From 2236b1b688e57c224f0e4721a4a66927d382cce2 Mon Sep 17 00:00:00 2001 From: JieXu Date: Fri, 12 Sep 2025 12:52:46 +0800 Subject: [PATCH] Update Utils.cs --- v2rayN/ServiceLib/Common/Utils.cs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs index 297ef2de..bfc74801 100644 --- a/v2rayN/ServiceLib/Common/Utils.cs +++ b/v2rayN/ServiceLib/Common/Utils.cs @@ -871,13 +871,31 @@ public class Utils return true; } - var sp = StartupPath()?.Replace('\\', '/'); - if (!string.IsNullOrEmpty(sp) && sp.StartsWith("/opt/v2rayN", StringComparison.OrdinalIgnoreCase)) + var exePath = GetExePath(); + var baseDir = string.IsNullOrEmpty(exePath) ? StartupPath() : Path.GetDirectoryName(exePath) ?? ""; + var p = baseDir.Replace('\\', '/'); + + if (string.IsNullOrEmpty(p)) + { + return false; + } + + if (p.Contains("/.mount_", StringComparison.Ordinal)) { return true; } - if (Directory.Exists("/opt/v2rayN")) + if (p.StartsWith("/opt/v2rayN", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + + if (p.StartsWith("/usr/lib/v2rayN", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + + if (p.StartsWith("/usr/share/v2rayN", StringComparison.OrdinalIgnoreCase)) { return true; }