diff --git a/vnt/src/channel/socket/unix.rs b/vnt/src/channel/socket/unix.rs index cea3262..4a7b50a 100644 --- a/vnt/src/channel/socket/unix.rs +++ b/vnt/src/channel/socket/unix.rs @@ -1,4 +1,7 @@ -use crate::channel::socket::{get_interface, LocalInterface, VntSocketTrait}; +#[cfg(any(target_os = "linux", target_os = "macos"))] +use crate::channel::socket::get_interface; +use crate::channel::socket::{LocalInterface, VntSocketTrait}; +#[cfg(any(target_os = "linux", target_os = "macos"))] use anyhow::Context; use std::net::Ipv4Addr; @@ -22,6 +25,12 @@ impl VntSocketTrait for socket2::Socket { Ok(()) } } +#[cfg(target_os = "android")] +impl VntSocketTrait for socket2::Socket { + fn set_ip_unicast_if(&self, _interface: &LocalInterface) -> anyhow::Result<()> { + Ok(()) + } +} #[cfg(any(target_os = "linux", target_os = "macos"))] pub fn get_best_interface(dest_ip: Ipv4Addr) -> anyhow::Result { @@ -35,6 +44,6 @@ pub fn get_best_interface(dest_ip: Ipv4Addr) -> anyhow::Result { Ok(LocalInterface::default()) } #[cfg(target_os = "android")] -pub fn get_best_interface(dest_ip: Ipv4Addr) -> anyhow::Result { +pub fn get_best_interface(_dest_ip: Ipv4Addr) -> anyhow::Result { Ok(LocalInterface::default()) } diff --git a/vnt/src/handle/maintain/heartbeat.rs b/vnt/src/handle/maintain/heartbeat.rs index d58fe88..5327a11 100644 --- a/vnt/src/handle/maintain/heartbeat.rs +++ b/vnt/src/handle/maintain/heartbeat.rs @@ -79,10 +79,6 @@ fn heartbeat0( } heartbeat_packet_server(device_map, server_cipher, src_ip, gateway_ip) } else { - if dest_ip < src_ip { - // 只向比自己大的发 - continue; - } heartbeat_packet_client(client_cipher, src_ip, dest_ip) }; let net_packet = match net_packet { @@ -93,9 +89,13 @@ fn heartbeat0( } }; for (index, route) in routes.iter().enumerate() { - if index >= channel_num + 1 { + let limit = if context.first_latency() { + channel_num + 1 + } else { + channel_num + }; + if index >= limit { // 多余的通道不再发送心跳包,让它自动过期 - // 这里多留一个增加稳定性 break; } if let Err(e) = context.send_by_key(&net_packet, route.route_key()) {