diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj index 560ba13e3..e1f514c07 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj @@ -7,7 +7,7 @@ BD.WTTS true false - APP_REVERSE_PROXY;NONE_UI;$(DefineConstants) + APP_REVERSE_PROXY;NONE_UI;REMOVE_DNS_INTERCEPT;$(DefineConstants) Properties\app.manifest @@ -110,7 +110,7 @@ - + diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Extensions/ServiceCollectionExtensions.cs b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Extensions/ServiceCollectionExtensions.cs index 009d64473..d190bde55 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Extensions/ServiceCollectionExtensions.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Extensions/ServiceCollectionExtensions.cs @@ -148,6 +148,7 @@ public static partial class ServiceCollectionExtensions #if WINDOWS +#if !REMOVE_DNS_INTERCEPT /// /// 注册数据包拦截器 /// @@ -170,6 +171,7 @@ public static partial class ServiceCollectionExtensions return services; } +#endif #endif } \ No newline at end of file diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/DnsInterceptHostedService.cs b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/DnsInterceptHostedService.cs index aeb0d0da2..2087eb38e 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/DnsInterceptHostedService.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/DnsInterceptHostedService.cs @@ -1,6 +1,6 @@ // https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/DnsInterceptHostedService.cs -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT // ReSharper disable once CheckNamespace namespace BD.WTTS.Services.Implementation; diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/DnsInterceptor.cs b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/DnsInterceptor.cs index 1c7b3576b..33ab75866 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/DnsInterceptor.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/DnsInterceptor.cs @@ -1,6 +1,6 @@ // https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Dns/DnsInterceptor.cs -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT using WinDivertSharp; using DNS.Protocol; diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/GitInterceptor.cs b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/GitInterceptor.cs index 517ef9a06..bc9e34c2c 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/GitInterceptor.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/GitInterceptor.cs @@ -1,6 +1,6 @@ // https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Tcp/GitInterceptor.cs -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT using static BD.WTTS.Models.Abstractions.IReverseProxyConfig; diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/HttpInterceptor.cs b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/HttpInterceptor.cs index 3d3871a91..466321184 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/HttpInterceptor.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/HttpInterceptor.cs @@ -1,6 +1,6 @@ // https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Tcp/HttpInterceptor.cs -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT using static BD.WTTS.Models.Abstractions.IReverseProxyConfig; diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/HttpsInterceptor.cs b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/HttpsInterceptor.cs index 717dbb8bf..8e655a0d5 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/HttpsInterceptor.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/HttpsInterceptor.cs @@ -1,6 +1,6 @@ // https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Tcp/HttpsInterceptor.cs -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT using static BD.WTTS.Models.Abstractions.IReverseProxyConfig; diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/SshInterceptor.cs b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/SshInterceptor.cs index b1ae83075..39e585bec 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/SshInterceptor.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/SshInterceptor.cs @@ -1,6 +1,6 @@ // https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Tcp/SshInterceptor.cs -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT using static BD.WTTS.Models.Abstractions.IReverseProxyConfig; diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/TcpInterceptHostedService.cs b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/TcpInterceptHostedService.cs index 3c7293700..f3dfa6185 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/TcpInterceptHostedService.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/TcpInterceptHostedService.cs @@ -1,6 +1,6 @@ // https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/TcpInterceptHostedService.cs -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT using static BD.WTTS.Models.Abstractions.IReverseProxyConfig; diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/TcpInterceptor.cs b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/TcpInterceptor.cs index 06af034ed..3fa3566b4 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/TcpInterceptor.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/PacketIntercept/TcpInterceptor.cs @@ -1,6 +1,6 @@ // https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Tcp/TcpInterceptor.cs -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT using WinDivertSharp; diff --git a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/YarpReverseProxyServiceImpl.Startup.cs b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/YarpReverseProxyServiceImpl.Startup.cs index b12c6b76d..884bca9ca 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/YarpReverseProxyServiceImpl.Startup.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator.ReverseProxy/Services.Implementation/YarpReverseProxyServiceImpl.Startup.cs @@ -23,7 +23,7 @@ partial class YarpReverseProxyServiceImpl services.AddReverseProxyServer(); services.AddFlowAnalyze(); -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT if (ProxyMode == ProxyMode.DNSIntercept) { services.AddPacketIntercept(); diff --git a/src/BD.WTTS.Client.Plugins.Accelerator/BD.WTTS.Client.Plugins.Accelerator.csproj b/src/BD.WTTS.Client.Plugins.Accelerator/BD.WTTS.Client.Plugins.Accelerator.csproj index e451ccba3..2c2c89800 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator/BD.WTTS.Client.Plugins.Accelerator.csproj +++ b/src/BD.WTTS.Client.Plugins.Accelerator/BD.WTTS.Client.Plugins.Accelerator.csproj @@ -3,7 +3,7 @@ BD.WTTS true - WTTS_PLUGIN;WTTS_PLUGIN_ACCELERATOR;$(DefineConstants) + WTTS_PLUGIN;WTTS_PLUGIN_ACCELERATOR;REMOVE_DNS_INTERCEPT;$(DefineConstants) true @@ -124,7 +124,7 @@ - + True True @@ -136,7 +136,7 @@ - + diff --git a/src/BD.WTTS.Client.Plugins.Accelerator/Helpers/WinDivertInitHelper.cs b/src/BD.WTTS.Client.Plugins.Accelerator/Helpers/WinDivertInitHelper.cs index 9e44e420d..25196393b 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator/Helpers/WinDivertInitHelper.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator/Helpers/WinDivertInitHelper.cs @@ -1,4 +1,4 @@ -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT using WinDivertBinRes = BD.WTTS.Properties.WinDivertResource; namespace Mobius.Helpers; diff --git a/src/BD.WTTS.Client.Plugins.Accelerator/Services/Mvvm/ProxyService.Operate.cs b/src/BD.WTTS.Client.Plugins.Accelerator/Services/Mvvm/ProxyService.Operate.cs index a790bf1b9..6869fb15e 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator/Services/Mvvm/ProxyService.Operate.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator/Services/Mvvm/ProxyService.Operate.cs @@ -120,6 +120,9 @@ partial class ProxyService switch (proxyMode) { +#if REMOVE_DNS_INTERCEPT + case ProxyMode.DNSIntercept: +#endif case ProxyMode.Hosts: var inUsePort = SocketHelper.IsUsePort(proxyIp_.Value, httpsPort); if (inUsePort) @@ -186,7 +189,7 @@ partial class ProxyService return Strings.CommunityFix_SetAsSystemPACProxyFail; } break; -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT case ProxyMode.DNSIntercept: { await Mobius.Helpers.WinDivertInitHelper.InitializeAsync(); @@ -315,6 +318,9 @@ partial class ProxyService #endif switch (proxyMode) // 先停止接入代理流量 { +#if REMOVE_DNS_INTERCEPT + case ProxyMode.DNSIntercept: +#endif case ProxyMode.Hosts: var needClear = hostsFileService.ContainsHostsByTag(); if (needClear) @@ -351,7 +357,7 @@ partial class ProxyService await platformService.SetAsSystemPACProxyAsync(false); } break; -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT case ProxyMode.DNSIntercept: { // 停止时也调用初始化 diff --git a/src/BD.WTTS.Client.Plugins.Accelerator/Settings/ProxySettings.ProxyMode.cs b/src/BD.WTTS.Client.Plugins.Accelerator/Settings/ProxySettings.ProxyMode.cs index ad566038c..1b8c1c7a8 100644 --- a/src/BD.WTTS.Client.Plugins.Accelerator/Settings/ProxySettings.ProxyMode.cs +++ b/src/BD.WTTS.Client.Plugins.Accelerator/Settings/ProxySettings.ProxyMode.cs @@ -11,7 +11,9 @@ public static partial class ProxySettings { #if WINDOWS yield return EProxyMode.Hosts; +#if !REMOVE_DNS_INTERCEPT yield return EProxyMode.DNSIntercept; +#endif yield return EProxyMode.PAC; yield return EProxyMode.System; #elif ANDROID