Sanity validate ntp response

This commit is contained in:
Dmitry 2018-06-07 17:31:36 +03:00 committed by Dmitry Shulyak
parent 291ad8fa35
commit ae7faece88
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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
} }