@@ -178,8 +178,12 @@ type QueryOptions struct {
178178 RequestReferenceID ReferenceIDRequest
179179
180180 // RequestSupportedVersions indicates whether to request which versions of
181- // the NTP protocol are supported by the server in its response. Used only
182- // in NTPv5.
181+ // the NTP protocol are supported by the server. When used with NTPv5, the
182+ // response will list all supported versions. When used with NTPv3 or
183+ // NTPv4, the response's supported versions will include the version used
184+ // in the query as well as 5 if the server supports it. The response's
185+ // ReferenceTime field will be invalid in NTPv3 and NTPv4 if this option
186+ // is set.
183187 RequestSupportedVersions bool
184188
185189 // RequestCorrection indicates whether to request delay corrections from
@@ -484,6 +488,7 @@ func (r *Response) Log(w io.Writer) {
484488 fmt .Fprintf (w , " RootDelay: %s\n " , r .RootDelay )
485489 fmt .Fprintf (w , " RootDisp: %s\n " , r .RootDispersion )
486490 fmt .Fprintf (w , " RootDist: %s\n " , r .RootDistance )
491+ fmt .Fprintf (w , " Supported: %v\n " , r .SupportedVersions )
487492 fmt .Fprintf (w , " MinError: %s\n " , r .MinError )
488493 fmt .Fprintf (w , " RefTime: %s\n " , fmtTime (r .ReferenceTime ))
489494 if r .Version == 5 {
@@ -492,7 +497,6 @@ func (r *Response) Log(w io.Writer) {
492497 fmt .Fprintf (w , " Offsets: %s\n " , fmtTimescaleOffsets (r .TimescaleOffsets ))
493498 fmt .Fprintf (w , " MonoOffset: %s\n " , r .MonotonicOffset )
494499 fmt .Fprintf (w , " MonoEpoch: %s\n " , fmtEpoch (r .MonotonicEpochID ))
495- fmt .Fprintf (w , " Supported: %v\n " , r .SupportedVersions )
496500 fmt .Fprintf (w , " SrvCookie: %s" , fmtCookie (r .ServerCookie ))
497501 } else {
498502 fmt .Fprintf (w , " RefID: %s (0x%08x)\n " , r .ReferenceString (), r .ReferenceID )
@@ -559,9 +563,9 @@ func (r *Response) Validate() error {
559563 return ErrInvalidStratum
560564 }
561565
562- // Estimate the "freshness" of the time. If it exceeds the maximum
563- // polling interval (~36 hours), then it cannot be considered "fresh".
564- if r .Version < 5 || (r .Version == 5 && ! r .ReferenceTime .IsZero ()) {
566+ // Estimate the "freshness" of the time. If it exceeds the maximum polling
567+ // interval (~36 hours), then it cannot be considered "fresh".
568+ if ( r .Version < 5 && r . ReferenceTime != ntpEra0 ) || (r .Version == 5 && ! r .ReferenceTime .IsZero ()) {
565569 if freshness := r .Time .Sub (r .ReferenceTime ); freshness > maxPollInterval {
566570 return ErrServerClockFreshness
567571 }
@@ -1009,8 +1013,8 @@ func fmtFlags(flags ResponseFlags) string {
10091013}
10101014
10111015func fmtTime (value time.Time ) string {
1012- if value .IsZero ( ) {
1013- return "<zero >"
1016+ if value .Equal ( ntpEra0 ) {
1017+ return "<invalid >"
10141018 }
10151019 return value .Format (timeFormat )
10161020}
0 commit comments