Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 7e02140

Browse files
lidelAlan Shaw
authored and
Alan Shaw
committed
feat: resolution of .eth names via .eth.link (#2373)
.eth TLD is not recognised by mainstream DNS, however ENS provides DNS compatibility service at .eth.link This change enables resolution of ENS names ending with .eth on systems that have regular DNS set up More context at the go-ipfs counterpart: ipfs/kubo#6448 License: MIT Signed-off-by: Marcin Rataj <[email protected]>
1 parent d7a77a0 commit 7e02140

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/core/components/dns.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
const dns = require('../runtime/dns-nodejs')
55
const promisify = require('promisify-es6')
66

7+
function fqdnFixups (domain) {
8+
// Allow resolution of .eth names via .eth.link
9+
// More context at the go-ipfs counterpart: https://github.com/ipfs/go-ipfs/pull/6448
10+
if (domain.endsWith('.eth')) {
11+
domain = domain.replace(/.eth$/, '.eth.link')
12+
}
13+
return domain
14+
}
15+
716
module.exports = () => {
817
return promisify((domain, opts, callback) => {
918
if (typeof domain !== 'string') {
@@ -16,6 +25,7 @@ module.exports = () => {
1625
}
1726

1827
opts = opts || {}
28+
domain = fqdnFixups(domain)
1929

2030
dns(domain, opts, callback)
2131
})

test/http-api/inject/dns.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,22 @@ module.exports = (http) => {
1111
api = http.api._httpApi._apiServers[0]
1212
})
1313

14-
it('resolve ipfs.io dns', async () => {
14+
it('resolve ipfs.io DNS', async () => {
1515
const res = await api.inject({
1616
method: 'GET',
1717
url: '/api/v0/dns?arg=ipfs.io'
1818
})
1919

2020
expect(res.result).to.have.property('Path')
2121
})
22+
23+
it('resolve ipfs.enstest.eth ENS', async () => {
24+
const res = await api.inject({
25+
method: 'GET',
26+
url: '/api/v0/dns?arg=ipfs.enstest.eth'
27+
})
28+
29+
expect(res.result).to.have.property('Path')
30+
})
2231
})
2332
}

0 commit comments

Comments
 (0)