mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-27 10:40:08 +00:00
Compare commits
7 commits
790025718d
...
d53039e541
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d53039e541 | ||
|
|
2236b1b688 | ||
|
|
8eeedbdb23 | ||
|
|
ef84e735c4 | ||
|
|
fffdbd4dd1 | ||
|
|
329a46ab9c | ||
|
|
3862f6c97c |
2 changed files with 51 additions and 22 deletions
|
|
@ -857,6 +857,55 @@ 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,29 +61,9 @@ 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 && IsPackagedInstall())
|
if (coreType == _v2rayN && Utils.IsPackagedInstall())
|
||||||
{
|
{
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
|
|
@ -134,7 +114,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else if (item.CoreType == _v2rayN)
|
else if (item.CoreType == _v2rayN)
|
||||||
{
|
{
|
||||||
if (IsPackagedInstall())
|
if (Utils.IsPackagedInstall())
|
||||||
{
|
{
|
||||||
await UpdateView(_v2rayN, "Not Support");
|
await UpdateView(_v2rayN, "Not Support");
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue