You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
-rate still under-counts wire queries: CNAME sends 3 queries and Go's resolver retries internally #50
#32 made -rate and -max-queries reserve per wire query, and the README now promises -rate is "max DNS queries per second on the wire ... including every record type, retry, wildcard probe and the preflight". Two gaps remain, and both overshoot the limit precisely when a resolver is struggling, which is when users rely on -rate to avoid bans.
Evidence
CNAME is charged 2 slots but sends 3 queries. In Go 1.24, net.Resolver.LookupCNAME issues A, AAAA and CNAME queries. See internal/dns/resolver.go:122 (queriesPerType). Repro: 3 wire queries, 2 slots charged.
Retries inside the Go resolver are never charged.tryOneName loops attempts(2) × len(system nameservers) on SERVFAIL, REFUSED or socket errors. The custom Dial (resolver.go:142-146) sends every one of those to -dns-server.
Repro: one SERVFAIL A lookup put 4 queries on the wire and was charged 1 slot.
With -attempts 3, the same lookup put 12 on the wire and was charged 3.
The multiplier depends on the host's resolv.conf.
Related limits of the stdlib client.
RCODE REFUSED is reported as "server misbehaving" and counted as OutcomeOther, so the "refused" stat never reflects the most common rate-limit signal (resolver.go:62).
Error text names the system nameserver instead of the configured -dns-server.
Suggested approach
Short term:
Set CNAME's cost to 3.
In the Dial hook, reserve a rate slot for every dial beyond the pre-reserved count. Each Go exchange dials a fresh connection, so dials equal queries.
Long term (recommended): move to a DNS client with one server and an explicit attempt count, such as github.com/miekg/dns. That gives exact accounting, real RCODEs (REFUSED, SERVFAIL), correct error text, and simpler tests.
Done when
A test asserts that wire queries equal charged slots for each record type, including under SERVFAIL.
Activity
test: shared scriptable DNS server (internal/dnstest) and new scenarios