Hole-punching is not possible during reconnection.
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.9k
- Forks
- 1.3k
- Avg merge
- 13d 21h
- Merged PRs (30d)
- 1
Description
Under the condition that `A [connect to B] ----> [inbound] B` peer exists,
Hole punching will not occur if A-peer is restarted.
Because,
- https://github.com/libp2p/go-libp2p/blob/7b78dd6802d137e499ec1196705bee7dc50b93e2/p2p/protocol/holepunch/holepuncher.go#L279 is called, but
- For UDP or unintended disconnection is not detected immediately, https://github.com/libp2p/go-libp2p/blob/7b78dd6802d137e499ec1196705bee7dc50b93e2/p2p/protocol/holepunch/holepuncher.go#L111 incorrectly assumes that a connection already exists.
```
2025-10-30T23:02:34.648+0900 [35mDEBUG[0m p2p-holepunch holepunch/holepuncher.go:95 beginDirectConnect {"host": "12D3KooWLcU8rxuwQphJq7DJGRwPx6qdFY8Aj6thpdjXyTcshEe6", "peer": "12D3KooWBAm5U5jMMeasz15KnP7Tg4fn2Qd68WAc7YzJoSosfPmt"}
2025-10-30T23:02:34.648+0900 [35mDEBUG[0m p2p-holepunch holepunch/holepuncher.go:112 already connected {"host": "12D3KooWLcU8rxuwQphJq7DJGRwPx6qdFY8Aj6thpdjXyTcshEe6", "peer": "12D3KooWBAm5U5jMMeasz15KnP7Tg4fn2Qd68WAc7YzJoSosfPmt"}
```
Version Information
github.com/libp2p/go-buffer-pool v0.1.0
github.com/libp2p/go-cidranger v1.1.0
github.com/libp2p/go-doh-resolver v0.5.0
github.com/libp2p/go-flow-metrics v0.3.0
github.com/libp2p/go-libp2p v0.43.0
github.com/libp2p/go-libp2p-asn-util v0.4.1
github.com/libp2p/go-libp2p-kad-dht v0.34.0
github.com/libp2p/go-libp2p-kbucket v0.7.0
github.com/libp2p/go-libp2p-record v0.3.1
github.com/libp2p/go-libp2p-routing-helpers v0.7.5
github.com/libp2p/go-libp2p-testing v0.12.0
github.com/libp2p/go-libp2p-xor v0.1.0
github.com/libp2p/go-msgio v0.3.0
github.com/libp2p/go-netroute v0.2.2
github.com/libp2p/go-reuseport v0.4.0
github.com/libp2p/go-yamux/v5 v5.0.1
github.com/libp2p/zeroconf/v2 v2.2.0
Contributor guide
No contributing guide indexed for this repository
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 by reading p2p/protocol/holepunch/holepuncher.go at the referenced lines 111 and 279, then trace how reconnection and unintended UDP disconnection are detected. Reproduce the A-to-B restart scenario and inspect the hole-punching logs. Done means hole punching is attempted after A restarts instead of being reported as already connected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100