diff --git a/vnt/src/channel/channel.rs b/vnt/src/channel/channel.rs index d8957b3..71df817 100644 --- a/vnt/src/channel/channel.rs +++ b/vnt/src/channel/channel.rs @@ -595,8 +595,7 @@ impl Channel { tcp_r .read_exact(&mut buf[head_reserve..head_reserve + len]) .await?; - handler - .handle(&mut buf, head_reserve, head_reserve + len, key, &context); + handler.handle(&mut buf, head_reserve, head_reserve + len, key, &context); } } async fn start_tcp( @@ -684,8 +683,7 @@ impl Channel { let handler = handler.clone(); std::thread::spawn(move || { while let Ok((mut buf, start, end, route_key)) = buf_receiver.recv() { - handler - .handle(&mut buf, start, end, route_key, &context); + handler.handle(&mut buf, start, end, route_key, &context); } log::warn!("异步处理停止"); }); @@ -815,14 +813,13 @@ impl Channel { break; } } - handler - .handle( - &mut buf, - head_reserve, - end, - RouteKey::new(id, addr), - &context, - ); + handler.handle( + &mut buf, + head_reserve, + end, + RouteKey::new(id, addr), + &context, + ); } Err(e) => { log::error!("udp :{:?}", e); @@ -864,11 +861,11 @@ impl Channel { #[cfg(target_os = "windows")] use std::os::windows::io::AsRawSocket; #[cfg(target_os = "windows")] - let id = 3 + udp.as_raw_socket() as usize; + let id = 3 + udp.as_raw_socket() as usize; #[cfg(any(unix))] use std::os::fd::AsRawFd; #[cfg(any(unix))] - let id = 3 + udp.as_raw_fd() as usize; + let id = 3 + udp.as_raw_fd() as usize; context.insert_udp(id, udp.clone()); match buf_sender { diff --git a/vnt/src/handle/recv_handler.rs b/vnt/src/handle/recv_handler.rs index 71c2665..d94298b 100644 --- a/vnt/src/handle/recv_handler.rs +++ b/vnt/src/handle/recv_handler.rs @@ -273,8 +273,10 @@ impl ChannelDataHandler { } _ => { log::warn!( - "不支持的ip代理Icmp协议:{}", - destination + "不支持的ip代理Icmp协议:{}->{}->{}", + source, + destination, + dest_ip ); return Err(Error::Warn( "不支持的ip代理Icmp协议".to_string(), @@ -283,18 +285,36 @@ impl ChannelDataHandler { } } _ => { - log::warn!("不支持的ip代理ipv4协议:{}", destination); + log::warn!( + "不支持的ip代理ipv4协议{:?}:{}->{}->{}", + ipv4.protocol(), + source, + destination, + ipv4.destination_ip() + ); return Err(Error::Warn( "不支持的ip代理ipv4协议".to_string(), )); } } } else { - log::warn!("没有ip代理规则:{}", destination); + log::warn!( + "没有ip代理规则{:?}:{}->{}->{}", + ipv4.protocol(), + source, + destination, + ipv4.destination_ip() + ); return Err(Error::Warn("没有ip代理规则".to_string())); } } else { - log::warn!("不支持ip代理:{}", destination); + log::warn!( + "不支持ip代理{:?}:{}->{}->{}", + ipv4.protocol(), + source, + destination, + ipv4.destination_ip() + ); return Err(Error::Warn("不支持ip代理".to_string())); } } @@ -635,9 +655,11 @@ impl ChannelDataHandler { { let context = context.clone(); let nat_test = self.nat_test.clone(); - std::thread::spawn(move ||{ + std::thread::spawn(move || { tokio::runtime::Builder::new_current_thread() - .enable_all().build().unwrap() + .enable_all() + .build() + .unwrap() .block_on(async move { let local_port = context.main_local_ipv4_port().unwrap_or(0); let local_ipv4_addr = nat::local_ipv4_addr(local_port); diff --git a/vnt/src/ip_proxy/udp_proxy.rs b/vnt/src/ip_proxy/udp_proxy.rs index e103659..62463fd 100644 --- a/vnt/src/ip_proxy/udp_proxy.rs +++ b/vnt/src/ip_proxy/udp_proxy.rs @@ -65,9 +65,10 @@ async fn start0( let dest_addr = *entry.value(); drop(entry); //先使用相同的端口,冲突了再随机端口 - let peer_udp_socket = match UdpSocket::bind(format!("0.0.0.0:{}", sender_addr.port())).await { - Ok(udp) => { udp } - Err(_) => { UdpSocket::bind("0.0.0.0:0").await? } + let peer_udp_socket = match UdpSocket::bind(format!("0.0.0.0:{}", sender_addr.port())).await + { + Ok(udp) => udp, + Err(_) => UdpSocket::bind("0.0.0.0:0").await?, }; peer_udp_socket.connect(dest_addr).await?; peer_udp_socket.send(buf).await?;