From e6ad308cd5d236e32c4ed2262ca51c3da5f809da Mon Sep 17 00:00:00 2001 From: m1m1sha <18262227804@163.com> Date: Wed, 8 May 2024 20:49:33 +0800 Subject: [PATCH] =?UTF-8?q?=E2=86=A9=20revert:=20=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easytier/src/peers/peer_ospf_route.rs | 8 ++++---- easytier/src/peers/peer_rip_route.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/easytier/src/peers/peer_ospf_route.rs b/easytier/src/peers/peer_ospf_route.rs index 1ea5152..59bdbf4 100644 --- a/easytier/src/peers/peer_ospf_route.rs +++ b/easytier/src/peers/peer_ospf_route.rs @@ -68,7 +68,7 @@ struct RoutePeerInfo { cost: u8, ipv4_addr: Option, proxy_cidrs: Vec, - hostname: String, + hostname: Option, udp_stun_info: i8, last_update: SystemTime, version: Version, @@ -82,7 +82,7 @@ impl RoutePeerInfo { cost: 0, ipv4_addr: None, proxy_cidrs: Vec::new(), - hostname: String::new(), + hostname: None, udp_stun_info: 0, last_update: SystemTime::now(), version: 0, @@ -101,7 +101,7 @@ impl RoutePeerInfo { .map(|x| x.to_string()) .chain(global_ctx.get_vpn_portal_cidr().map(|x| x.to_string())) .collect(), - hostname: global_ctx.get_hostname(), + hostname: Some(global_ctx.get_hostname()), udp_stun_info: global_ctx .get_stun_info_collector() .get_stun_info() @@ -138,7 +138,7 @@ impl Into for RoutePeerInfo { next_hop_peer_id: 0, cost: self.cost as i32, proxy_cidrs: self.proxy_cidrs.clone(), - hostname: self.hostname, + hostname: self.hostname.unwrap_or_default(), stun_info: { let mut stun_info = StunInfo::default(); if let Ok(udp_nat_type) = NatType::try_from(self.udp_stun_info as i32) { diff --git a/easytier/src/peers/peer_rip_route.rs b/easytier/src/peers/peer_rip_route.rs index 3137e01..2ce0a05 100644 --- a/easytier/src/peers/peer_rip_route.rs +++ b/easytier/src/peers/peer_rip_route.rs @@ -36,7 +36,7 @@ pub struct SyncPeerInfo { pub cost: u32, pub ipv4_addr: Option, pub proxy_cidrs: Vec, - pub hostname: String, + pub hostname: Option, pub udp_stun_info: i8, } @@ -52,7 +52,7 @@ impl SyncPeerInfo { .map(|x| x.to_string()) .chain(global_ctx.get_vpn_portal_cidr().map(|x| x.to_string())) .collect(), - hostname: global_ctx.get_hostname(), + hostname: Some(global_ctx.get_hostname()), udp_stun_info: global_ctx .get_stun_info_collector() .get_stun_info() @@ -585,7 +585,7 @@ impl Route for BasicRoute { route.next_hop_peer_id = route_info.peer_id; route.cost = route_info.cost as i32; route.proxy_cidrs = route_info.proxy_cidrs.clone(); - route.hostname = route_info.hostname.clone(); + route.hostname = route_info.hostname.clone().unwrap_or_default(); let mut stun_info = StunInfo::default(); if let Ok(udp_nat_type) = NatType::try_from(route_info.udp_stun_info as i32) {