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

ipfs.dns does not handle subdomains correctly #1932

Closed
niinpatel opened this issue Mar 14, 2019 · 0 comments · Fixed by #1933
Closed

ipfs.dns does not handle subdomains correctly #1932

niinpatel opened this issue Mar 14, 2019 · 0 comments · Fixed by #1933

Comments

@niinpatel
Copy link
Contributor

niinpatel commented Mar 14, 2019

When I do ipfs.dns('docs.ipfs.io'). It throws an error 'ENODATA'. I did some digging and found out that this error is thrown by nodejs' dns.resolveTxt method when it does not find any txt records.

Now, to handle subdomain correctly, we need to append _dnslink. string to it, which we do here

const _dnslinkDomain = `_dnslink.${domain}`
// If this throws then we propagate the error
return resolveDnslink(_dnslinkDomain)

But, the problem is, the error is way before the line gets to be executed, here:

if (err.code !== 'ENOTFOUND' && err.code !== 'ERR_DNSLINK_NOT_FOUND') throw err

The easiest solution to this problem would be to check for err.code 'ENODATA' also along with 'ENOTFOUND', etc. in the if condition. So, the next lines get a chance to be executed.

Basically something like this:

      if (err.code !== 'ENOTFOUND' && err.code !== 'ERR_DNSLINK_NOT_FOUND' && err.code !== 'ENODATA') throw err

Would fix the problem.

What do you think?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant