-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[WIP] UDP-based NAT hole-punching #490
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we are planning a refactoring for the host construction that should surface services in a much more reasonable way.
@@ -92,7 +92,9 @@ func (h *AutoRelayHost) background(ctx context.Context) { | |||
|
|||
for { | |||
wait := autonat.AutoNATRefreshInterval | |||
switch h.autonat.Status() { | |||
status := h.autonat.Status() | |||
h.Ids.SetNatStatus(status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's gross -- we should embed AutoNAT in basic_host if identify needs it or pass it a reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this is not just gross, it's also wrong -- identify should poll the NATStatus directly instead of a second-hand delayed version.
quicAddress := make([]string, 0, len(allAddresses)) | ||
for _, a := range allAddresses { | ||
s := a.String() | ||
if strings.Contains(s, "/quic") && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use go-multiaddr-net
, which contains utilities for testing private addresses.
More specifically, look at IsPrivateAddr
.
Please don't duplicate the AutoNAT constants and functionality in identify by second hand. |
Also, it's not clear to me why identify needs to have the NATStatus for this protocol. |
I understand that the info
The NAT status is exchanged by Identify protocol, so we only do punching if both peers are behind NAT gateways. |
That's not the AutoNATService you want -- move the AutoNAT client which lives in the AutoRelayHost. |
allAddresses := p.host.Addrs() | ||
quicAddress := make([]string, 0, len(allAddresses)) | ||
for _, a := range allAddresses { | ||
s := a.String() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should work with the multiaddr representation directly instead of converting to strings.
I think we may want to punt a bit on this, I am going to be working on the service refactoring the next few days. |
Sure. I'd also expect a refactor after changes landed on libp2p. I publish it earlier so maybe more people interested could help test it. |
Is this full duplication with what is being done in #188? Is this closer timeframe? |
No. WebRTC is a standardized protocol that happen also solves NAT traversal problem. This patch is much simpler. For the time being, I'm waiting for the refactoring of libp2p. |
Are you going to merge it into the master? |
Does this support the symmetric to restricted address cone case? |
I'll try my best.
Theoretically it could handle restricted cone, but not symmetric case. |
OBE (Project Flare). |
This patch utilizes relayed connection as signaling channel, and run
/libp2p/punching/1.0.0
protocol on it. If both nodes are behind NAT gateways, they send self-observed QUIC addresses to each other. On receiving such messages, nodes would dial the addresses, hoping to establish connections directly.I think the patch could be deployed and tested now, so I publish it for review. I understand that some major refactors would happen in go-libp2p, so I'm prepared for corresponding refactors. Also as a "WIP", expect nits here and there:)
Part of #433