Skip to content

Commit

Permalink
Adding OSPlatform Processing
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Aug 27, 2024
1 parent ae3ab15 commit 54c16ca
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
31 changes: 7 additions & 24 deletions v2rayN/ServiceLib/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,29 +495,6 @@ public static bool IsIpv6(string ip)

#region 测速

/// <summary>
/// 取得本机 IP Address
/// </summary>
/// <returns></returns>
//public static List<string> GetHostIPAddress()
//{
// List<string> lstIPAddress = new List<string>();
// try
// {
// IPHostEntry IpEntry = Dns.GetHostEntry(Dns.GetHostName());
// foreach (IPAddress ipa in IpEntry.AddressList)
// {
// if (ipa.AddressFamily == AddressFamily.InterNetwork)
// lstIPAddress.Add(ipa.ToString());
// }
// }
// catch (Exception ex)
// {
// SaveLog(ex.Message, ex);
// }
// return lstIPAddress;
//}

public static void SetSecurityProtocol(bool enableSecurityProtocolTls13)
{
if (enableSecurityProtocolTls13)
Expand Down Expand Up @@ -708,7 +685,7 @@ public static Dictionary<string, string> GetSystemHosts()

public static string GetExeName(string name)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (IsWindows())
{
return $"{name}.exe";
}
Expand All @@ -718,6 +695,12 @@ public static string GetExeName(string name)
}
}

public static bool IsWindows() => RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

public static bool IsLinux() => RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

public static bool IsOSX() => RuntimeInformation.IsOSPlatform(OSPlatform.OSX);

#endregion 杂项

#region TempPath
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/ServiceLib/Handler/LazyConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public int GetLocalPort(EInboundProtocol protocol)

public void AddProcess(IntPtr processHandle)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Utils.IsWindows())
{
_processJob ??= new();
_processJob?.AddProcess(processHandle);
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/ServiceLib/Handler/UpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ private void ResponseHandler(ECoreType type, string gitHubReleaseApi, bool preRe

private string? GetUrlFromCore(CoreInfo? coreInfo)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (Utils.IsWindows())
{
return RuntimeInformation.ProcessArchitecture switch
{
Expand All @@ -454,7 +454,7 @@ private void ResponseHandler(ECoreType type, string gitHubReleaseApi, bool preRe
_ => null,
};
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
else if (Utils.IsLinux())
{
return RuntimeInformation.ProcessArchitecture switch
{
Expand Down

0 comments on commit 54c16ca

Please sign in to comment.