From da50d2f15f6c5a45ee04c3e99c99ad74b842e1de Mon Sep 17 00:00:00 2001 From: ospab Date: Fri, 15 May 2026 15:58:35 +0300 Subject: [PATCH] feat: autonomous self-downloading dependencies inside TUN OS drivers --- ostp-client/src/tunnel/linux_handler.rs | 4 +++- ostp-client/src/tunnel/wintun_handler.rs | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ostp-client/src/tunnel/linux_handler.rs b/ostp-client/src/tunnel/linux_handler.rs index d257b7d..98822d4 100644 --- a/ostp-client/src/tunnel/linux_handler.rs +++ b/ostp-client/src/tunnel/linux_handler.rs @@ -18,7 +18,9 @@ pub async fn run_linux_tunnel( println!("[ostp-client] Starting Linux TUN handler initialization..."); } - // 1. Locate tun2socks binary + // 1. Automatically ensure tun2socks binary is downloaded and present + super::download_tun2socks(debug)?; + let exe = std::env::current_exe()?; let dir = exe.parent().ok_or_else(|| anyhow!("failed to get binary directory"))?; diff --git a/ostp-client/src/tunnel/wintun_handler.rs b/ostp-client/src/tunnel/wintun_handler.rs index 558438b..8c8a510 100644 --- a/ostp-client/src/tunnel/wintun_handler.rs +++ b/ostp-client/src/tunnel/wintun_handler.rs @@ -15,13 +15,16 @@ pub async fn run_wintun_tunnel( println!("[ostp-client] Initializing high-performance TUN tunnel via tun2socks..."); } - // 1. Get executable directory to locate tun2socks.exe and wintun.dll + // 1. Automatically ensure Wintun and tun2socks dependencies are downloaded and present + super::download_wintun_dll(debug)?; + super::download_tun2socks(debug)?; + let exe = std::env::current_exe()?; let dir = exe.parent().ok_or_else(|| anyhow!("failed to get binary directory"))?; let tun2socks_exe = dir.join("tun2socks.exe"); if !tun2socks_exe.exists() { - return Err(anyhow!("tun2socks.exe not found! Please ensure initialization downloaded it successfully.")); + return Err(anyhow!("tun2socks.exe not found! Even after download attempt, binary remains missing.")); } // 2. Resolve Server IP for routing table exclusion