Skip to content

Commit

Permalink
🔥 Remove ProxyMode.DNSIntercept with REMOVE_DNS_INTERCEPT"
Browse files Browse the repository at this point in the history
  • Loading branch information
AigioL committed Nov 27, 2024
1 parent dcda15a commit a0279bf
Show file tree
Hide file tree
Showing 17 changed files with 29 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
<PackageReference Include="Utf8StringInterpolation" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsOSPlatform('windows')) AND ($(RuntimeIdentifier.StartsWith('win-')) OR $(RuntimeIdentifier) == '')">
<ItemGroup Condition="!$(DefineConstants.Contains('REMOVE_DNS_INTERCEPT')) AND $([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,6 +148,7 @@ internal static IServiceCollection AddFlowAnalyze(this IServiceCollection servic

#if WINDOWS

#if !REMOVE_DNS_INTERCEPT
/// <summary>
/// 注册数据包拦截器
/// </summary>
Expand All @@ -170,6 +171,7 @@ 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
#if WINDOWS && !REMOVE_DNS_INTERCEPT

// 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
#if WINDOWS && !REMOVE_DNS_INTERCEPT

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
#if WINDOWS && !REMOVE_DNS_INTERCEPT

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
#if WINDOWS && !REMOVE_DNS_INTERCEPT

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
#if WINDOWS && !REMOVE_DNS_INTERCEPT

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
#if WINDOWS && !REMOVE_DNS_INTERCEPT

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
#if WINDOWS && !REMOVE_DNS_INTERCEPT

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
#if WINDOWS && !REMOVE_DNS_INTERCEPT

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
#if WINDOWS && !REMOVE_DNS_INTERCEPT
if (ProxyMode == ProxyMode.DNSIntercept)
{
services.AddPacketIntercept();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<ItemGroup Condition="!$(DefineConstants.Contains('REMOVE_DNS_INTERCEPT')) AND $([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="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'windows'">
<ItemGroup Condition="$(DefineConstants.Contains('REMOVE_DNS_INTERCEPT')) OR $([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
#if WINDOWS && !REMOVE_DNS_INTERCEPT
using WinDivertBinRes = BD.WTTS.Properties.WinDivertResource;

namespace Mobius.Helpers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -322,6 +325,9 @@ 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 @@ -358,7 +364,7 @@ async Task<OperateProxyServiceResult> StopProxyServiceCoreAsync(bool isExit)
await platformService.SetAsSystemPACProxyAsync(false);
}
break;
#if WINDOWS
#if WINDOWS && !REMOVE_DNS_INTERCEPT
case ProxyMode.DNSIntercept:
{
// 停止时也调用初始化
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ 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 All @@ -26,7 +28,7 @@ static IEnumerable<EProxyMode> GetProxyModes()
yield return EProxyMode.System;
}
#else
return Array.Empty<EProxyMode>();
return Array.Empty<EProxyMode>();
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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\""
Expand Down
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ValidateExecutableReferencesMatchSelfContained>false</ValidateExecutableReferencesMatchSelfContained>
<Deterministic>true</Deterministic>
<CheckEolWorkloads>false</CheckEolWorkloads>
<DefineConstants>REMOVE_DNS_INTERCEPT;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\AssemblyInfo.cs">
Expand Down

0 comments on commit a0279bf

Please sign in to comment.