Skip to content

Commit

Permalink
Revert "🔥 Remove ProxyMode.DNSIntercept with REMOVE_DNS_INTERCEPT"
Browse files Browse the repository at this point in the history
This reverts commit 7f7fde2.
  • Loading branch information
AigioL committed Oct 9, 2024
1 parent 5ab308b commit 59474d6
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<RootNamespace>BD.WTTS</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SelfContained>false</SelfContained>
<DefineConstants>APP_REVERSE_PROXY;NONE_UI;REMOVE_DNS_INTERCEPT;$(DefineConstants)</DefineConstants>
<DefineConstants>APP_REVERSE_PROXY;NONE_UI;$(DefineConstants)</DefineConstants>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>

Expand Down Expand Up @@ -110,7 +110,7 @@
<PackageReference Include="Utf8StringInterpolation" />
</ItemGroup>

<ItemGroup Condition="!$(DefineConstants.Contains('REMOVE_DNS_INTERCEPT')) AND $([MSBuild]::IsOSPlatform('windows')) AND ($(RuntimeIdentifier.StartsWith('win-')) OR $(RuntimeIdentifier) == '')">
<ItemGroup Condition="$([MSBuild]::IsOSPlatform('windows')) AND ($(RuntimeIdentifier.StartsWith('win-')) OR $(RuntimeIdentifier) == '')">
<PackageReference Include="Aigio.WinDivertSharp" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ internal static IServiceCollection AddFlowAnalyze(this IServiceCollection servic

#if WINDOWS

#if !REMOVE_DNS_INTERCEPT
/// <summary>
/// 注册数据包拦截器
/// </summary>
Expand All @@ -171,7 +170,6 @@ internal static IServiceCollection AddPacketIntercept(this IServiceCollection se

return services;
}
#endif

#endif
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/DnsInterceptHostedService.cs

#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS

// ReSharper disable once CheckNamespace
namespace BD.WTTS.Services.Implementation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Dns/DnsInterceptor.cs

#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS

using WinDivertSharp;
using DNS.Protocol;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Tcp/GitInterceptor.cs

#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS

using static BD.WTTS.Models.Abstractions.IReverseProxyConfig;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Tcp/HttpInterceptor.cs

#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS

using static BD.WTTS.Models.Abstractions.IReverseProxyConfig;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Tcp/HttpsInterceptor.cs

#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS

using static BD.WTTS.Models.Abstractions.IReverseProxyConfig;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Tcp/SshInterceptor.cs

#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS

using static BD.WTTS.Models.Abstractions.IReverseProxyConfig;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/TcpInterceptHostedService.cs

#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS

using static BD.WTTS.Models.Abstractions.IReverseProxyConfig;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// https://github.com/dotnetcore/FastGithub/blob/2.1.4/FastGithub.PacketIntercept/Tcp/TcpInterceptor.cs

#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS

using WinDivertSharp;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void StartupConfigureServices(IServiceCollection services)
services.AddReverseProxyServer();
services.AddFlowAnalyze();

#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS
if (ProxyMode == ProxyMode.DNSIntercept)
{
services.AddPacketIntercept();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<RootNamespace>BD.WTTS</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>WTTS_PLUGIN;WTTS_PLUGIN_ACCELERATOR;REMOVE_DNS_INTERCEPT;$(DefineConstants)</DefineConstants>
<DefineConstants>WTTS_PLUGIN;WTTS_PLUGIN_ACCELERATOR;$(DefineConstants)</DefineConstants>
<!--<EnableDynamicLoading>true</EnableDynamicLoading>-->
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
Expand Down Expand Up @@ -124,7 +124,7 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup Condition="!$(DefineConstants.Contains('REMOVE_DNS_INTERCEPT')) AND $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<Compile Update="Properties\WinDivertResource.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand All @@ -136,7 +136,7 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup Condition="$(DefineConstants.Contains('REMOVE_DNS_INTERCEPT')) OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'windows'">
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'windows'">
<Compile Remove="Properties\WinDivertResource.Designer.cs" />
<EmbeddedResource Remove="Properties\WinDivertResource.resx" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS
using WinDivertBinRes = BD.WTTS.Properties.WinDivertResource;

namespace Mobius.Helpers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ 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)
Expand Down Expand Up @@ -189,7 +186,7 @@ await EnableProxyScripts.ContinueWith(e =>
return Strings.CommunityFix_SetAsSystemPACProxyFail;
}
break;
#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS
case ProxyMode.DNSIntercept:
{
await Mobius.Helpers.WinDivertInitHelper.InitializeAsync();
Expand Down Expand Up @@ -318,9 +315,6 @@ async Task<OperateProxyServiceResult> StopProxyServiceCoreAsync(bool isExit)
#endif
switch (proxyMode) // 先停止接入代理流量
{
#if REMOVE_DNS_INTERCEPT
case ProxyMode.DNSIntercept:
#endif
case ProxyMode.Hosts:
var needClear = hostsFileService.ContainsHostsByTag();
if (needClear)
Expand Down Expand Up @@ -357,7 +351,7 @@ async Task<OperateProxyServiceResult> StopProxyServiceCoreAsync(bool isExit)
await platformService.SetAsSystemPACProxyAsync(false);
}
break;
#if WINDOWS && !REMOVE_DNS_INTERCEPT
#if WINDOWS
case ProxyMode.DNSIntercept:
{
// 停止时也调用初始化
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ static IEnumerable<EProxyMode> 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
Expand Down

0 comments on commit 59474d6

Please sign in to comment.