Hole Punching Protocol#711
Conversation
| github.com/libp2p/go-libp2p-blankhost v0.1.3 | ||
| github.com/libp2p/go-libp2p-circuit v0.1.1 | ||
| github.com/libp2p/go-libp2p-core v0.2.2 | ||
| github.com/libp2p/go-libp2p-core v0.2.3-0.20190826112323-405451631c05 |
There was a problem hiding this comment.
just noting for when we need to propagate releases
fde49e1 to
d06bee2
Compare
|
Ping @marten-seemann @Stebalien for review. |
|
ping @vyzo for review . |
| // attempts to make a direct connection with the remote peer of `relayConn` by co-ordinating a hole punch over | ||
| // the given relay connection `relayConn`. | ||
| func (hs *HolePunchService) holePunch(relayConn network.Conn) { | ||
| rp := relayConn.RemotePeer() |
There was a problem hiding this comment.
Same concern as https://github.com/libp2p/go-libp2p/pull/711/files#r561681671.
|
@aarshkshah1992 Hello! I'm looking forward to this PR being merged, as we are facing a lot of troubles with multiplexing with TCP transport. BTW, I've just run the bidirectional connections test from this issue: libp2p/go-libp2p-noise#70, and it fails: on the 4th-8th iteration |
|
@requilence That definitely sounds like a bug. I'll take a look ! |
|
@requilence There was a race in that test wherein a peer could check for peers it is connected to after that connection has been closed by the remote peer depending on when it hit that code path. I've fixed the test and you can follow this issue at #1041. Once this PR is merge, we can release simopen. |
|
@aarshkshah1992 can I clarify? Do both of them share the same connection? For each node, it seems that the connection has been initiated on their side and can be safely closed when the operation on their side is finished. Here is an example
|
dbd9c5e to
749086f
Compare
vyzo
left a comment
There was a problem hiding this comment.
this is looking pretty good, a few comments.
Note: I can't green tick this one, as I originally opened the pr.
| if cfg.EnableHolePunching && !cfg.Relay { | ||
| return nil, errors.New("cannot enable hole punching; relay is not enabled") | ||
| } |
There was a problem hiding this comment.
this will need to use the v2 relay instead of the legacy relay.
| const ( | ||
| protocol = "/libp2p/holepunch/1.0.0" | ||
| maxMsgSize = 4 * 1024 // 4K | ||
| holePunchTimeout = 2 * time.Minute |
There was a problem hiding this comment.
this may exceed the limited relay timeout... maybe we need to increase the default for the latter?
|
|
||
| // short-circuit hole punching if a direct dial works. | ||
| // attempt a direct connection ONLY if we have a public address for the remote peer | ||
| for _, a := range hs.host.Peerstore().Addrs(rp) { |
There was a problem hiding this comment.
this kind of assumes that identify has completed for the peer, which may not be the case here.
| } | ||
|
|
||
| // hole punch | ||
| s, err := hs.host.NewStream(hs.ctx, rp, protocol) |
| if msg.GetType() != holepunch_pb.HolePunch_CONNECT { | ||
| s.Reset() | ||
| return |
There was a problem hiding this comment.
let's log this, probably Debug.
| // We plan to have a better address discovery and advertisement mechanism in the future. | ||
| // See https://github.com/libp2p/go-libp2p-autonat/pull/98 | ||
| repeated bytes ObsAddrs = 2; | ||
| } No newline at end of file |
|
Note that this is getting quite messy in terms of commit history, we might have to squash it. |
|
We will want to integrate the circuit v2 pr here and change the libp2p constructor to use the new beast instead of the legacy one. |
|
Closed in favour of #1057. |
For #1039.
Implements the Hole Punching co-ordination protocol and upgrades dependencies to solve multi-stream simultaneous connect.
TODO