feat(namesys): propagate DNSLink TXT TTL#1167
Open
lidel wants to merge 2 commits into
Open
Conversation
The DNS resolver dropped the TXT record TTL, so a gateway could not set Cache-Control max-age for DNSLink (/ipns/<dnslink-host>) responses, and a recursive name was cached for only its final hop's TTL. - add LookupTXTWithTTLFunc and NewDNSResolverWithTTL; LookupTXTFunc and NewDNSResolver keep their signatures and report an unknown TTL (0) - carry the looked-up TTL into AsyncResult.TTL in the DNS resolver - WithDNSResolver detects a resolver implementing multiformats/go-multiaddr-dns#75 TXTWithTTLResolver and propagates the TTL; add WithDNSResolverWithTTL for a TTL-aware lookup - cap a resolved name's TTL to its shortest hop, so a DNSLink or recursive IPNS name is not cached past its earliest-expiring link Refs #329
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #1167 +/- ##
=======================================
Coverage 63.39% 63.39%
=======================================
Files 268 268
Lines 26967 26987 +20
=======================================
+ Hits 17096 17109 +13
- Misses 8147 8153 +6
- Partials 1724 1725 +1
... and 4 files with indirect coverage changes 🚀 New features to boost your workflow:
|
gammazero
approved these changes
Jun 3, 2026
drop the min from negative inputs so a negative TTL is never returned; cover the negative cases in the test table.
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
boxo's DNS resolver discards the TTL of DNSLink TXT records and returns 0. The gateway sets
Cache-Control: max-agefor mutable paths only when the TTL is non-zero, so DNSLink (/ipns/<dnslink-host>) responses go out with no max-age and fall back to a static value, even though the TXT record states exactly how long the mapping is valid (#329). Recursive names made it worse: a name resolved through several records was cached for only its final hop's TTL, ignoring shorter-lived links earlier in the chain.Fix
AsyncResult.TTL/Result.TTL), which the gateway already turns intoCache-Control: max-age.NewDNSResolverWithTTL,WithDNSResolverWithTTL, andLookupTXTWithTTLFuncfor a TTL-aware lookup.WithDNSResolverauto-detects a resolver that implementsmadns.TXTWithTTLResolverand uses it.NewDNSResolverandLookupTXTFunckeep their signatures and report an unknown TTL (0), so existing callers are unchanged; the new behavior stays inert until the resolver passed toWithDNSResolveractually reports TTLs.Upstream PRs to land first
Required before this PR can build and merge:
madns.TXTWithTTLResolverand routesLookupTXTWithTTL.go.modpins its commit here; re-pin to a tagged release once it merges.Needed only to switch DNSLink
Cache-Controlon end-to-end (a separate follow-up boxo PR, not this one):go.modbump of both deps, with no code change, sinceWithDNSResolverauto-detects the capability.Part of #329. ETag for resolved paths (the issue's other half) is out of scope.