Skip to content

Commit

Permalink
feat!: use custom DNS resolver in @helia/ipns for DNSLink
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
achingbrain committed Mar 12, 2024
1 parent 02e709d commit d941ad6
Show file tree
Hide file tree
Showing 16 changed files with 319 additions and 665 deletions.
45 changes: 45 additions & 0 deletions packages/interop/src/ipns-dnslink.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* eslint-env mocha */

import { ipns } from '@helia/ipns'
import { expect } from 'aegir/chai'
import { createHeliaNode } from './fixtures/create-helia.js'
import type { IPNS } from '@helia/ipns'
import type { HeliaLibp2p } from 'helia'

const TEST_DOMAINS: string[] = [
'ipfs.io',
'docs.ipfs.tech',
'en.wikipedia-on-ipfs.org',
'blog.libp2p.io',
'consensuslab.world',
'n0.computer',
'protocol.ai',
'research.protocol.ai',
'probelab.io',
'singularity.storage',
'saturn.tech'
]

describe('@helia/ipns - dnslink', () => {
let helia: HeliaLibp2p
let name: IPNS

beforeEach(async () => {
helia = await createHeliaNode()
name = ipns(helia)
})

afterEach(async () => {
if (helia != null) {
await helia.stop()
}
})

TEST_DOMAINS.forEach(domain => {
it(`should resolve ${domain}`, async () => {
const result = await name.resolveDNSLink(domain)

expect(result).to.have.property('cid')
})
})
})
5 changes: 1 addition & 4 deletions packages/ipns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,10 @@
"@libp2p/kad-dht": "^12.0.8",
"@libp2p/logger": "^4.0.7",
"@libp2p/peer-id": "^4.0.7",
"dns-over-http-resolver": "^3.0.2",
"dns-packet": "^5.6.1",
"hashlru": "^2.3.0",
"@multiformats/dns": "^1.0.1",
"interface-datastore": "^8.2.11",
"ipns": "^9.0.0",
"multiformats": "^13.1.0",
"p-queue": "^8.0.1",
"progress-events": "^1.0.0",
"uint8arrays": "^5.0.2"
},
Expand Down
9 changes: 0 additions & 9 deletions packages/ipns/src/dns-resolvers/default.ts

This file was deleted.

90 changes: 0 additions & 90 deletions packages/ipns/src/dns-resolvers/dns-json-over-https.ts

This file was deleted.

146 changes: 0 additions & 146 deletions packages/ipns/src/dns-resolvers/dns-over-https.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/ipns/src/dns-resolvers/index.ts

This file was deleted.

50 changes: 0 additions & 50 deletions packages/ipns/src/dns-resolvers/resolver.browser.ts

This file was deleted.

25 changes: 0 additions & 25 deletions packages/ipns/src/dns-resolvers/resolver.ts

This file was deleted.

Loading

0 comments on commit d941ad6

Please sign in to comment.