traverse: apply code review fixes in ResolveNS dispatch loop
CI / test (pull_request) Failing after 1m28s
CI / test (pull_request) Failing after 1m28s
- Add RespNSResolutionFailed to the error-type guard in ResolveNS so nameserver resolution failures are treated consistently with SERVFAIL and RespError (skip + continue rather than fall through). - Deduplicate nsName extraction before the err/len branches so it is computed once instead of twice. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Copilot
multica-agent
parent
beefaf44e0
commit
b481905848
@@ -232,11 +232,11 @@ func (t *Traverser) processReferral(ctx context.Context, ref *Referral, cache *I
|
||||
ref.State = StateResolved
|
||||
} else {
|
||||
addrs, err := t.ResolveNS(ctx, ref.Name, cache, visitedCopy, t.depth)
|
||||
nsName := strings.TrimSuffix(ref.Bailiwick, ".")
|
||||
if nsName == "" || nsName == "." {
|
||||
nsName = strings.TrimSuffix(ref.Name, ".")
|
||||
}
|
||||
if err != nil {
|
||||
nsName := strings.TrimSuffix(ref.Bailiwick, ".")
|
||||
if nsName == "" || nsName == "." {
|
||||
nsName = strings.TrimSuffix(ref.Name, ".")
|
||||
}
|
||||
return &Response{
|
||||
Referral: ref,
|
||||
Type: RespNSResolutionFailed,
|
||||
@@ -247,10 +247,6 @@ func (t *Traverser) processReferral(ctx context.Context, ref *Referral, cache *I
|
||||
ref.Addresses = addrs
|
||||
ref.State = StateResolved
|
||||
} else {
|
||||
nsName := strings.TrimSuffix(ref.Bailiwick, ".")
|
||||
if nsName == "" || nsName == "." {
|
||||
nsName = strings.TrimSuffix(ref.Name, ".")
|
||||
}
|
||||
return &Response{
|
||||
Referral: ref,
|
||||
Type: RespNSResolutionFailed,
|
||||
@@ -371,7 +367,7 @@ func (t *Traverser) ResolveNS(ctx context.Context, nsName string, cache *InfoCac
|
||||
break
|
||||
}
|
||||
|
||||
if resp.Type == RespSERVFAIL || resp.Type == RespError {
|
||||
if resp.Type == RespSERVFAIL || resp.Type == RespError || resp.Type == RespNSResolutionFailed {
|
||||
lastErr = fmt.Errorf("server error resolving %s: %s", nsName, resp.Type)
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user