Sanity validate ntp response
This commit is contained in:
parent
291ad8fa35
commit
ae7faece88
|
@ -73,6 +73,9 @@ func computeOffset(timeQuery ntpQuery, servers []string, allowedFailures int) (t
|
||||||
response, err := timeQuery(server, ntp.QueryOptions{
|
response, err := timeQuery(server, ntp.QueryOptions{
|
||||||
Timeout: DefaultRPCTimeout,
|
Timeout: DefaultRPCTimeout,
|
||||||
})
|
})
|
||||||
|
if err == nil {
|
||||||
|
err = response.Validate()
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
responses <- queryResponse{Error: err}
|
responses <- queryResponse{Error: err}
|
||||||
return
|
return
|
||||||
|
|
|
@ -39,7 +39,10 @@ func (tc *testCase) query(string, ntp.QueryOptions) (*ntp.Response, error) {
|
||||||
tc.actualAttempts++
|
tc.actualAttempts++
|
||||||
tc.mu.Unlock()
|
tc.mu.Unlock()
|
||||||
}()
|
}()
|
||||||
response := &ntp.Response{ClockOffset: tc.responses[tc.actualAttempts].Offset}
|
response := &ntp.Response{
|
||||||
|
ClockOffset: tc.responses[tc.actualAttempts].Offset,
|
||||||
|
Stratum: 1,
|
||||||
|
}
|
||||||
return response, tc.responses[tc.actualAttempts].Error
|
return response, tc.responses[tc.actualAttempts].Error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue