From 3f9a1d8f2e1ec036b210351649fe6dc8b52cac55 Mon Sep 17 00:00:00 2001 From: Hs_Yeah Date: Tue, 24 Sep 2024 16:03:56 +0800 Subject: [PATCH] Get dev_name from the global_ctx of each instance --- easytier-gui/README.md | 5 +++++ easytier/src/launcher.rs | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/easytier-gui/README.md b/easytier-gui/README.md index 3af8953..beb3004 100644 --- a/easytier-gui/README.md +++ b/easytier-gui/README.md @@ -14,6 +14,11 @@ npm install -g pnpm ### For Desktop (Win/Mac/Linux) ``` +cd ../tauri-plugin-vpnservice +pnpm install +pnpm build + +cd ../easytier-gui pnpm install pnpm tauri build ``` diff --git a/easytier/src/launcher.rs b/easytier/src/launcher.rs index e0fe49e..615093d 100644 --- a/easytier/src/launcher.rs +++ b/easytier/src/launcher.rs @@ -41,6 +41,7 @@ struct EasyTierData { routes: Arc>>, peers: Arc>>, tun_fd: Arc>>, + tun_dev_name: Arc>, } pub struct EasyTierLauncher { @@ -136,6 +137,10 @@ impl EasyTierLauncher { let vpn_portal = instance.get_vpn_portal_inst(); tasks.spawn(async move { loop { + + // Update TUN Device Name + *data_c.tun_dev_name.write().unwrap() = global_ctx_c.get_flags().dev_name.clone(); + let node_info = MyNodeInfo { virtual_ipv4: global_ctx_c .get_ipv4() @@ -235,6 +240,10 @@ impl EasyTierLauncher { .load(std::sync::atomic::Ordering::Relaxed) } + pub fn get_dev_name(&self) -> String { + self.data.tun_dev_name.read().unwrap().clone() + } + pub fn get_events(&self) -> Vec<(DateTime, GlobalCtxEvent)> { let events = self.data.events.read().unwrap(); events.iter().cloned().collect() @@ -307,7 +316,7 @@ impl NetworkInstance { let peer_route_pairs = list_peer_route_pair(peers.clone(), routes.clone()); Some(NetworkInstanceRunningInfo { - dev_name: self.config.get_flags().dev_name.clone(), + dev_name: launcher.get_dev_name(), my_node_info: launcher.get_node_info(), events: launcher.get_events(), node_info: launcher.get_node_info(),