diff --git a/vnt/src/ip_proxy/icmp_proxy.rs b/vnt/src/ip_proxy/icmp_proxy.rs index 7472927..23fcadd 100644 --- a/vnt/src/ip_proxy/icmp_proxy.rs +++ b/vnt/src/ip_proxy/icmp_proxy.rs @@ -181,13 +181,12 @@ fn recv_handle( log::warn!("加密失败:{}", e); return; } - if context.send_by_id(net_packet.buffer(), &dest_ip).is_err() { - let connect_server = current_device.connect_server; - if let Err(e) = - context.send_default(net_packet.buffer(), connect_server) - { - log::warn!("发送到目标失败:{},{}", e, connect_server); - } + if let Err(e) = context.send_ipv4_by_id( + net_packet.buffer(), + &dest_ip, + current_device.connect_server, + ) { + log::warn!("发送到目标失败:{}", e); } } } diff --git a/vnt/src/ip_proxy/tcp_proxy.rs b/vnt/src/ip_proxy/tcp_proxy.rs index 3d381b5..95aac13 100644 --- a/vnt/src/ip_proxy/tcp_proxy.rs +++ b/vnt/src/ip_proxy/tcp_proxy.rs @@ -300,6 +300,13 @@ fn tcp_connect(src_port: u16, addr: SocketAddr) -> io::Result { { socket.bind(&SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0).into())?; } + if let Err(e) = socket.set_tcp_keepalive( + &socket2::TcpKeepalive::new() + .with_time(Duration::from_secs(120)) + .with_interval(Duration::from_secs(10)), + ) { + log::warn!("set_tcp_keepalive err {:?}", e); + } let _ = socket.set_nodelay(false); socket.connect_timeout(&addr.into(), Duration::from_secs(3))?; socket.set_nonblocking(true)?;