rust-libp2p icon indicating copy to clipboard operation
rust-libp2p copied to clipboard

fix(websocket): don't dial `/dnsaddr` addresses

Open hmzdot opened this issue 1 year ago • 5 comments

Description

Returns Error::InvalidMultiaddr when parse_ws_dial_addr is called with /dnsaddr.

As per its specification, /dnsaddr domains are not meant to be directly dialed, instead it should be appended with _dnsaddr. and used for DNS lookups afterwards

Related: #5529 Fixes: #5601

Notes & open questions

  • Is it okay to return an error, or should I perform a DNS lookup and resolve that DNS afterwards if address has /dnsaddr?
  • If so, how should I handle that case where DNS lookup returns multiple multiaddrs?

Change checklist

  • [x] I have performed a self-review of my own code
  • [ ] I have made corresponding changes to the documentation
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] A changelog entry has been made in the appropriate crates

hmzdot avatar Sep 27 '24 08:09 hmzdot

websocket-websys needs this change too.

oblique avatar Oct 02 '24 09:10 oblique

bsys needs this change too.

I see, will update there as well

hmzdot avatar Oct 03 '24 13:10 hmzdot

Hello

I just opened https://github.com/libp2p/rust-libp2p/issues/5619 because I want to dial /dnsaddr from webrtc-websys. Then I noticed this issue.

Would it make sense to simply support DNS multiaddr resolution in the browser?

DougAnderson444 avatar Oct 03 '24 16:10 DougAnderson444

Also https://github.com/libp2p/rust-libp2p/issues/5531 could enable this?

DougAnderson444 avatar Oct 03 '24 16:10 DougAnderson444

@DougAnderson444 As described in #5601, this PR removes an incorrect handling of /dnsaddr. #5531 is the only way forward which needs to implement resolution of only /dnsaddr multiaddresses through a new Transport that targets only browsers.

oblique avatar Oct 04 '24 07:10 oblique

Updated websocket-websys (bf23e92b6ccd60ebe65d08d2436dee62d80946ba) so that it returns None when a /dnsaddr is extracted. This should be enough to fix incorrect handling of /dnsaddr and to resolve them correctly we can continue from #5531

cc: @dariusc93

hmzdot avatar Oct 25 '24 15:10 hmzdot

Previous CI runs failed because I didn't update top-level versions, my bad. Can you restart the workflow? @oblique

hmzdot avatar Nov 01 '24 13:11 hmzdot

cc @jxs

oblique avatar Nov 01 '24 18:11 oblique