Skip to content

Commit

Permalink
Append PeerId to listen address
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger committed Oct 26, 2022
1 parent 9a80510 commit e5e9c46
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions transports/webrtc/src/tokio/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,8 @@ impl ListenStream {
{
return Poll::Ready(TransportEvent::NewAddress {
listener_id: self.listener_id,
listen_addr: self.listen_multiaddress(ip),
listen_addr: self
.listen_multiaddress(ip, self.config.id_keys.public().to_peer_id()),
});
}
}
Expand All @@ -261,7 +262,8 @@ impl ListenStream {
{
return Poll::Ready(TransportEvent::AddressExpired {
listener_id: self.listener_id,
listen_addr: self.listen_multiaddress(ip),
listen_addr: self
.listen_multiaddress(ip, self.config.id_keys.public().to_peer_id()),
});
}
}
Expand All @@ -278,10 +280,11 @@ impl ListenStream {
}

/// Constructs a [`Multiaddr`] for the given IP address that represents our listen address.
fn listen_multiaddress(&self, ip: IpAddr) -> Multiaddr {
fn listen_multiaddress(&self, ip: IpAddr, local_peer_id: PeerId) -> Multiaddr {
let socket_addr = SocketAddr::new(ip, self.listen_addr.port());

socketaddr_to_multiaddr(&socket_addr, Some(self.config.fingerprint))
.with(Protocol::P2p(*local_peer_id.as_ref()))
}
}

Expand Down

0 comments on commit e5e9c46

Please sign in to comment.