Skip to content

Commit f44dd09

Browse files
committed
Fix tunnel check failing all resolvers on subdomain delegations
QueryNS only checked the Answer section for NS records, but for subdomain delegations (e.g. t.example.com) most resolvers return NS records in the Authority section. Now checks both.
1 parent a408276 commit f44dd09

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

internal/scanner/dns.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,20 @@ func QueryNS(resolver, domain string, timeout time.Duration) ([]string, bool) {
4040
return nil, false
4141
}
4242
var hosts []string
43+
// Check Answer section first
4344
for _, ans := range r.Answer {
4445
if ns, ok := ans.(*dns.NS); ok {
4546
hosts = append(hosts, ns.Ns)
4647
}
4748
}
49+
// For subdomain delegations, NS records are often in the Authority section
50+
if len(hosts) == 0 {
51+
for _, ans := range r.Ns {
52+
if ns, ok := ans.(*dns.NS); ok {
53+
hosts = append(hosts, ns.Ns)
54+
}
55+
}
56+
}
4857
if len(hosts) == 0 {
4958
return nil, false
5059
}

internal/scanner/doh.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,20 @@ func QueryDoHNS(resolverURL, domain string, timeout time.Duration) ([]string, bo
8383
return nil, false
8484
}
8585
var hosts []string
86+
// Check Answer section first
8687
for _, ans := range r.Answer {
8788
if ns, ok := ans.(*dns.NS); ok {
8889
hosts = append(hosts, ns.Ns)
8990
}
9091
}
92+
// For subdomain delegations, NS records are often in the Authority section
93+
if len(hosts) == 0 {
94+
for _, ans := range r.Ns {
95+
if ns, ok := ans.(*dns.NS); ok {
96+
hosts = append(hosts, ns.Ns)
97+
}
98+
}
99+
}
91100
if len(hosts) == 0 {
92101
return nil, false
93102
}

0 commit comments

Comments
 (0)