diff --git a/src/core/components/dns.js b/src/core/components/dns.js index 55d81f1c04..7a083fdd6c 100644 --- a/src/core/components/dns.js +++ b/src/core/components/dns.js @@ -4,6 +4,15 @@ const dns = require('../runtime/dns-nodejs') const promisify = require('promisify-es6') +function fqdnFixups (domain) { + // Allow resolution of .eth names via .eth.link + // More context at the go-ipfs counterpart: https://github.com/ipfs/go-ipfs/pull/6448 + if (domain.endsWith('.eth')) { + domain = domain.replace(/.eth$/, '.eth.link') + } + return domain +} + module.exports = () => { return promisify((domain, opts, callback) => { if (typeof domain !== 'string') { @@ -16,6 +25,7 @@ module.exports = () => { } opts = opts || {} + domain = fqdnFixups(domain) dns(domain, opts, callback) }) diff --git a/test/http-api/inject/dns.js b/test/http-api/inject/dns.js index 18f0ec5925..ee2a4e88ca 100644 --- a/test/http-api/inject/dns.js +++ b/test/http-api/inject/dns.js @@ -11,7 +11,7 @@ module.exports = (http) => { api = http.api._httpApi._apiServers[0] }) - it('resolve ipfs.io dns', async () => { + it('resolve ipfs.io DNS', async () => { const res = await api.inject({ method: 'GET', url: '/api/v0/dns?arg=ipfs.io' @@ -19,5 +19,14 @@ module.exports = (http) => { expect(res.result).to.have.property('Path') }) + + it('resolve ipfs.enstest.eth ENS', async () => { + const res = await api.inject({ + method: 'GET', + url: '/api/v0/dns?arg=ipfs.enstest.eth' + }) + + expect(res.result).to.have.property('Path') + }) }) }