From 9badbe180cb5bdc1707e0d38fb3c08960d5d53f0 Mon Sep 17 00:00:00 2001 From: lubeilin <1791778603@qq.com> Date: Wed, 20 Mar 2024 12:21:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E8=BD=AC=E5=8F=91=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=E5=92=8C=E7=9B=AE=E7=9A=84=E7=9B=B8=E5=90=8C=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnt/src/handle/recv_data/turn.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vnt/src/handle/recv_data/turn.rs b/vnt/src/handle/recv_data/turn.rs index 508676d..b0ecbb5 100644 --- a/vnt/src/handle/recv_data/turn.rs +++ b/vnt/src/handle/recv_data/turn.rs @@ -18,7 +18,7 @@ impl PacketHandler for TurnPacketHandler { fn handle( &self, mut net_packet: NetPacket<&mut [u8]>, - _route_key: RouteKey, + route_key: RouteKey, context: &Context, _current_device: &CurrentDeviceInfo, ) -> std::io::Result<()> { @@ -27,6 +27,16 @@ impl PacketHandler for TurnPacketHandler { if ttl > 0 { let destination = net_packet.destination(); if let Some(route) = context.route_table.route_one(&destination) { + if route.addr == route_key.addr { + //防止环路 + log::warn!( + "来源和目标相同 {:?},{},{}", + route_key, + net_packet.source(), + net_packet.destination() + ); + return Ok(()); + } if route.metric <= ttl { context.send_by_key(net_packet.buffer(), route.route_key())?; }