From 32e90b672f5e6ce04f74e6dfc20ba91e030d18c1 Mon Sep 17 00:00:00 2001 From: Aigio Liu Date: Wed, 9 Mar 2022 00:29:04 +0800 Subject: [PATCH] Add ProxyMode --- src/ST.Client/ProxyMode.cs | 28 +++++++++++++++++++++++++ src/ST.Client/Settings/ProxySettings.cs | 23 ++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/ST.Client/ProxyMode.cs diff --git a/src/ST.Client/ProxyMode.cs b/src/ST.Client/ProxyMode.cs new file mode 100644 index 000000000..2956e3c6b --- /dev/null +++ b/src/ST.Client/ProxyMode.cs @@ -0,0 +1,28 @@ +namespace System.Application +{ + /// + /// 代理模式 + /// + public enum ProxyMode : byte + { + /// + /// 通过注入驱动实现 DNS 拦截进行代理 (Windows Only) + /// + DNSIntercept, + + /// + /// 修改 Hosts 文件进行代理 (Desktop Only) + /// + Hosts, + + /// + /// 系统代理模式 + /// + System, + + /// + /// VPN 代理模式(虚拟网卡) + /// + VPN, + } +} diff --git a/src/ST.Client/Settings/ProxySettings.cs b/src/ST.Client/Settings/ProxySettings.cs index dd8c1803a..34e49f7e4 100644 --- a/src/ST.Client/Settings/ProxySettings.cs +++ b/src/ST.Client/Settings/ProxySettings.cs @@ -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; + } + } + + /// + /// 当前代理模式 + /// + public static SerializableProperty ProxyMode { get; } + = GetProperty(defaultValue: DefaultProxyMode, autoSave: true); } }