diff options
| author | tv <tv@krebsco.de> | 2026-11-22 16:30:45 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-22 16:30:45 +0000 |
| commit | 37940e51a0113c744042390a5226bda78fc1ab0d (patch) | |
| tree | c1e6d512f9459ace51738257c1889445da7e1fa0 /src | |
| parent | 1063c8ef8da08f76bdc75823a4c16924b55b0e8e (diff) | |
libp2p: dial a relayed peer directly even while another dial is under way
upgrade dialled with PeerCondition::NotDialing: while hole punching's
dial went, the direct one didn't, and came only once that dial failed,
which where packets are dropped is when it times out. Hole punching
dials the address the relay saw, which may not answer where the peer's
listen addresses do (a host with several, a port mapped otherwise).
a_relayed_connection_is_upgraded_where_one_side_can_be_dialled hit
that now and then: identify told b where a listens 1 ms after dcutr's
dial began, and b didn't dial a within the test's 5 s.
Now it dials regardless. Where both dials connect, the slower is closed
after DUPLICATE_GRACE, as of any two. The retry on a failed dial goes:
nothing waits on another dial any more; the next try comes as before
(identify, mDNS, a send to the peer), UPGRADE_RETRY after the last.
Diffstat (limited to 'src')
| -rw-r--r-- | src/transport/libp2p/driver.rs | 4 | ||||
| -rw-r--r-- | src/transport/libp2p/relays.rs | 8 |
2 files changed, 4 insertions, 8 deletions
diff --git a/src/transport/libp2p/driver.rs b/src/transport/libp2p/driver.rs index 6ef04e7..9f12cea 100644 --- a/src/transport/libp2p/driver.rs +++ b/src/transport/libp2p/driver.rs @@ -297,10 +297,6 @@ pub(super) async fn run( } find_on_dht(&mut swarm, peer); } - // A dial that kept ours from going (`upgrade`) is over. - if let Some(peer) = peer_id { - upgrade(&mut swarm, &book, peer, relaying.local); - } } SwarmEvent::NewListenAddr { address, .. } => { // libp2p listens on every interface it's told to; the ranges left diff --git a/src/transport/libp2p/relays.rs b/src/transport/libp2p/relays.rs index 1a57635..0539ac5 100644 --- a/src/transport/libp2p/relays.rs +++ b/src/transport/libp2p/relays.rs @@ -127,9 +127,9 @@ pub(super) fn pick_relays( /// too (the member list, identify, mDNS), since the first connection, made through a /// relay (a relayed seed), would otherwise be kept for good: a peer connected isn't /// dialled again, and hole punching needs both sides to listen. The direct connection, -/// once open, wins over the relayed one (`Book::duplicates`). A dial refused because -/// another to the peer is under way (hole punching's, say) doesn't count as a try: the -/// next comes when that one fails (`driver`), not `UPGRADE_RETRY` later. +/// once open, wins over the relayed one (`Book::duplicates`). It goes even while another +/// dial to the peer is under way: hole punching's goes to the address the relay saw, which +/// may not answer where these do, until its dial times out. pub(super) fn upgrade( swarm: &mut Swarm<Behaviour>, book: &Mutex<Book>, @@ -160,7 +160,7 @@ pub(super) fn upgrade( let dialled = swarm.dial( DialOpts::peer_id(peer) .addresses(direct.clone()) - .condition(PeerCondition::NotDialing) + .condition(PeerCondition::Always) .build(), ); match dialled { |
