Skip to content

TCP transport: bind to the same port for outgoing connections #1563

@BlackYoup

Description

@BlackYoup

Hello,

I have a simple use case where I want two peers behind different NAT to communicate. For that, I went with TCP Hole Punching with a signalization server telling both peers to initiate a communication with the other on IP X and port Y. I also added the Identify protocol to my swarm's behaviour so every peer would configure itself to know their observed address.

But if I understood the whole TCP Hole Punching concept, each peer have to bind to the same port (Y) they used to communicate with the signalization server for incoming connections and also bind to that same port when doing the ongoing connection to the other peer.

I copied the TCP transport provided by libp2p and modified it to have this behaviour and so my peers are able to connect to each other using TCP Hole Punching, as expected. But now, I wish I wouldn't have to use my "own" TCP transport with such little modifications.

I've seen a few NAT traversal discussions in the issues but nothing about binding to the same port for outgoing connections. Would it be possible to have this in rust-libp2p directly? Or maybe I'm missing something somewhere to allow me to do this already?

Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions