From 20e3ae4d583426ddba296f2613c6008c035abe39 Mon Sep 17 00:00:00 2001 From: lubeilin <1791778603@qq.com> Date: Wed, 6 Mar 2024 12:55:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnt/src/ip_proxy/icmp_proxy.rs | 2 +- vnt/src/ip_proxy/tcp_proxy.rs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/vnt/src/ip_proxy/icmp_proxy.rs b/vnt/src/ip_proxy/icmp_proxy.rs index 23fcadd..3b580a2 100644 --- a/vnt/src/ip_proxy/icmp_proxy.rs +++ b/vnt/src/ip_proxy/icmp_proxy.rs @@ -132,7 +132,7 @@ fn readable_handle( break; } log::warn!("icmp_socket {:?}", e); - continue; + return; } }; if let IpAddr::V4(peer_ip) = addr.ip() { diff --git a/vnt/src/ip_proxy/tcp_proxy.rs b/vnt/src/ip_proxy/tcp_proxy.rs index 95aac13..bb5e3b6 100644 --- a/vnt/src/ip_proxy/tcp_proxy.rs +++ b/vnt/src/ip_proxy/tcp_proxy.rs @@ -157,7 +157,7 @@ fn tcp_proxy( let _ = stream2.shutdown(Shutdown::Read); and_shutdown_state(state1, Shutdown::Write) } else if read { - if readable_handle(stream2, stream1, buf2, state2).is_err() { + if readable_handle(stream2, stream1, buf2, state1).is_err() { if buf2.is_empty() { let _ = stream1.shutdown(Shutdown::Write); } @@ -325,7 +325,7 @@ struct ProxyValue { dest_state: Option, } -const BUF_LEN: usize = 10 * 4096; +const BUF_LEN: usize = 65536; impl ProxyValue { fn new(src_stream: TcpStream, dest_stream: TcpStream, src_fd: usize, dest_fd: usize) -> Self { @@ -384,7 +384,6 @@ fn readable_handle( loop { if mid_buf.len() >= BUF_LEN { // 达到上限不再继续读取 - log::warn!("达到上限不再继续读取 {:?}->{:?}", stream1, stream2); return Ok(()); } match stream1.read(&mut buf) {