Add ProxyMode

This commit is contained in:
Aigio Liu
2022-03-09 00:29:04 +08:00
parent ad98879d5c
commit 32e90b672f
2 changed files with 51 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
namespace System.Application
{
/// <summary>
/// 代理模式
/// </summary>
public enum ProxyMode : byte
{
/// <summary>
/// 通过注入驱动实现 DNS 拦截进行代理 (Windows Only)
/// </summary>
DNSIntercept,
/// <summary>
/// 修改 Hosts 文件进行代理 (Desktop Only)
/// </summary>
Hosts,
/// <summary>
/// 系统代理模式
/// </summary>
System,
/// <summary>
/// VPN 代理模式(虚拟网卡)
/// </summary>
VPN,
}
}
+23
View File
@@ -4,6 +4,7 @@ using System.Application.Services;
using System.Application.UI;
using System.Collections.Generic;
using IPAddress = System.Net.IPAddress;
using EProxyMode = System.Application.ProxyMode;
namespace System.Application.Settings
{
@@ -127,5 +128,27 @@ namespace System.Application.Settings
= GetProperty(defaultValue: string.Empty, autoSave: false);
#endregion
static EProxyMode DefaultProxyMode
{
get
{
if (OperatingSystem2.IsWindows)
{
return EProxyMode.DNSIntercept;
}
else if (OperatingSystem2.IsAndroid)
{
return EProxyMode.VPN;
}
return EProxyMode.Hosts;
}
}
/// <summary>
/// 当前代理模式
/// </summary>
public static SerializableProperty<EProxyMode> ProxyMode { get; }
= GetProperty(defaultValue: DefaultProxyMode, autoSave: true);
}
}