解决已知问题

This commit is contained in:
lbl8603
2024-08-08 21:30:19 +08:00
parent e6cfdec9c6
commit 7901407d69
2 changed files with 17 additions and 8 deletions
+11 -2
View File
@@ -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<LocalInterface> {
@@ -35,6 +44,6 @@ pub fn get_best_interface(dest_ip: Ipv4Addr) -> anyhow::Result<LocalInterface> {
Ok(LocalInterface::default())
}
#[cfg(target_os = "android")]
pub fn get_best_interface(dest_ip: Ipv4Addr) -> anyhow::Result<LocalInterface> {
pub fn get_best_interface(_dest_ip: Ipv4Addr) -> anyhow::Result<LocalInterface> {
Ok(LocalInterface::default())
}
+6 -6
View File
@@ -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()) {