Update outgoing address for incoming peers
This commit is contained in:
parent
5994d84a14
commit
a483bc6586
2 changed files with 14 additions and 0 deletions
|
|
@ -919,6 +919,17 @@ impl<'a> PeerConnectionHandler for &'a PeerHandler {
|
||||||
if let Some(peer_pex_msg_id) = hs.ut_pex() {
|
if let Some(peer_pex_msg_id) = hs.ut_pex() {
|
||||||
trace!("peer supports pex at {peer_pex_msg_id}");
|
trace!("peer supports pex at {peer_pex_msg_id}");
|
||||||
}
|
}
|
||||||
|
if let Some(port) = hs.p {
|
||||||
|
// Lets update outgoing Socket address for incoming connection
|
||||||
|
if self.incoming {
|
||||||
|
if let Ok(port) = <u32 as TryInto<u16>>::try_into(port) {
|
||||||
|
let outgoing_addr = SocketAddr::new(self.addr.ip(), port);
|
||||||
|
self.state.peers.with_peer_mut(self.addr, "update outgoing addr",
|
||||||
|
|peer| peer.outgoing_address=Some(outgoing_addr));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
pub mod stats;
|
pub mod stats;
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use librqbit_core::hash_id::Id20;
|
use librqbit_core::hash_id::Id20;
|
||||||
use librqbit_core::lengths::ChunkInfo;
|
use librqbit_core::lengths::ChunkInfo;
|
||||||
|
|
@ -20,6 +21,7 @@ pub(crate) type PeerTx = UnboundedSender<WriterRequest>;
|
||||||
pub(crate) struct Peer {
|
pub(crate) struct Peer {
|
||||||
pub state: PeerStateNoMut,
|
pub state: PeerStateNoMut,
|
||||||
pub stats: stats::atomic::PeerStats,
|
pub stats: stats::atomic::PeerStats,
|
||||||
|
pub outgoing_address: Option<SocketAddr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Peer {
|
impl Peer {
|
||||||
|
|
@ -35,6 +37,7 @@ impl Peer {
|
||||||
Self {
|
Self {
|
||||||
state,
|
state,
|
||||||
stats: Default::default(),
|
stats: Default::default(),
|
||||||
|
outgoing_address: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue