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

/api/v0/dns/ fails with "not a valid domain name" error on IPNS DNSLinks #6454

Closed
Gozala opened this issue Jun 15, 2019 · 11 comments
Closed
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P1 High: Likely tackled by core team if no one steps up status/ready Ready to be worked topic/api Topic api topic/rpc-api Issues related to Kubo RPC API at /api/v0

Comments

@Gozala
Copy link

Gozala commented Jun 15, 2019

Version information:

go-ipfs version: 0.4.18-
Repo version: 7
System version: amd64/darwin
Golang version: go1.11.1

Description:

/api/v0/dns API endpoint no longer seems to work for DNSLinks that have ipns values e.g:

dig +noall +answer TXT _dnslink.ipns.gozala.io                                                                                             
_dnslink.ipns.gozala.io. 3600   IN      TXT     "dnslink=/ipns/QmYhQG9JXYeBF6pL7yafFJfEYcKPp9N8n4aRmYZzU6z47u/"

calling following API call seems to fail:

curl http://localhost:5001/api/v0/dns\?arg\=dweb.gozala.io -v                                                                              ✗ ✭
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 5001 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 5001 (#0)
> GET /api/v0/dns?arg=dweb.gozala.io HTTP/1.1
> Host: localhost:5001
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 500 Internal Server Error
< Access-Control-Allow-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
< Access-Control-Expose-Headers: X-Stream-Output, X-Chunked-Output, X-Content-Length
< Content-Type: application/json
< Server: go-ipfs/0.4.21
< Trailer: X-Stream-Error
< Vary: Origin
< Date: Sat, 15 Jun 2019 23:33:54 GMT
< Transfer-Encoding: chunked
< 
{"Message":"not a valid domain name","Code":0,"Type":"error"}
* Connection #0 to host localhost left intact

Public gateway seems to also suffer from the same issue:

url https://ipfs.io/api/v0/dns\?arg\=ipns.gozala.io -v                                                                                    ✗ ✭
*   Trying 209.94.90.1...
* TCP_NODELAY set
* Connected to ipfs.io (209.94.90.1) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=ipfs.io
*  start date: May  7 21:37:01 2019 GMT
*  expire date: Aug  5 21:37:01 2019 GMT
*  subjectAltName: host "ipfs.io" matched cert's "ipfs.io"
*  issuer: C=US; O=Let's Encrypt; CN=Let's Encrypt Authority X3
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f87aa805200)
> GET /api/v0/dns?arg=ipns.gozala.io HTTP/2
> Host: ipfs.io
> User-Agent: curl/7.54.0
> Accept: */*
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 500 
< server: nginx
< date: Sat, 15 Jun 2019 23:36:57 GMT
< content-type: application/json
< trailer: X-Stream-Error
< vary: Origin
< access-control-allow-origin: *
< access-control-allow-methods: GET, POST, OPTIONS
< access-control-allow-headers: X-Requested-With, Range, Content-Range, X-Chunked-Output, X-Stream-Output
< access-control-expose-headers: Content-Range, X-Chunked-Output, X-Stream-Output
< x-ipfs-pop: gateway-bank3-sjc1
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< 
{"Message":"not a valid domain name","Code":0,"Type":"error"}
* Connection #0 to host ipfs.io left intact
@eingenito
Copy link
Contributor

Hey @Gozala, thanks for the report. Is this a recent change? Do you know of an IPFS version where this last worked?

@Gozala
Copy link
Author

Gozala commented Jun 20, 2019

@eingenito Sadly I don't know exactly when this has changed, but it definitely used to work in the past. The project that used it has last commit on Feb 22, 2019 & I'm inclined to believe that it worked around then.

I also have being using it through IPFS Desktop so I'd say it regressed somewhere between 0.7.0-rc and 0.8.

I hope this helps to narrow it down somewhat.

@Stebalien Stebalien added the kind/bug A bug in existing code (including security flaws) label Jun 27, 2019
@Stebalien
Copy link
Member

This should resolve to /ipns/Qm... I'm not sure if this ever worked.

Note: If you actually want to resolve it, you can use ipfs resolve.

@RubenKelevra
Copy link
Contributor

I can confirm this bug, it works fine if the dnslink is /ipfs but does not work if it's /ipns.

@Stebalien
Copy link
Member

You're correct, this has not been fixed. If you want to resolve a path, I recommend using ipfs resolve ....

Ideally, ipfs dns ... would resolve all DNSLink names until the first non-DNSLink. If you want to take a stab at this, the issue is in namesys/base.go.

@RubenKelevra
Copy link
Contributor

Ideally, ipfs dns ... would resolve all DNSLink names until the first non-DNSLink. If you want to take a stab at this, the issue is in namesys/base.go.

I would really enjoy to so this, but I know nothing about Go.

I don't think I'm the right one to do this. 😕

@Stebalien
Copy link
Member

Up to you. Contributing to OSS projects is one of the best ways to learn a language (https://tour.golang.org/welcome/1).

@DougAnderson444
Copy link

The thing is, js-ipfs relies on this to resolve the dns
ipfs/helia-ipns#53
so until this is fixed, it break js-ipfs for resolving /ipns/QmHashes too...

@lidel
Copy link
Member

lidel commented Dec 4, 2020

For the record, this is still broken in v0.7.0:

$ dig +noall +answer TXT _dnslink.seanbehan.dev
_dnslink.seanbehan.dev.	300	IN	TXT	"dnslink=/ipns/k51qzi5uqu5djnx8xr1du720eheh7fmkehu5ltzkr0ksvvd43v6zfhez9y7o70"

$ ipfs dns -r seanbehan.dev
Error: not a valid domain name

Not only it does not work, it also produces invalid error message (domain is valid).

I created standalone test case in case someone wants to pick this up:

Given DNS TXT record at _dnslink.ipns-path-in-dnslink-record.aergia.eu:

dnslink=/ipns/k51qzi5uqu5dgutdk6i1ynyzgkqngpha5xpgia3a5qqp4jsh0u4csozksxel2r

Compare:

@RubenKelevra
Copy link
Contributor

I've added a PR that at least shows the domain name where it fails:

#7886

@lidel lidel added P1 High: Likely tackled by core team if no one steps up topic/api Topic api topic/rpc-api Issues related to Kubo RPC API at /api/v0 status/ready Ready to be worked exp/novice Someone with a little familiarity can pick up and removed need/triage Needs initial labeling and prioritization labels Apr 7, 2021
@lidel
Copy link
Member

lidel commented Dec 12, 2023

/api/v0/dns will be removed in Kubo 0.26, use /api/v0/resolve instead.
Details in #10253

@lidel lidel closed this as not planned Won't fix, can't repro, duplicate, stale Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exp/novice Someone with a little familiarity can pick up kind/bug A bug in existing code (including security flaws) P1 High: Likely tackled by core team if no one steps up status/ready Ready to be worked topic/api Topic api topic/rpc-api Issues related to Kubo RPC API at /api/v0
Projects
None yet
Development

No branches or pull requests

6 participants