mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-27 10:40:08 +00:00
Compare commits
No commits in common. "2236b1b688e57c224f0e4721a4a66927d382cce2" and "6a98ee377dd6c75784fcd57c973349ffc6a99eb5" have entirely different histories.
2236b1b688
...
6a98ee377d
2 changed files with 22 additions and 51 deletions
|
|
@ -857,55 +857,6 @@ public class Utils
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsPackagedInstall()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (IsWindows() || IsOSX())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPIMAGE")))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 (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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static async Task<string?> GetLinuxUserId()
|
private static async Task<string?> GetLinuxUserId()
|
||||||
{
|
{
|
||||||
var arg = new List<string>() { "-c", "id -u" };
|
var arg = new List<string>() { "-c", "id -u" };
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,29 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
CheckUpdateModels.Add(GetCheckUpdateModel(_geo));
|
CheckUpdateModels.Add(GetCheckUpdateModel(_geo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsPackagedInstall()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (Utils.IsWindows())
|
||||||
|
return false;
|
||||||
|
if (!string.IsNullOrEmpty(System.Environment.GetEnvironmentVariable("APPIMAGE")))
|
||||||
|
return true;
|
||||||
|
var sp = Utils.StartupPath()?.Replace('\\', '/');
|
||||||
|
if (!string.IsNullOrEmpty(sp) && sp.StartsWith("/opt/v2rayN", StringComparison.Ordinal))
|
||||||
|
return true;
|
||||||
|
var procPath = System.Environment.ProcessPath;
|
||||||
|
var procDir = string.IsNullOrEmpty(procPath) ? "" : System.IO.Path.GetDirectoryName(procPath)?.Replace('\\', '/');
|
||||||
|
if (!string.IsNullOrEmpty(procDir) && procDir.StartsWith("/opt/v2rayN", StringComparison.Ordinal))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private CheckUpdateModel GetCheckUpdateModel(string coreType)
|
private CheckUpdateModel GetCheckUpdateModel(string coreType)
|
||||||
{
|
{
|
||||||
if (coreType == _v2rayN && Utils.IsPackagedInstall())
|
if (coreType == _v2rayN && IsPackagedInstall())
|
||||||
{
|
{
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
|
|
@ -114,7 +134,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else if (item.CoreType == _v2rayN)
|
else if (item.CoreType == _v2rayN)
|
||||||
{
|
{
|
||||||
if (Utils.IsPackagedInstall())
|
if (IsPackagedInstall())
|
||||||
{
|
{
|
||||||
await UpdateView(_v2rayN, "Not Support");
|
await UpdateView(_v2rayN, "Not Support");
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue