From e7afe3bb92540c40f65aa804ff1bc87e922bc267 Mon Sep 17 00:00:00 2001 From: Valeriy Manzhos <47538801+InvisibleRain@users.noreply.github.com> Date: Thu, 9 Apr 2026 17:20:21 +0300 Subject: [PATCH] Stop TUN and delete rules when the TUN button is untoggled --- v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index 384c7206..db8ddf72 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -494,6 +494,15 @@ public class StatusBarViewModel : MyReactiveObject } } } + + if (EnableTun == false) + { + if (Utils.IsLinux()) + { + await CoreManager.DeleteTUNRoutes(); + await CoreManager.KillTUNProcess(); + } + } await ConfigHandler.SaveConfig(_config); // On Linux TUN is managed by an external program, not by the core if (!Utils.IsLinux())