-
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
chore: move go-nat to internal package #3154
base: master
Are you sure you want to change the base?
Conversation
Port mapping update
Bumps [github.com/jackpal/gateway](https://github.com/jackpal/gateway) from 1.0.4 to 1.0.5. - [Release notes](https://github.com/jackpal/gateway/releases) - [Commits](jackpal/gateway@v1.0.4...v1.0.5) Signed-off-by: dependabot[bot] <[email protected]>
…l/gateway-1.0.5 Bump github.com/jackpal/gateway from 1.0.4 to 1.0.5
add gomod support // tag v0.0.1.
Added method to generically discover IG Devices
This change makes it possible to configure all discovered NATs, not just the first one found.
Merge/upstream
Multi nat
* chore: add or force update .github/workflows/go-test.yml * chore: add or force update .github/workflows/go-check.yml * chore: add or force update .github/workflows/releaser.yml * chore: add or force update .github/workflows/release-check.yml * chore: add or force update .github/workflows/tagpush.yml
* chore: bump go.mod to Go 1.21 and run go fix * chore: run go mod tidy
* chore: add or force update .github/workflows/go-test.yml * chore: add or force update .github/workflows/go-check.yml * chore: add or force update .github/workflows/releaser.yml * chore: add or force update .github/workflows/release-check.yml * chore: add or force update .github/workflows/tagpush.yml * chore: add or force update .github/workflows/go-test.yml * chore: add or force update .github/workflows/go-check.yml * chore: add or force update .github/workflows/releaser.yml * chore: add or force update .github/workflows/release-check.yml * chore: add or force update .github/workflows/tagpush.yml * chore: add or force update .github/workflows/go-test.yml * chore: add or force update .github/workflows/go-check.yml * chore: add or force update .github/workflows/releaser.yml * chore: add or force update .github/workflows/release-check.yml * chore: add or force update .github/workflows/tagpush.yml
For reviewing, only the last commit is likely useful. |
p2p/net/nat/internal/nat/upnp.go
Outdated
var gw ssdp.Service | ||
for _, Service := range DeviceList { | ||
if strings.Contains(Service.Type, "InternetGatewayDevice") { | ||
gw = Service |
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.
Shouldn't we do this on all services that match this string?
Please don't do this. It's totally ok to refuse PRs to reduce the maintenance burden (as you've been doing with zeroconf), and you can call this out in the README. But code should only be moved if the code logically belongs somewhere else. This clearly is not the case for go-nat. |
Are you using this library? |
A fair complaint would be that this makes it much harder for other folks to use As an alternative, folks looking for a higher level NAT package could make use of go-libp2p's nat package directly Given that we have a supported high level API with |
26be225
to
f8bd11c
Compare
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.
@MarcoPolo I reviewed f8bd11c. Is there anything else you wanted me to look at (e.g. the git merging things)?
return | ||
} | ||
|
||
func serviceVisitor(ctx context.Context, rootDevice *goupnp.RootDevice, outNats *[]NAT, outErrs *[]error) func(srv *goupnp.Service) { |
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.
We need a comment somewhere (e.g. on this function or the top level caller of all the upnp discovery mechanisms) describing why we'll handle whatever service type gets sent to us even if we searched for a totally different one (e.g. searching for IG1 and getting IP2 which comes from IG2). This will help us later if there's a problem.
Note: do we want / need this behavior anymore now that we're doing the sequential lookups to deal with badly implemented routers (e.g. fritzbox)?
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.
This will now collect an error if it sees a v2 service on a v1 device.
That should be it. I'll merge this a merge commit so the history should be preserved. |
Regarding whether we should bring this functionality into the monorepo I'm +1 with @MarcoPolo's assessment.
FWIW if the above were not true (particularly, if the library was going to be used by others independent of go-libp2p and the Go module pruning was insufficient) I'd understand wanting to keep the repo separate. Additionally, this is not an uncommon thing to do. Other projects like Syncthing (https://github.com/syncthing/syncthing/tree/124673f7a89b73e7389dc664ce46441b41b7012b/lib/upnp) and Tailscale (https://github.com/tailscale/tailscale/tree/08dd4994d09cf4b960663321136b4fde3f5ccb18/net/portmapper) seem to take the same approach with bundling their portmapping code into their codebases (albeit they're less library focused than go-libp2p is). If in the future say a group like Syncthing wanted to collaborate on / share a portmapping module and it made sense to do so in a separate repo that'd seem very reasonable to me. |
I believe we are the main users of this library, and we don't have enough bandwidth to maintain this for other use cases besides our own.
This PR brings in the commit history from the go-nat repo, and does some refactoring to clean up the code and surface errors to help debug issues.
After merging this, I'll archive the old repo.
Before merge: