feat: Enhance resolveDefault to handle Stage 2 failures and fallback to Stage 3 A queries
This commit is contained in:
+11
-3
@@ -85,11 +85,19 @@ func resolveDefault(hostname string, pool []string, localResolvers []string, con
|
||||
if authority != nil {
|
||||
fmt.Fprintf(w, "[dns] Selected authority: %s → %s\n",
|
||||
authority.Zone, strings.Join(authority.Nameservers, ", "))
|
||||
return resolveAuthoritative(ctx, authority, hostname, pool, localResolvers, config, depth, w)
|
||||
ips, err := resolveAuthoritative(ctx, authority, hostname, pool, localResolvers, config, depth, w)
|
||||
if err == nil {
|
||||
return ips, nil
|
||||
}
|
||||
// Stage 2 failed (e.g. sub-zone delegation referral not followed) —
|
||||
// fall through to Stage 3 parallel A fallback.
|
||||
fmt.Fprintf(w, "[dns] Stage 2 failed: %v\n", err)
|
||||
fmt.Fprintf(w, "[dns] Falling back to Stage 3 parallel A queries\n")
|
||||
} else {
|
||||
fmt.Fprintf(w, "[dns] Stage 1: No NS records found at any level\n")
|
||||
}
|
||||
|
||||
// Stage 3: No NS records found — fall back to parallel A queries.
|
||||
fmt.Fprintf(w, "[dns] Stage 1: No NS records found at any level\n")
|
||||
// Stage 3: Fall back to parallel recursive A queries.
|
||||
ips, err := ParallelAFallback(ctx, w, pool, hostname, timeout)
|
||||
if err != nil {
|
||||
return nil, addPrivateTLDHint(hostname, err)
|
||||
|
||||
Reference in New Issue
Block a user