fix(gw): frugal DNSLink lookups on subdomains #493
Merged
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.
This PR refactors the rushed ipfs-companion Manifest V3 fix from #462 to be more efficient and with better UX.
The old version was not very smart and wasted DNS lookup per every inlined DNSLink label (
my-v--long-example-com
) before retrying with un-inlined one (my.v-long.example.com
).This version is optimized to avoid unnecessary DNS lookups for both positive and negative scenarios.
It also ensures that in case of missing DNSLink, real FQDN (un-inlined domain name) is used in error path, which makes better UX AND simplifies the flow related to content blocking @hsanjuan is working on.
Before
Positive scenario
$ curl http://en-wikipedia--on--ipfs-org.ipns.localhost:8080 -H 'X-Forwarded-Proto: https'
DNS lookups made by gateway:
en-wikipedia--on--ipfs-org
(💢 we tried the unlikely inlined version for every name first, and it always failed)en.wikipedia-on-ipfs.org
Negative scenario (no DNSLink)
💢 Note: error message is about inlined notation
google-com
and not the real domaingoogle.com
👎DNS lookups made by gateway:
google-com
(💢 less likely, but we checked it first)google.com
(more likely, but we checked this second)After
Positive scenario
$ curl http://google-com.ipns.localhost:8080 -H 'X-Forwarded-Proto: https'
DNS lookups made by gateway:
en.wikipedia-on-ipfs.org
(:green_circle: no wasted lookups)Negative scenario (no DNSLink)
🟢 Note: error message is about real domain
google.com
and not inlined notationgoogle-com
👍DNS lookups made by gateway:
google.com
(:green_circle: we try this first as it is more likely to have dnslink, as seen in positive scenario above)google-com
(:green_circle: less likely, but we have to check to avoid false-negatives)