TCP transport: configurable bind address for outgoing connections
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.6k
- Forks
- 1.3k
- Avg merge
- 8h 47m
- Merged PRs (30d)
- 19
Description
Description
I want to be able to configure the bound address of outgoing tcp connections - eg 127.0.0.2:0. Currently, the only supported binding is related to port reuse.
Motivation
In a local test I've created, I'm trying to shape traffic by IP ranges. There currently isn't a way to configure the outbound IPs used for dialing in the default libp2p tcp transport.
A concrete example:
- 2 libp2p swarms - one listening on
127.0.0.1:5000and one listening on127.0.0.2:5000
Desired behavior:
- All outbound connections from the former to be from (configurable)
127.0.0.1:0, and all outbound connections from the latter to be from (configurable)127.0.0.2:0.
Requirements
Add a config option here for a configurable outbound bind address.
Open questions
Are you planning to do it yourself in a pull request?
Yes
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in transports/tcp/src/lib.rs, especially the configuration area linked in the issue, and read the socket2 bind documentation for the expected address behavior. Trace how outgoing TCP connections are created and verify the configurable bind address is used for dialing. Done means callers can select an outbound address such as 127.0.0.1:0 while preserving existing port-reuse behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100