Skip to content
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

better nat mapping #549

Merged
merged 6 commits into from
Mar 6, 2019
Merged

better nat mapping #549

merged 6 commits into from
Mar 6, 2019

Conversation

Stebalien
Copy link
Member

  1. Update to work with remove all uses of multiaddrs go-libp2p-nat#14.
  2. Avoid observed addrs when our NAT tells us about external addrs.
  3. Ignore bad addrs reported by our NAT. Substitute with observed addrs.
  4. Fix Handle /quic and /ws in NAT mappings #428.

(really, I'm just trying to get NAT port mapping working on my network...)

@ghost ghost assigned Stebalien Mar 6, 2019
@ghost ghost added the status/in-progress In progress label Mar 6, 2019
@Stebalien Stebalien added the status/blocked Unable to be worked further until needs are met label Mar 6, 2019
@Stebalien
Copy link
Member Author

This PR has some pretty nasty functions and could use some multiaddr helpers.

Copy link
Contributor

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks ok at first glance.

@Stebalien Stebalien force-pushed the feat/better-natmapping branch 2 times, most recently from 90576ba to a82f420 Compare March 6, 2019 16:29
@Stebalien Stebalien removed the status/blocked Unable to be worked further until needs are met label Mar 6, 2019
1. Update to work with libp2p/go-libp2p-nat#14.
2. Avoid observed addrs when our NAT tells us about external addrs.
3. Ignore bad addrs reported by our NAT. Substitute with observed addrs.
4. Fix #428.
These were exceeding their tolerances when run under the race detector on CI.
Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clean and readable! Minor doubts.

// Only bother if we're listening on a
// unicast/unspecified IP.
ip := net.IP(maIP.RawValue())
if !(ip.IsGlobalUnicast() || ip.IsUnspecified()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm. This doesn't continue if the listen address is public (i.e. we don't need a port mapping). That's because we're presuming in that case there's no NAT device at all, and hence this func would return at line 124? What would happen if the host is listening on multiple network interfaces, of which one is public and one is private (behind a NAT)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... this actually works for more than NATs. It also applies to situations where nodes have public IP addresses but are behind firewalls (I think?).

However, we could check ip.IsUnspecified() || ip.Equals(IP_ON_NAT). However, I'll need to make go-libp2p-nat expose IP_ON_NAT first. I'll mess with that in a followup patch.

}(proto, port)
}
}
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not relevant to the changes in this PR, but shouldn't we be triggering an "identify push" here if there were changes (maybe not exactly here, but when the mappings are done)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably (#553). However, we also need to push when:

  1. Our observed addresses change significantly.
  2. Our interface addresses change.

etc...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventbus 🚌🚌🚌

@Stebalien Stebalien merged commit abe3981 into master Mar 6, 2019
@ghost ghost removed the status/in-progress In progress label Mar 6, 2019
@Stebalien Stebalien deleted the feat/better-natmapping branch March 12, 2019 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants