aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRustDesk <[email protected]>2023-06-08 13:53:09 +0800
committerGitHub <[email protected]>2023-06-08 13:53:09 +0800
commitd8e3cb9e650fbdd49b10572fa60e919384f4ea8a (patch)
tree9efb0e1446875a13d9c0e025e8ab6f2f5cdfabdc /src
parent3a7904fa8e325636a85b4cc941b3d598c9651a7f (diff)
parent85a20769fb9754edeeb440191f129b860add5539 (diff)
downloadrustdesk-server-d8e3cb9e650fbdd49b10572fa60e919384f4ea8a.tar.gz
rustdesk-server-d8e3cb9e650fbdd49b10572fa60e919384f4ea8a.zip
Merge pull request #249 from nsgundy/FixNoDirectConnectionWhenBothPeersOnLan
Fix no direct connection when both peers on LAN
Diffstat (limited to 'src')
-rw-r--r--src/rendezvous_server.rs29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs
index 681ffe6..ea2767c 100644
--- a/src/rendezvous_server.rs
+++ b/src/rendezvous_server.rs
@@ -709,17 +709,14 @@ impl RendezvousServer {
}
ph.nat_type = NatType::SYMMETRIC.into(); // will force relay
}
- let same_intranet = !ws
- && match peer_addr {
- SocketAddr::V4(a) => match addr {
- SocketAddr::V4(b) => a.ip() == b.ip(),
+ let same_intranet: bool = !ws
+ && (peer_is_lan && is_lan || {
+ match (peer_addr, addr) {
+ (SocketAddr::V4(a), SocketAddr::V4(b)) => a.ip() == b.ip(),
+ (SocketAddr::V6(a), SocketAddr::V6(b)) => a.ip() == b.ip(),
_ => false,
- },
- SocketAddr::V6(a) => match addr {
- SocketAddr::V6(b) => a.ip() == b.ip(),
- _ => false,
- },
- };
+ }
+ });
let socket_addr = AddrMangle::encode(addr).into();
if same_intranet {
log::debug!(
@@ -1191,8 +1188,16 @@ impl RendezvousServer {
#[inline]
fn is_lan(&self, addr: SocketAddr) -> bool {
if let Some(network) = &self.inner.mask {
- if let SocketAddr::V4(addr) = addr {
- return network.contains(*addr.ip());
+ match addr {
+ SocketAddr::V4(v4_socket_addr) => {
+ return network.contains(*v4_socket_addr.ip());
+ }
+
+ SocketAddr::V6(v6_socket_addr) => {
+ if let Some(v4_addr) = v6_socket_addr.ip().to_ipv4_mapped() {
+ return network.contains(v4_addr);
+ }
+ }
}
}
false