feat: add LookupTXTWithTTL to expose TXT record TTL#33
Open
lidel wants to merge 1 commit into
Open
Conversation
LookupTXT discarded the TTL that doRequestTXT already computes from the DNS answer, so callers had no way to learn how long a TXT record set is valid. This blocks consumers (e.g. a gateway resolving DNSLink) from setting Cache-Control max-age based on the real DNS TTL. Add LookupTXTWithTTL which returns the records plus their TTL. LookupTXT delegates to it so behavior is unchanged. On a cache hit the remaining lifetime is returned so the value does not over-report as the entry ages, and it is capped by the resolver max cache TTL. A TTL of 0 means unknown.
This was referenced Jun 3, 2026
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
LookupTXTcomputes the TXT record TTL (the smallestHdr.Ttlacross the answer) to size its internal cache, then throws it away before returning. Callers get the records but no indication of how long they are valid.This blocks IPFS gateways from setting
Cache-Control: max-age=<ttl>for DNSLink based on the DNS record's real TTL. DNSLink resolution flows through this resolver, but the TTL is lost at theLookupTXTboundary, so aboxo/gatewaylibrary (used by IPFS Desktop, Kubo, Rainbow, ipfs.io etc) emits noCache-Controlfor/ipns/<dnslink-host>responses and falls back to a static value. See ipfs/boxo#329 and the path-gateway spec's Cache-Control section [1]; tracked for Kubo under ipfs/kubo#8717.Fix
LookupTXTWithTTL(ctx, domain) ([]string, time.Duration, error), returning the records plus their TTL.LookupTXTnow delegates to it, so its behavior is unchanged and the resolver still satisfiesmadns.BasicResolver(the new method is additive).WithMaxCacheTTL); a TTL of0means unknown.This lets consumers such as
boxo/namesysthread the DNS TTL through to the gateway'sCache-Control. A follow-up boxo change will consume it via a new TTL-aware lookup option.[1] https://specs.ipfs.tech/http-gateways/path-gateway/#cache-control-response-header