aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorrustdesk <[email protected]>2023-06-16 15:13:23 +0800
committerrustdesk <[email protected]>2023-06-16 15:13:23 +0800
commitf1e941bf9f55f6e936f5b8484716002e0ee771e5 (patch)
tree1b3019218ae1521b44f94f9ea6bb8f71cf76c9d3
parentc8719784751af9393b2e8d0c3fb9e8dc52f450d2 (diff)
downloadrustdesk-server-f1e941bf9f55f6e936f5b8484716002e0ee771e5.tar.gz
rustdesk-server-f1e941bf9f55f6e936f5b8484716002e0ee771e5.zip
fix is_loopback
-rw-r--r--src/relay_server.rs5
-rw-r--r--src/rendezvous_server.rs4
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);
}
}