resolver: take a domain's NS set from its delegation (closes #200)
check / check (push) Failing after 2m2s
check / check (push) Failing after 2m2s
A domain's NS set was taken from whichever of its own servers answered first, so when they disagree (during a move between DNS providers, or with a stale secondary) the set could change between checks and send an NS change notification with nothing changed. The walk now stops at the referral to the domain from its parent zone's servers and returns that delegation, which those servers all hold alike; the domain's own servers are no longer asked for it. The NS records in an answer are still used where no such referral comes first, as from a server that holds both the parent zone and the domain. Hostnames get their zone's servers the same way. Model: opus-5-5
This commit was merged in pull request #202.
This commit is contained in:
@@ -222,9 +222,9 @@ func (r *Resolver) followDelegation(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ansNS := extractNSSet(resp.Answer)
|
||||
if len(ansNS) > 0 {
|
||||
return ansNS, nil
|
||||
nsSet := nsSetFrom(resp, domain)
|
||||
if len(nsSet) > 0 {
|
||||
return nsSet, nil
|
||||
}
|
||||
|
||||
// An authoritative reply comes from the servers of the zone
|
||||
@@ -325,6 +325,21 @@ func referralZone(resp *dns.Msg) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// nsSetFrom returns the NS set of domain that resp, a reply to a query
|
||||
// for domain's NS records, gives: the delegation in a referral to domain
|
||||
// itself, or else the NS records in the answer; empty when it gives
|
||||
// neither. A referral to domain comes from its parent zone's servers,
|
||||
// which all hold the same delegation, so the set does not depend on
|
||||
// which of them answered. domain's own servers, which can disagree about
|
||||
// their NS records, are then not asked.
|
||||
func nsSetFrom(resp *dns.Msg, domain string) []string {
|
||||
if referralZone(resp) == domain {
|
||||
return extractNSSet(resp.Ns)
|
||||
}
|
||||
|
||||
return extractNSSet(resp.Answer)
|
||||
}
|
||||
|
||||
func (r *Resolver) resolveNSIPs(
|
||||
ctx context.Context,
|
||||
nsNames []string,
|
||||
@@ -372,7 +387,7 @@ func (r *Resolver) resolveNSIterative(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nsNames := extractNSSet(resp.Answer)
|
||||
nsNames := nsSetFrom(resp, domain)
|
||||
if len(nsNames) > 0 {
|
||||
return nsNames, nil
|
||||
}
|
||||
@@ -465,7 +480,8 @@ func (r *Resolver) resolveARecord(
|
||||
|
||||
// FindAuthoritativeNameservers traces the delegation chain from
|
||||
// root servers to discover all authoritative nameservers for the
|
||||
// given domain. For a name that is not a zone apex it tries each
|
||||
// given domain, as the delegation from its parent zone's servers lists
|
||||
// them. For a name that is not a zone apex it tries each
|
||||
// parent name in turn, so it returns the nameservers of the zone the
|
||||
// name is in.
|
||||
func (r *Resolver) FindAuthoritativeNameservers(
|
||||
@@ -631,9 +647,10 @@ func (r *Resolver) querySingleType(
|
||||
|
||||
// A reply with no answer that lists other nameservers, from a server
|
||||
// that does not hold the name's zone, is a referral and says nothing
|
||||
// about the name's records. A parent zone's servers send one when
|
||||
// every server of the name's own zone failed and
|
||||
// FindAuthoritativeNameservers moved on to the parent name.
|
||||
// about the name's records. A server named in the delegation that
|
||||
// does not hold the zone may send one, as do a parent zone's servers
|
||||
// when FindAuthoritativeNameservers found no delegation for the
|
||||
// name's zone and moved on to a parent name.
|
||||
if !msg.Authoritative && len(msg.Answer) == 0 &&
|
||||
len(extractNSSet(msg.Ns)) > 0 {
|
||||
state.gotReferral = true
|
||||
|
||||
Reference in New Issue
Block a user