resolver: a nameserver is asked at each of its addresses in turn (closes #285)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
A nameserver's queries went only to the first IPv4 address its name resolves to, so one unreachable address made it fail whenever that address came first in the answer. Each record type is now asked at the addresses one at a time until one gives a usable reply, and the next type is asked first at the address that gave it. A type that fails is logged with the reason at each address, and a nameserver is reported as timed out only when every query timed out; one given no address has failed. The README's DNS Resolution Strategy says which addresses are asked. Model: opus-5-5
This commit was merged in pull request #291.
This commit is contained in:
@@ -15,8 +15,10 @@ import (
|
||||
// that answered some record types, even with no records, has not failed
|
||||
// when its query for another type got no usable reply, whatever the
|
||||
// reason, and is ok, not nodata: that type may have records. One whose
|
||||
// every query got none has failed. Only one whose every type answered
|
||||
// with no records is nodata.
|
||||
// every query got none has failed, and its error says all queries timed
|
||||
// out only when every one did: a reply such as a refusal, or a network
|
||||
// error, at one of its addresses is given instead. Only one whose every
|
||||
// type answered with no records is nodata.
|
||||
func TestClassifyResponse(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -27,63 +29,46 @@ func TestClassifyResponse(t *testing.T) {
|
||||
wantStatus string
|
||||
wantError string
|
||||
}{
|
||||
{
|
||||
"every type answered with no records",
|
||||
{"every type answered with no records",
|
||||
queryState{answered: true},
|
||||
nil,
|
||||
StatusNoData, "",
|
||||
},
|
||||
{
|
||||
"some types answered with no records, another timed out",
|
||||
nil, StatusNoData, ""},
|
||||
{"some types answered with no records, another timed out",
|
||||
queryState{answered: true, gotTimeout: true},
|
||||
[]string{"A"},
|
||||
StatusOK, "",
|
||||
},
|
||||
{
|
||||
"some types answered with no records, another got SERVFAIL",
|
||||
queryState{
|
||||
answered: true, gotErrorReply: true, errorReply: "SERVFAIL",
|
||||
},
|
||||
[]string{"A"},
|
||||
StatusOK, "",
|
||||
},
|
||||
{
|
||||
"some types answered with no records, another was refused",
|
||||
[]string{"A"}, StatusOK, ""},
|
||||
{"some types answered with no records, another got SERVFAIL",
|
||||
queryState{answered: true, gotErrorReply: true, errorReply: "SERVFAIL"},
|
||||
[]string{"A"}, StatusOK, ""},
|
||||
{"some types answered with no records, another was refused",
|
||||
queryState{answered: true, gotRefused: true},
|
||||
[]string{"A"},
|
||||
StatusOK, "",
|
||||
},
|
||||
{
|
||||
"some types answered with no records, another got a network error",
|
||||
[]string{"A"}, StatusOK, ""},
|
||||
{"some types answered with no records, another got a network error",
|
||||
queryState{answered: true, netErr: syscall.ECONNREFUSED},
|
||||
[]string{"A"},
|
||||
StatusOK, "",
|
||||
},
|
||||
{
|
||||
"some types answered with no records, another's reply was " +
|
||||
"truncated and its retry over TCP failed",
|
||||
[]string{"A"}, StatusOK, ""},
|
||||
{"some types answered with no records, another's reply was " +
|
||||
"truncated and its retry over TCP failed",
|
||||
queryState{answered: true, netErr: ErrTruncated},
|
||||
[]string{"TXT"},
|
||||
StatusOK, "",
|
||||
},
|
||||
{
|
||||
"some types answered with no records, another got a referral",
|
||||
[]string{"TXT"}, StatusOK, ""},
|
||||
{"some types answered with no records, another got a referral",
|
||||
queryState{answered: true, gotReferral: true},
|
||||
[]string{"A"},
|
||||
StatusOK, "",
|
||||
},
|
||||
{
|
||||
"every query timed out",
|
||||
[]string{"A"}, StatusOK, ""},
|
||||
{"every query timed out",
|
||||
queryState{gotTimeout: true},
|
||||
[]string{"A", "AAAA", "CNAME"},
|
||||
StatusTimeout, "all queries timed out",
|
||||
},
|
||||
{
|
||||
"every query got NOTIMP",
|
||||
[]string{"A", "AAAA", "CNAME"}, StatusTimeout, "all queries timed out"},
|
||||
{"every query got NOTIMP",
|
||||
queryState{gotErrorReply: true, errorReply: "NOTIMP"},
|
||||
[]string{"A", "AAAA", "CNAME"},
|
||||
StatusError, "server returned NOTIMP",
|
||||
},
|
||||
[]string{"A", "AAAA", "CNAME"}, StatusError, "server returned NOTIMP"},
|
||||
{"every query got SERVFAIL at one address, timed out at another",
|
||||
queryState{gotErrorReply: true, errorReply: "SERVFAIL", gotTimeout: true},
|
||||
[]string{"A"}, StatusError, "server returned SERVFAIL"},
|
||||
{"every query was refused at one address, timed out at another",
|
||||
queryState{gotRefused: true, gotTimeout: true},
|
||||
[]string{"A"}, StatusError, "server returned REFUSED"},
|
||||
{"every query got a network error at one address, timed out at another",
|
||||
queryState{netErr: syscall.ECONNREFUSED, gotTimeout: true},
|
||||
[]string{"A"}, StatusError, "network error: connection refused"},
|
||||
{"every query got a referral at one address, timed out at another",
|
||||
queryState{gotReferral: true, gotTimeout: true},
|
||||
[]string{"A"}, StatusError, "server returned a referral"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user