Commit 925dc62
Merge pull request #4873 from driftluo:hole-puching-protocol
feat: add a hole punching protocol try use on nat traversal
closes #4824 #4766
This PR introduces a protocol to coordinate node connection behavior, attempting to perform TCP traversal through coordination:
1. Removed the `try dial observe address` behavior.
2. The protocol currently does not support the wasm target and does not support establishing WebSocket protocol connections.
3. The protocol has only three messages, with the following behavior:
1. Schedule finding peer IDs from the peer store that want to establish a connection and broadcasting their possible listening addresses.
2. The node receives a Request message and determines if the target object is itself.
1. If the `to` object is itself, it returns a Delivered message.
2. If the `to` object is not itself, it broadcasts the route and ttl modified.
3. The node receives a Delivered message response.
1. If the `from` object is itself, it starts a TCP connection request and responds with a Sync message
2. If the `from` object is not itself, it modifies the route and ttl and propagates the message to the next router object.
4. The node receives a Sync message response.
1. If the `to` object is itself, it starts a TCP connection request.
2. If the `to` object is not itself, it propagates the message to the next router object.
```mermaid
sequenceDiagram
participant A as Initiator Node A
participant B as Relay Node B
participant C as Target Node C
autonumber
A->>B: ConnectionRequest
B->>C: Forward(ConnectionRequest)
activate C
C-->>C: Validate Target
C->>B: ConnectionRequestDelivered (incl. Observed Addr)
deactivate C
B->>A: Forward(ConnectionRequestDelivered)
activate A
A-->>A: Process Reply (Store Observed Addr)
Note right of A: Delay start early NAT<br/>traversal attempt here (ttl/2)
A->>B: ConnectionSync
deactivate A
B->>C: Forward(ConnectionSync)
par Start NAT Traversal & Direct Connection Attempt
activate A
A-->>A: Start NAT Traversal
A-->>C: Direct Connection Attempt (e.g., TCP Hole Punching)
deactivate A
and
activate C
C-->>C: Start NAT Traversal
C-->>A: Direct Connection Attempt (e.g., TCP Hole Punching)
deactivate C
end
```
Co-Authored-By: driftluo <[email protected]>1 parent a26ca43 commit 925dc62
File tree
28 files changed
+3354
-170
lines changed- network
- src
- peer_store
- protocols
- hole_punching
- component
- identify
- services
- resource
- script/src
- verify/tests
- ckb_latest
- sync/src/relayer
- tx-pool/src
- component
- tests
- util
- app-config/src/configs
- gen-types
- schemas
- src/generated
28 files changed
+3354
-170
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
204 | | - | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
217 | 221 | | |
218 | 222 | | |
219 | 223 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 52 | + | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
| |||
0 commit comments