Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions protocols/autonat/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
`SeedableRng + rand::Rng`.
See [PR 6559](https://github.com/libp2p/rust-libp2p/pull/6559).

- Close v2 server dial-back connections once the client acknowledges the dial-back instead of leaving them open.
See [PR 6528](https://github.com/libp2p/rust-libp2p/pull/6528).

- Fix AutoNAT v2 server preserving the selected address index for multi-address `DialRequest`s.
See [PR 6514](https://github.com/libp2p/rust-libp2p/pull/6514).

Expand Down
21 changes: 15 additions & 6 deletions protocols/autonat/src/v2/server/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use either::Either;
use libp2p_core::{Endpoint, Multiaddr, transport::PortUse};
use libp2p_identity::PeerId;
use libp2p_swarm::{
ConnectionDenied, ConnectionHandler, ConnectionId, DialFailure, FromSwarm, NetworkBehaviour,
ToSwarm,
CloseConnection, ConnectionDenied, ConnectionHandler, ConnectionId, DialFailure, FromSwarm,
NetworkBehaviour, ToSwarm,
dial_opts::{DialOpts, PeerCondition},
dummy,
};
Expand Down Expand Up @@ -102,13 +102,22 @@ where
fn on_connection_handler_event(
&mut self,
peer_id: PeerId,
_connection_id: ConnectionId,
connection_id: ConnectionId,
event: <Handler<R> as ConnectionHandler>::ToBehaviour,
) {
match event {
Either::Left(Either::Left(Ok(_))) => {}
Either::Left(Either::Left(Err(e))) => {
tracing::debug!("dial back error: {e:?}");
Either::Left(Either::Left(result)) => {
if let Err(e) = result {
tracing::debug!("dial back error: {e:?}");
}
// By now the dial-back exchange has concluded: the handler
// waited for the `DialBackResponse` confirming the nonce was
// delivered, or failed. Either way the connection is safe to
// close.
self.pending_events.push_back(ToSwarm::CloseConnection {
peer_id,
connection: CloseConnection::One(connection_id),
});
}
Either::Left(Either::Right(v)) => libp2p_core::util::unreachable(v),
Either::Right(Either::Left(cmd)) => {
Expand Down