From 1be64223c8332f8fcdb6a94804a4302de58bd43c Mon Sep 17 00:00:00 2001 From: "Sijie.Sun" Date: Tue, 8 Oct 2024 21:05:46 +0800 Subject: [PATCH] ensure dst have session when we are initiator (#398) * ensure dst have session when we are initiator * bump version to 2.0.1 --- .github/workflows/release.yml | 2 +- Cargo.lock | 4 ++-- easytier-gui/package.json | 2 +- easytier-gui/src-tauri/Cargo.toml | 2 +- easytier-gui/src-tauri/tauri.conf.json | 2 +- easytier/Cargo.toml | 2 +- easytier/src/peers/peer_ospf_route.rs | 15 +++++++++++++-- 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f4cbfc0..3df09a2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ on: version: description: 'Version for this release' type: string - default: 'v2.0.0' + default: 'v2.0.1' required: true make_latest: description: 'Mark this release as latest' diff --git a/Cargo.lock b/Cargo.lock index 55c766c..aa73b91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1539,7 +1539,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" [[package]] name = "easytier" -version = "2.0.0" +version = "2.0.1" dependencies = [ "aes-gcm", "anyhow", @@ -1631,7 +1631,7 @@ dependencies = [ [[package]] name = "easytier-gui" -version = "2.0.0" +version = "2.0.1" dependencies = [ "anyhow", "chrono", diff --git a/easytier-gui/package.json b/easytier-gui/package.json index ad81771..8c2638f 100644 --- a/easytier-gui/package.json +++ b/easytier-gui/package.json @@ -1,7 +1,7 @@ { "name": "easytier-gui", "type": "module", - "version": "2.0.0", + "version": "2.0.1", "private": true, "scripts": { "dev": "vite", diff --git a/easytier-gui/src-tauri/Cargo.toml b/easytier-gui/src-tauri/Cargo.toml index 39a2ba8..f29dc6c 100644 --- a/easytier-gui/src-tauri/Cargo.toml +++ b/easytier-gui/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "easytier-gui" -version = "2.0.0" +version = "2.0.1" description = "EasyTier GUI" authors = ["you"] edition = "2021" diff --git a/easytier-gui/src-tauri/tauri.conf.json b/easytier-gui/src-tauri/tauri.conf.json index 1fcc2be..5aa2f2d 100644 --- a/easytier-gui/src-tauri/tauri.conf.json +++ b/easytier-gui/src-tauri/tauri.conf.json @@ -17,7 +17,7 @@ "createUpdaterArtifacts": false }, "productName": "easytier-gui", - "version": "2.0.0", + "version": "2.0.1", "identifier": "com.kkrainbow.easytier", "plugins": {}, "app": { diff --git a/easytier/Cargo.toml b/easytier/Cargo.toml index a949929..98b6a89 100644 --- a/easytier/Cargo.toml +++ b/easytier/Cargo.toml @@ -3,7 +3,7 @@ name = "easytier" description = "A full meshed p2p VPN, connecting all your devices in one network with one command." homepage = "https://github.com/EasyTier/EasyTier" repository = "https://github.com/EasyTier/EasyTier" -version = "2.0.0" +version = "2.0.1" edition = "2021" authors = ["kkrainbow"] keywords = ["vpn", "p2p", "network", "easytier"] diff --git a/easytier/src/peers/peer_ospf_route.rs b/easytier/src/peers/peer_ospf_route.rs index adba786..d699d83 100644 --- a/easytier/src/peers/peer_ospf_route.rs +++ b/easytier/src/peers/peer_ospf_route.rs @@ -6,7 +6,7 @@ use std::{ atomic::{AtomicBool, AtomicU32, Ordering}, Arc, Weak, }, - time::{Duration, SystemTime}, + time::{Duration, Instant, SystemTime}, }; use crossbeam::atomic::AtomicCell; @@ -1290,6 +1290,7 @@ impl PeerRouteServiceImpl { &self, dst_peer_id: PeerId, peer_rpc: Arc, + sync_as_initiator: bool, ) -> bool { let Some(session) = self.get_session(dst_peer_id) else { // if session not exist, exit the sync loop. @@ -1306,6 +1307,7 @@ impl PeerRouteServiceImpl { && conn_bitmap.is_none() && foreign_network.is_none() && !session.need_sync_initiator_info.load(Ordering::Relaxed) + && !(sync_as_initiator && session.we_are_initiator.load(Ordering::Relaxed)) { return true; } @@ -1462,6 +1464,7 @@ impl RouteSessionManager { dst_peer_id: PeerId, mut sync_now: tokio::sync::broadcast::Receiver<()>, ) { + let mut last_sync = Instant::now(); loop { let mut first_time = true; @@ -1479,8 +1482,16 @@ impl RouteSessionManager { service_impl.update_my_infos().await; } + // if we are initiator, we should ensure the dst has the session. + let sync_as_initiator = if last_sync.elapsed().as_secs() > 10 { + last_sync = Instant::now(); + true + } else { + false + }; + if service_impl - .sync_route_with_peer(dst_peer_id, peer_rpc.clone()) + .sync_route_with_peer(dst_peer_id, peer_rpc.clone(), sync_as_initiator) .await { break;