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

move NAT mapping logic out of the host, add tests for NAT handling #2248

Merged
merged 8 commits into from Apr 28, 2023

Conversation

marten-seemann
Copy link
Contributor

@marten-seemann marten-seemann commented Apr 8, 2023

In preparation for #2229.

There's a few packages involved in NAT handling here:

  1. go-nat: Wraps UPnP and PMP libraries and provides functions to add, query and remove NAT mappings.
  2. p2p/net/nat: Uses go-nat periodically renew NAT mappings and query for IP address changes.
  3. p2p/host/basic/natmgr.go: Listens for Listen / ListenClose notifications from the swarm and tries to obtain NAT mappings for our listen addresses. Provides a GetMapping(ma.Multiaddr) ma.Multiaddr method that applies NAT mappings to existing multiaddresses.

Copy link
Contributor

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

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

Couple comments, but looks good. Thanks for the tests!

continue
}

var (
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏 . Thanks for getting rid of this

p2p/net/nat/nat.go Show resolved Hide resolved
p2p/net/nat/nat.go Outdated Show resolved Hide resolved
p2p/host/basic/mockgen_private.sh Outdated Show resolved Hide resolved
p2p/host/basic/mockgen_private.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@MarcoPolo MarcoPolo left a comment

Choose a reason for hiding this comment

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

Thanks for getting rid of the bash script :)

@marten-seemann marten-seemann merged commit 410248e into master Apr 28, 2023
20 checks passed
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.

None yet

2 participants