resolver: try servers in a random order on each resolution (closes #138)
check / check (push) Successful in 1m42s
check / check (push) Successful in 1m42s
Every resolution walked the root servers in a fixed order, so a.root-servers.net got every first query and its timeouts were paid on every lookup. Each list of servers the resolver walks is now walked in a random order from rand.Shuffle, chosen anew each time; a server that does not reply, refuses, or gives an error reply or a referral that leads no closer is still passed over for the next. When a referral names a zone's nameservers without their addresses, all of them are now looked up, not only the first that resolves, so the zone is not given up because the first nameserver whose address was found gave no usable reply. No test fails if the walk stops shuffling: which server a live query reached is not observable. Model: opus-5-5
This commit was merged in pull request #199.
This commit is contained in:
@@ -36,3 +36,24 @@ func (r *Resolver) QueryEachNS(
|
||||
) (map[string]*NameserverResponse, error) {
|
||||
return r.queryEachNS(ctx, nameservers, hostname)
|
||||
}
|
||||
|
||||
// ResolveNSIPs exports resolveNSIPs for testing.
|
||||
func (r *Resolver) ResolveNSIPs(
|
||||
ctx context.Context,
|
||||
nsNames []string,
|
||||
) []string {
|
||||
return r.resolveNSIPs(ctx, nsNames)
|
||||
}
|
||||
|
||||
// RootServerList exports rootServerList for testing.
|
||||
func RootServerList() []string {
|
||||
return rootServerList()
|
||||
}
|
||||
|
||||
// Shuffled exports shuffled for testing.
|
||||
func Shuffled(
|
||||
servers []string,
|
||||
shuffle func(n int, swap func(i, j int)),
|
||||
) []string {
|
||||
return shuffled(servers, shuffle)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user