feat: resolve /dnsaddr before filtering - #174
Merged
Merged
Conversation
lidel
force-pushed
the
feat/resolve-dnsaddr
branch
from
July 29, 2026 12:06
dde90ff to
b730f13
Compare
A /dnsaddr carries no transport component, so filter-addrs can neither match it nor exclude it: a ws-speaking peer was dropped by ?filter-addrs=ws, and a quic-only peer survived ?filter-addrs=!quic-v1. Neither is detectable by the client. someguy now resolves before boxo filters, which fixes both directions. See ipfs/specs#542. A filtered request has its /dnsaddr replaced, since keeping it would let a record survive a filter meant to exclude it. The exception is a positive filter naming dnsaddr, the one filter a /dnsaddr matches; the client is asking for indirections, so the /dnsaddr is kept alongside what it resolves to. An unfiltered request gets the resolved addresses added and keeps the /dnsaddr, so it can dial now and re-resolve later. SOMEGUY_DNSADDR_RESOLUTION names what an unfiltered response does with the /dnsaddr: append (default), replace, filtered, or never. Hostnames in provider records are attacker-chosen, and resolution runs inline while the response streams, so it is bounded on four axes: DNS lookups per request, resolved addresses per record, recursion depth, and a per-lookup timeout, which together also cap the delay resolution can add to one response. The per-record limit is threaded through the recursion rather than applied to the finished result: a TXT record that lists itself expands as fan^depth, and re-entering a cached name costs no lookup, so a limit checked at the end still let one request build millions of addresses. - resolve detached from the request context behind a singleflight, so a disconnect cannot cache its own cancellation as a 15 minute failure - shed load once the request is gone rather than spend the rest of its budget on queries nothing will read - keep the original whenever an expansion is not whole, so a failed or throttled lookup does not drop the indirection the rest lives behind - drop a /dnsaddr naming a different peer: nothing it yields can belong to the record carrying it - normalize only the hostname in cache keys, over ASCII: lowering a whole multiaddr folds case-sensitive components together, and Unicode case mapping folds U+0130 and U+212A onto ASCII, which let one record cache a failure under another name's key - skip lookups madns can never satisfy, such as a /p2p-circuit suffix - order addresses by how directly they dial: IP, DNS, dnsaddr, relay last - require go 1.26
lidel
force-pushed
the
feat/resolve-dnsaddr
branch
from
July 29, 2026 13:00
b730f13 to
841c42a
Compare
lidel
marked this pull request as ready for review
July 29, 2026 14:51
Merged
lidel
added a commit
that referenced
this pull request
Jul 29, 2026
Minor rather than patch: #174 adds SOMEGUY_DNSADDR_RESOLUTION and changes what /routing/v1 returns by default (dnsaddr resolution, address order), and Go 1.26 is now the minimum.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A
/dnsaddrcarries no transport component, sofilter-addrscan neither match nor exclude it: a ws-speaking peer behind one vanishes from?filter-addrs=ws, and a quic-only peer survives?filter-addrs=!quic-v1. The client can't detect either case.1Credit to @achingbrain for flagging this gap
Fix
/dnsaddrbefore boxo filters: a filtered request gets it replaced (exceptfilter-addrs=dnsaddr, the one filter that matches it), an unfiltered one keeps it alongside the resolved addressesSOMEGUY_DNSADDR_RESOLUTIONnames what an unfiltered response does with the/dnsaddr:append(default),replace,filtered, orneverdocs/dnsaddr-resolution.mdcarries the rationale/dnsaddr, relays lastThis turned out to not be trivial due to the way things work, and increased surface for abuse, but with enough code/tests should be good to go now.
Footnotes
delegated routing: resolve DNSADDR addresses before filtering specs#542 proposes this behavior for every Delegated Routing implementation. I think there is more nuance, thus this PR provides
SOMEGUY_DNSADDR_RESOLUTIONconfiguration flag. ↩