libp2p / libp2p/js-libp2p

Use `localPort` option during TCP connect

Open
#2,620 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/enhancement
Dominant language
TypeScript
Stars
2.6k
Forks
546
Avg merge
8h 18m
Merged PRs (30d)
16

Description

For autoNAT to work correctly, we should use the `localPort` option in [socket.connect](https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) to ensure we use a predictable port. Otherwise we end up using ephemeral ports and each autoNAT interaction tries to confirm a different port number.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the TCP connection entry point that calls socket.connect and review how the autoNAT interaction chooses its port. Use the Node.js socket.connect options documentation linked in the issue to determine how localPort should be passed. Done means autoNAT interactions use a predictable local port instead of a new ephemeral port each time.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.