Skip to content

Commit

Permalink
fix(igd): don't skip port forwarding if local IP address is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel-faber committed Feb 12, 2021
1 parent 2d70c05 commit 2fb6401
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
5 changes: 1 addition & 4 deletions examples/echo_service.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
use anyhow::{anyhow, bail, Error, Result};
use bytes::Bytes;
use qp2p::{Config, Message, QuicP2p};
use std::{
env,
net::{IpAddr, Ipv4Addr},
};
use std::env;
use tokio::io::AsyncBufReadExt;

#[tokio::main]
Expand Down
12 changes: 1 addition & 11 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Endpoint {
/// such an address cannot be reached and hence not useful.
async fn public_addr(&self) -> Result<SocketAddr> {
// Skip port forwarding
if self.local_addr.ip().is_loopback() || !self.local_addr.ip().is_unspecified() {
if self.local_addr.ip().is_loopback() {
return Ok(self.local_addr);
}

Expand Down Expand Up @@ -155,16 +155,6 @@ impl Endpoint {
})
}

/// Get an existing connection for the peer address.
pub fn get_connection(&self, peer_addr: &SocketAddr) -> Option<Connection> {
if let Some((conn, guard)) = self.connection_pool.get(peer_addr) {
trace!("Using cached connection to peer: {}", peer_addr);
Some(Connection::new(conn, guard))
} else {
None
}
}

/// Connects to another peer.
///
/// Returns `Connection` which is a handle for sending messages to the peer and
Expand Down

0 comments on commit 2fb6401

Please sign in to comment.