展示客户端中继状态

This commit is contained in:
lubeilin
2023-07-26 21:31:34 +08:00
parent a2d45da44d
commit 62b2af54a2
3 changed files with 10 additions and 5 deletions
+8 -1
View File
@@ -72,6 +72,7 @@ pub fn command_route(vnt: &Vnt) -> Vec<RouteItem> {
}
pub fn command_list(vnt: &Vnt) -> Vec<DeviceItem> {
let info = vnt.current_device();
let device_list = vnt.device_list();
let mut list = Vec::new();
for peer in device_list {
@@ -87,7 +88,13 @@ pub fn command_list(vnt: &Vnt) -> Vec<DeviceItem> {
("".to_string(), "".to_string(), "".to_string())
};
let (nat_traversal_type, rt) = if let Some(route) = vnt.route(&peer.virtual_ip) {
let nat_traversal_type = if route.metric == 1 { "p2p" } else { "relay" }.to_string();
let nat_traversal_type = if route.metric == 1 {
"p2p"
} else if route.addr == info.connect_server {
"server-relay"
} else {
"client-relay"
}.to_string();
let rt = if route.rt < 0 {
"".to_string()
} else {
+1 -2
View File
@@ -15,8 +15,7 @@ crossbeam-skiplist = "0.1"
parking_lot = "0.12.1"
rand = "0.8.5"
sha2 = { version = "0.10.6", features = ["oid"] }
aes-gcm = "0.10.2"
ring = "0.16.20"
thiserror = "1.0.37"
protobuf = "3.2.0"
socket2 ={ version = "0.5.2", features = ["all"] }
+1 -2
View File
@@ -149,7 +149,6 @@ async fn start_heartbeat_(
} else {
//没有直连路由则发送到网关
let _ = sender.send_main(net_packet.buffer(), current_dev.connect_server).await;
continue;
}
//再随机发送到其他地址,看有没有客户端符合转发条件
@@ -167,7 +166,7 @@ async fn start_heartbeat_(
num += 1;
break;
}
if num >= 3 {
if num >= 2 {
break 'a;
}
}