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

autonat and upnp-nat both detect external IP address, but neither updates announced addresses. #2454

Open
MichaelJCole opened this issue Mar 27, 2024 · 1 comment
Labels
need/triage Needs initial labeling and prioritization

Comments

@MichaelJCole
Copy link
Contributor

MichaelJCole commented Mar 27, 2024

  • Version:
    ├── @libp2p/autonat@1.0.13
    ├── @libp2p/upnp-nat@1.0.14
    ├── libp2p@1.3.0

  • Platform:
    linux

  • Subsystem:
    addressManager, AutoNAT, and UPNP.

Severity:

Considering js-libp2p as the transport layer for a peer-to-peer app running on a personal computer, and how users expect to configure p2p apps like bittorrent.

High - The main functionality of the application does not work, API breakage, repo format breakage, etc.
Medium - A non-essential functionality does not work, performance issues, etc.

Description:

Most peer-to-peer apps are run on personal computers instead of servers. Consider Bittorrent clients like qbittorrent, utorrent, vuze, etc.
These allow users to change the address, port, and upnp settings while the application is running.

Both autonat and upnp-nat detect a nodes public ip, but neither update the announce addresses in addressManager or candidates used by autonat.

This means an application using js-libp2p must detect these through other means or manage a restart of libp2p.

autonat detects them from peers and updates addressManager's observedAddrs, but it doesn't appear to update the candidates with the new IP address.

upnp-nat gets client.externaIp() and updates observed addrs but my client's libp2p.getMultiaddrs() never update.

Maybe I'm missing something but I don't see a way to use this information to reconfigure the js-libp2p other than to:

  1. start it with a known incomplete config
  2. add a timer to let these async processes complete (60s timeout for upnp-nat)
  3. interrogate the libp2p client using undeclared interfaces to get addressManager
  4. stop the client and reconfigure listen addresses and restart.

The statically configured listen addresses are already templates 0.0.0.0 and port 0 are replaced with local interfaces. It would be great if libp2p could do this with announce addresses as well.

What I'd like is to configure libp2p with these options:

services: {
  autoNAT: autoNAT({ autoAnnounce true }),
  upnp: uPnPNAT({ autoAnnounce true })
}

When autoNAT observes an externalIP, it calls addressManager.autoAnnounce(ip).
addressManager iterates transports to create addresses. These are then verified by autoNAT.

When uPnPNAT observes an externalIP/port it calls addressManager.autoAnnounce(ip, port)
addressManager iterates transports to create addresses. These are then verified by autoNAT.

If addressManager remembers it's announced IP's, it could also do a port change with addressManager.autoAnnounce(undefined, port)

This would be a large change and may or may not be wanted.

Steps to reproduce the error:

Look at how other peer-to-peer applications configure their networking

https://vpn.ac/images/tutorials/socks5/qbittorrent1.png
https://www.bolehvpn.net/images/utorrent1.jpg
https://imgur.com/MQ4zkcA

@MichaelJCole MichaelJCole added the need/triage Needs initial labeling and prioritization label Mar 27, 2024
@MichaelJCole MichaelJCole changed the title autonat and upnp-nat both detect external IP address, but neither updates candidates. libp2p addresses are statically declared requiring a restart and restart management. autonat and upnp-nat both detect external IP address, but neither updates announced addresses. Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need/triage Needs initial labeling and prioritization
Projects
None yet
Development

No branches or pull requests

1 participant