Skip to content

Commit

Permalink
chore: Remove peer id from address if exist
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusc93 committed Oct 25, 2024
1 parent 17aa20a commit a2daed6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use multibase::Base;
use libp2p::core::ConnectedPoint;
#[cfg(not(target_arch = "wasm32"))]
use libp2p::mdns::Event as MdnsEvent;
use libp2p::multiaddr::Protocol;
use libp2p::{
autonat,
identify::{Event as IdentifyEvent, Info as IdentifyInfo},
Expand Down Expand Up @@ -262,6 +263,10 @@ impl<C: NetworkBehaviour<ToSwarm = void::Void>> IpfsTask<C> {
if let Some(ch_list) = self.peer_connection_events.get_mut(&peer_id) {
let ev = match &endpoint {
ConnectedPoint::Dialer { address, .. } => {
let mut address = address.clone();
if matches!(address.iter().last(), Some(Protocol::P2p(_))) {
address.pop();
}
PeerConnectionEvents::OutgoingConnection {
connection_id,
addr: address.clone(),
Expand All @@ -288,6 +293,10 @@ impl<C: NetworkBehaviour<ToSwarm = void::Void>> IpfsTask<C> {
for ch in &mut self.connection_events {
let ev = match &endpoint {
ConnectedPoint::Dialer { address, .. } => {
let mut address = address.clone();
if matches!(address.iter().last(), Some(Protocol::P2p(_))) {
address.pop();
}
ConnectionEvents::OutgoingConnection {
peer_id,
connection_id,
Expand Down

0 comments on commit a2daed6

Please sign in to comment.