diff options
-rw-r--r-- | src/relay_server.rs | 5 | ||||
-rw-r--r-- | src/rendezvous_server.rs | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/relay_server.rs b/src/relay_server.rs index b7e2a76..4522c89 100644 --- a/src/relay_server.rs +++ b/src/relay_server.rs @@ -374,8 +374,8 @@ async fn handle_connection( key: &str, ws: bool, ) { - let ip = addr.ip().to_string(); - if !ws && ip == "127.0.0.1" { + let ip = hbb_common::try_into_v4(addr).ip(); + if !ws && ip.is_loopback() { let limiter = limiter.clone(); tokio::spawn(async move { let mut stream = stream; @@ -389,6 +389,7 @@ async fn handle_connection( }); return; } + let ip = ip.to_string(); if BLOCKLIST.read().await.get(&ip).is_some() { log::info!("{} blocked", ip); return; diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs index a5ba9bb..c504576 100644 --- a/src/rendezvous_server.rs +++ b/src/rendezvous_server.rs @@ -436,7 +436,7 @@ impl RendezvousServer { self.handle_local_addr(la, addr, Some(socket)).await?; } Some(rendezvous_message::Union::ConfigureUpdate(mut cu)) => { - if addr.ip().is_loopback() && cu.serial > self.inner.serial { + if try_into_v4(addr).ip().is_loopback() && cu.serial > self.inner.serial { let mut inner: Inner = (*self.inner).clone(); inner.serial = cu.serial; self.inner = Arc::new(inner); @@ -1203,7 +1203,7 @@ impl RendezvousServer { } SocketAddr::V6(v6_socket_addr) => { - if let Some(v4_addr) = v6_socket_addr.ip().to_ipv4_mapped() { + if let Some(v4_addr) = v6_socket_addr.ip().to_ipv4() { return network.contains(v4_addr); } } |