waku-org / js-waku

JavaScript implementation of Waku v2
https://js.waku.org
Apache License 2.0
168 stars 42 forks source link

bug: cannot use multiaddr with 127.0.0.1 to dial #1974

Open weboko opened 6 months ago

weboko commented 6 months ago
This is a **bug report/feature request/support request/change request** ## Problem If `/dns4/127.0.0.1/tcp/8000/ws/p2p/16Uiu2HAkxcq84cB1gD1MH5XDQNm1vakvUzwoEhmLFtywF7YF3Hvm` is used to dial - then error is thrown from `websocket` transport [here](https://github.com/libp2p/js-libp2p/blob/17e2d64e05ef4555cae304f0fbcc546d5446e0c0/packages/transport-websockets/src/index.ts#L127) Works just fine if ``/dns4/localhost/tcp/8000/ws/p2p/16Uiu2HAkxcq84cB1gD1MH5XDQNm1vakvUzwoEhmLFtywF7YF3Hvm` is used. ## Proposed Solutions Since `nwaku` generates multiaddr with `IP` in it - we should be able to dial it without error. Most straightforward solution can be to check for `127.0.0.1` and replace with `localhost`. But we also need to check why this throw actually happens as there might be unintended consequences.