Improve DNS output: distinguish NS resolution failures from domain errors (#20)
CI / test (push) Failing after 2m19s
CI / test (push) Failing after 2m19s
This commit was merged in pull request #20.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -231,10 +232,15 @@ 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 {
|
||||
return &Response{
|
||||
Referral: ref,
|
||||
Type: RespError,
|
||||
Referral: ref,
|
||||
Type: RespNSResolutionFailed,
|
||||
ErrorMessage: fmt.Sprintf("nameserver %s could not be resolved", nsName),
|
||||
}
|
||||
}
|
||||
if len(addrs) > 0 {
|
||||
@@ -242,8 +248,9 @@ func (t *Traverser) processReferral(ctx context.Context, ref *Referral, cache *I
|
||||
ref.State = StateResolved
|
||||
} else {
|
||||
return &Response{
|
||||
Referral: ref,
|
||||
Type: RespError,
|
||||
Referral: ref,
|
||||
Type: RespNSResolutionFailed,
|
||||
ErrorMessage: fmt.Sprintf("nameserver %s could not be resolved", nsName),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -360,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