From a0279bf8f14c9e7f71fa6d366e476160bf648a9b Mon Sep 17 00:00:00 2001 From: Aigio Liu Date: Wed, 27 Nov 2024 17:27:29 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20ProxyMode.DNSIntercept?= =?UTF-8?q?=20with=20REMOVE=5FDNS=5FINTERCEPT"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...WTTS.Client.Plugins.Accelerator.ReverseProxy.csproj | 2 +- .../Extensions/ServiceCollectionExtensions.cs | 2 ++ .../PacketIntercept/DnsInterceptHostedService.cs | 2 +- .../PacketIntercept/DnsInterceptor.cs | 2 +- .../PacketIntercept/GitInterceptor.cs | 2 +- .../PacketIntercept/HttpInterceptor.cs | 2 +- .../PacketIntercept/HttpsInterceptor.cs | 2 +- .../PacketIntercept/SshInterceptor.cs | 2 +- .../PacketIntercept/TcpInterceptHostedService.cs | 2 +- .../PacketIntercept/TcpInterceptor.cs | 2 +- .../YarpReverseProxyServiceImpl.Startup.cs | 2 +- .../BD.WTTS.Client.Plugins.Accelerator.csproj | 4 ++-- .../Helpers/WinDivertInitHelper.cs | 2 +- .../Services/Mvvm/ProxyService.Operate.cs | 10 ++++++++-- .../Settings/ProxySettings.ProxyMode.cs | 4 +++- .../Properties/launchSettings.json | 4 ++-- src/Directory.Build.props | 1 + 17 files changed, 29 insertions(+), 18 deletions(-) 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 560ba13e352..c02c0c3140a 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 @@ -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 009d64473d9..d190bde55f8 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 @@ internal static IServiceCollection AddFlowAnalyze(this IServiceCollection servic #if WINDOWS +#if !REMOVE_DNS_INTERCEPT /// /// 注册数据包拦截器 /// @@ -170,6 +171,7 @@ internal static IServiceCollection AddPacketIntercept(this IServiceCollection se 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 aeb0d0da224..2087eb38eaf 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 1c7b3576b88..33ab75866ca 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 517ef9a0661..bc9e34c2ca6 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 3d3871a9116..4663211849d 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 717dbb8bf89..8e655a0d51b 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 b1ae83075bf..39e585bec8c 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 3c7293700a9..f3dfa6185b7 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 06af034edb7..3fa3566b4ca 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 b12c6b76d03..884bca9cab0 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 @@ void StartupConfigureServices(IServiceCollection services) 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 e451ccba342..2dd506d2c91 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 @@ -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 9e44e420d60..25196393b8a 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 d0e9260d797..72a8f9e5414 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 @@ -127,6 +127,9 @@ await EnableProxyScripts.ContinueWith(e => switch (proxyMode) { +#if REMOVE_DNS_INTERCEPT + case ProxyMode.DNSIntercept: +#endif case ProxyMode.Hosts: var inUsePort = SocketHelper.IsUsePort(proxyIp_.Value, httpsPort); if (inUsePort) @@ -193,7 +196,7 @@ await EnableProxyScripts.ContinueWith(e => return Strings.CommunityFix_SetAsSystemPACProxyFail; } break; -#if WINDOWS +#if WINDOWS && !REMOVE_DNS_INTERCEPT case ProxyMode.DNSIntercept: { await Mobius.Helpers.WinDivertInitHelper.InitializeAsync(); @@ -322,6 +325,9 @@ async Task StopProxyServiceCoreAsync(bool isExit) #endif switch (proxyMode) // 先停止接入代理流量 { +#if REMOVE_DNS_INTERCEPT + case ProxyMode.DNSIntercept: +#endif case ProxyMode.Hosts: var needClear = hostsFileService.ContainsHostsByTag(); if (needClear) @@ -358,7 +364,7 @@ async Task StopProxyServiceCoreAsync(bool isExit) 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 ad566038c9c..2a266c68c7e 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 @@ static IEnumerable GetProxyModes() { #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 @@ -26,7 +28,7 @@ static IEnumerable GetProxyModes() yield return EProxyMode.System; } #else - return Array.Empty(); + return Array.Empty(); #endif } diff --git a/src/BD.WTTS.Client.Tools.Publish/Properties/launchSettings.json b/src/BD.WTTS.Client.Tools.Publish/Properties/launchSettings.json index 9162d7fe27c..b28e41e1ec3 100644 --- a/src/BD.WTTS.Client.Tools.Publish/Properties/launchSettings.json +++ b/src/BD.WTTS.Client.Tools.Publish/Properties/launchSettings.json @@ -2,9 +2,9 @@ "profiles": { "BD.WTTS.Client.Tools.Publish": { "commandName": "Project", - "commandLineArgs": "nsis --rids win-x64 --hsm-sign --t 241127_1620486875958", + "commandLineArgs": "nsis --rids win-x64 --hsm-sign --t 241127_1710500975164", "commandLineArgs_release": "run --rids win-x64 --hsm-sign --stm-upload", - "commandLineArgs_nsis": "nsis --rids win-x64 --hsm-sign --t 241127_1620486875958 --debug", + "commandLineArgs_nsis": "nsis --rids win-x64 --hsm-sign --t 241127_1710500975164 --debug", "commandLineArgs_debug": "run --rids win-x64 --hsm-sign --stm-upload --debug", "commandLineArgs_GenerateBridgeContentXml": "csproj --rids win-x64", "commandLineArgs_TestUploadFile": "bs --type 2 --old \"C:\\Users\\Mossimo\\Desktop\\Steam++\\ms-test.steampp.net\"" diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 93b8c21b9bb..a44f446ab3f 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -23,6 +23,7 @@ false true false + REMOVE_DNS_INTERCEPT;$(DefineConstants)