libp2p / jvm-libp2p

a libp2p implementation for the JVM, written in Kotlin 🔥
https://libp2p.io
Apache License 2.0
277 stars 76 forks source link

NetworkImpl can't handle relayed addresses #339

Open ianopolous opened 1 year ago

ianopolous commented 1 year ago

If you try and dial an address that is relayed, e.g. /ip6/2a03:b0c0:3:d0::f5b:2001/tcp/4001/p2p/12D3KooWAYhKPvH8JrBT7oTiY69LY2QksfvPH2sY8ECvR1KD9ZTo/p2p-circuit/p2p/12D3KooWHci62Skj6sC6c2ASXARBnBMmUuM7kuHqtgi5mVQdJ6Gf

Then you get an error trying to set the peerid, because there are two p2p elements in relayed addresses. We want to append in the p2p-circuit case.

java.lang.IllegalArgumentException: Value (12D3KooWHci62Skj6sC6c2ASXARBnBMmUuM7kuHqtgi5mVQdJ6Gf) for P2P doesn't match existing value in /ip6/2a03:b0c0:3:d0::f5b:2001/tcp/4001/p2p/12D3KooWAYhKPvH8JrBT7oTiY69LY2QksfvPH2sY8ECvR1KD9ZTo/p2p-circuit at io.libp2p.core.multiformats.Multiaddr.withComponentImpl(Multiaddr.kt:68) at io.libp2p.core.multiformats.Multiaddr.withComponent(Multiaddr.kt:78) at io.libp2p.core.multiformats.Multiaddr.withP2P(Multiaddr.kt:57) at io.libp2p.network.NetworkImpl.connect(NetworkImpl.kt:72) at io.libp2p.core.Network.connect(Network.kt:75) at io.libp2p.host.HostImpl.newStream(HostImpl.kt:94) at io.libp2p.core.multistream.ProtocolBinding.dial(ProtocolBinding.kt:37)

Nashatyrev commented 1 year ago

I don't think we support /p2p-circuit at the moment

ianopolous commented 1 year ago

Exactly, I'm implementing circuit relaying at the moment. But The Tcp transport shouldn't say it can dial them because it has ip4 etc..