完善代理

This commit is contained in:
lubeilin
2024-03-06 12:55:26 +08:00
parent a910d7a673
commit 20e3ae4d58
2 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -132,7 +132,7 @@ fn readable_handle(
break;
}
log::warn!("icmp_socket {:?}", e);
continue;
return;
}
};
if let IpAddr::V4(peer_ip) = addr.ip() {
+2 -3
View File
@@ -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<Shutdown>,
}
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) {