From 8a032f86d88c40162aa82aff3733d1342c91884a Mon Sep 17 00:00:00 2001 From: lubeilin <1791778603@qq.com> Date: Sat, 8 Apr 2023 21:44:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dudp=E5=B9=BF=E6=92=AD?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- switch/src/handle/recv_handler.rs | 3 ++- switch/src/handle/tun_handler.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/switch/src/handle/recv_handler.rs b/switch/src/handle/recv_handler.rs index 0f3961e..a9e3f80 100644 --- a/switch/src/handle/recv_handler.rs +++ b/switch/src/handle/recv_handler.rs @@ -109,7 +109,8 @@ impl RecvHandler { return Ok(()); } let destination = net_packet.destination(); - if current_device.virtual_ip() != destination && self.connect_status.load() == ConnectStatus::Connected { + if !destination.is_broadcast() && destination != current_device.broadcast_address + && current_device.virtual_ip() != destination && self.connect_status.load() == ConnectStatus::Connected { if !check_dest(source, current_device.virtual_netmask, current_device.virtual_network) { log::warn!("转发数据,源地址错误:{:?},当前网络:{:?},route_key:{:?}",source,current_device.virtual_network,route_key); return Ok(()); diff --git a/switch/src/handle/tun_handler.rs b/switch/src/handle/tun_handler.rs index da837f1..022d5ee 100644 --- a/switch/src/handle/tun_handler.rs +++ b/switch/src/handle/tun_handler.rs @@ -49,7 +49,7 @@ fn handle(sender: &Sender, data: &mut [u8], tun_writer: &TunWriter, cu // // 137端口是在局域网中提供计算机的名字或IP地址查询服务 // return Ok(()); // } - if src_ip != current_device.virtual_ip() || !check_dest(dest_ip, current_device.virtual_netmask, current_device.virtual_network) { + if src_ip != current_device.virtual_ip() || (!check_dest(dest_ip, current_device.virtual_netmask, current_device.virtual_network) && !dest_ip.is_broadcast()) { return Ok(()); } if src_ip == dest_ip { @@ -97,7 +97,7 @@ fn start_(sender: Sender, } } -#[cfg(any(target_os = "linux",target_os = "macos"))] +#[cfg(any(target_os = "linux", target_os = "macos"))] fn start_(sender: Sender, tun_reader: TunReader, tun_writer: TunWriter,