mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-07-02 19:21:37 +00:00
protocols/kad: Implement NetworkBehaviour::inject_address_change (#1649)
With 826f513
a `StreamMuxer` can notify that the address of a remote
peer changed. This is needed to support the transport protocol QUIC as
remotes can change their IP addresses within the lifetime of a single
connection.
This commit implements the `NetworkBehaviour::inject_address_change`
handler to update the Kademlia routing table accordingly.
This commit is contained in:
@ -133,6 +133,19 @@ impl ConnectedPoint {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the address of the remote stored in this struct.
|
||||
///
|
||||
/// For `Dialer`, this returns `address`. For `Listener`, this returns `send_back_addr`.
|
||||
///
|
||||
/// Note that the remote node might not be listening on this address and hence the address might
|
||||
/// not be usable to establish new connections.
|
||||
pub fn get_remote_address(&self) -> &Multiaddr {
|
||||
match self {
|
||||
ConnectedPoint::Dialer { address } => address,
|
||||
ConnectedPoint::Listener { send_back_addr, .. } => send_back_addr,
|
||||
}
|
||||
}
|
||||
|
||||
/// Modifies the address of the remote stored in this struct.
|
||||
///
|
||||
/// For `Dialer`, this modifies `address`. For `Listener`, this modifies `send_back_addr`.
|
||||
|
Reference in New Issue
Block a user