Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: use custom DNS resolver in @helia/ipns for DNSLink #466

Merged
merged 11 commits into from
Mar 14, 2024

Conversation

achingbrain
Copy link
Member

@achingbrain achingbrain commented Mar 12, 2024

Uses the .dns property from #465 to resolve DNS TXT records.

This allows configuring discrete resolvers for different TLDs, unifies caching across different use of DNS (e.g. dnsaddr multiaddrs), etc.

Refs: ipfs/helia-verified-fetch#13 (comment)
Fixes: #369

BREAKING CHANGE: requires @helia/[email protected] or later, resolveDns has been renamed resolveDNSLink

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation if necessary (this includes comments as well)
  • I have added tests that prove my fix is effective or that my feature works

Exposes a `.dns` property on the Helia interface for use with other
modules such as @helia/ipns.

Refs: ipfs/helia-verified-fetch#13 (comment)
Uses the `.dns` property from #465 to resolve DNS `TXT` records.

This allows configuring discrete resolvers for different TLDs, unifies caching across different use of DNS (e.g. dnsaddr multiaddrs), etc.

BREAKING CHANGE: requires @helia/[email protected] or later, `resolveDns` has been renamed `resolveDNSLink`
@achingbrain achingbrain requested a review from a team as a code owner March 12, 2024 13:31
@achingbrain
Copy link
Member Author

#465 should be merged first to prevent this change causing a breaking change to cascade to other modules in this monorepo.

Base automatically changed from feat/expose-dns-property to main March 13, 2024 05:27
result = result.substring(1, result.length - 1)
}

if (!result.startsWith('dnslink=')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do

Suggested change
if (!result.startsWith('dnslink=')) {
if (!result.startsWith('dnslink=/ip')) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because we want to handle weird things like dnslink=/dnslink/blah.com

Comment on lines +28 to +30
if (result.startsWith('"') && result.endsWith('"')) {
result = result.substring(1, result.length - 1)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is a leading or trailing " will there always be the other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empirical evidence suggests yes, the spec is silent.

*/
resolvers?: DNSResolver[]
maxRecursiveDepth?: number
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the method for users to pass a custom one-off resolver with these new changes?

Copy link
Member Author

@achingbrain achingbrain Mar 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add an optional dns?: DNS key, but the caching situation gets a little weird - is this something we do often?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was requested by a user a few months ago, but a dnsResolver map might handle their usecase?

@achingbrain achingbrain merged commit 2c71b6e into main Mar 14, 2024
18 checks passed
@achingbrain achingbrain deleted the feat/use-custom-dns-resolver-in-ipns branch March 14, 2024 06:42
@achingbrain achingbrain mentioned this pull request Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ignore non-IPFS content paths in DNSLink records
2 participants