[mio] 优化代理
This commit is contained in:
@@ -181,13 +181,12 @@ fn recv_handle(
|
|||||||
log::warn!("加密失败:{}", e);
|
log::warn!("加密失败:{}", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if context.send_by_id(net_packet.buffer(), &dest_ip).is_err() {
|
if let Err(e) = context.send_ipv4_by_id(
|
||||||
let connect_server = current_device.connect_server;
|
net_packet.buffer(),
|
||||||
if let Err(e) =
|
&dest_ip,
|
||||||
context.send_default(net_packet.buffer(), connect_server)
|
current_device.connect_server,
|
||||||
{
|
) {
|
||||||
log::warn!("发送到目标失败:{},{}", e, connect_server);
|
log::warn!("发送到目标失败:{}", e);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,6 +300,13 @@ fn tcp_connect(src_port: u16, addr: SocketAddr) -> io::Result<TcpStream> {
|
|||||||
{
|
{
|
||||||
socket.bind(&SocketAddrV4::new(Ipv4Addr::UNSPECIFIED, 0).into())?;
|
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);
|
let _ = socket.set_nodelay(false);
|
||||||
socket.connect_timeout(&addr.into(), Duration::from_secs(3))?;
|
socket.connect_timeout(&addr.into(), Duration::from_secs(3))?;
|
||||||
socket.set_nonblocking(true)?;
|
socket.set_nonblocking(true)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user