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

NAT Flow #200

Closed
dryajov opened this issue May 31, 2018 · 3 comments
Closed

NAT Flow #200

dryajov opened this issue May 31, 2018 · 3 comments
Labels
status/ready Ready to be worked

Comments

@dryajov
Copy link
Member

dryajov commented May 31, 2018

Here is an outline of the overall plan for NAT traversal. This implies both port mapping/punching as well as using other techniques such as circuit relaying and dialme flows:

  • Have a nat module to take care of all things NAT
  • Circuit relays work like TURN servers
    • circuit relays and NAT port mapping/punching provides pretty good connectivity for peers
    • relaying traffic can be slow, plus it will be demanding for the relay peers
  • The upcoming dialme protocol can be used to upgrade relayed connections to direct ones when possible, thus increasing the chances of direct connections and alleviating load on the relay nodes

Here is the overall flow I'm thinking about

Booting libp2p

assuming nat manager and circuit dialing are both enabled

  • On boot
    • detect the current network topology
      • if we have a public ip do nothing and ignore NAT altogether
      • if we've detected NAT then proceed to set up NAT traversal
        • try to set up a port mapping for each of the (applicable) swarm addrs
        • announce the public addresses (along side the private ones?)

Dialing Peers

(assuming we have NATed ports and circuit is enabled)

  • Dialing a peer
    • Peer A dials to Peer B over circuit (because B is behind a NAT or its a browser, etc...)
      • on success, see if Peer A has a public address or NAT port mappings setup
        • if either are true
          • use the dialme protocol to ask the other end (Peer B) to dial us on our public address
            • if success, drop the circuit connection and use the newly acquired direct connection
            • if failure, continue using the circuited connection
        • if neither are true
          • continue using the circuited connection
@dryajov dryajov mentioned this issue May 31, 2018
@daviddias daviddias added the status/ready Ready to be worked label Jun 4, 2018
@sequoiar
Copy link

+1 traverse FW/NAT

@VishalWaman
Copy link

+1

@achingbrain
Copy link
Member

Closing due to staleness. The current approach is to use a combination of uPNP NAT traversal, if available, and if not to use autonat + socket timing - see https://blog.ipfs.tech/2022-01-20-libp2p-hole-punching/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

5 participants