diff --git a/FastGithub.PacketIntercept/Dns/DnsInterceptor.cs b/FastGithub.PacketIntercept/Dns/DnsInterceptor.cs
index 9716180..6a8a9ca 100644
--- a/FastGithub.PacketIntercept/Dns/DnsInterceptor.cs
+++ b/FastGithub.PacketIntercept/Dns/DnsInterceptor.cs
@@ -1,10 +1,10 @@
using DNS.Protocol;
using DNS.Protocol.ResourceRecords;
using FastGithub.Configuration;
+using FastGithub.WinDiverts;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
-using System.Buffers.Binary;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -13,7 +13,6 @@ using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
-using WinDivertSharp;
namespace FastGithub.PacketIntercept.Dns
{
@@ -146,21 +145,21 @@ namespace FastGithub.PacketIntercept.Dns
var destAddress = packet.IPv4Header->DstAddr;
packet.IPv4Header->DstAddr = packet.IPv4Header->SrcAddr;
packet.IPv4Header->SrcAddr = destAddress;
- packet.IPv4Header->Length = BinaryPrimitives.ReverseEndianness((ushort)packetLength);
+ packet.IPv4Header->Length = (ushort)packetLength;
}
else
{
var destAddress = packet.IPv6Header->DstAddr;
packet.IPv6Header->DstAddr = packet.IPv6Header->SrcAddr;
packet.IPv6Header->SrcAddr = destAddress;
- packet.IPv6Header->Length = BinaryPrimitives.ReverseEndianness((ushort)packetLength);
+ packet.IPv6Header->Length = (ushort)packetLength;
}
// 修改udp包
var destPort = packet.UdpHeader->DstPort;
packet.UdpHeader->DstPort = packet.UdpHeader->SrcPort;
packet.UdpHeader->SrcPort = destPort;
- packet.UdpHeader->Length = BinaryPrimitives.ReverseEndianness((ushort)(sizeof(UdpHeader) + responsePayload.Length));
+ packet.UdpHeader->Length = (ushort)(sizeof(UdpHeader) + responsePayload.Length);
winDivertAddress.Impostor = true;
WinDivert.WinDivertHelperCalcChecksums(winDivertBuffer, packetLength, ref winDivertAddress, WinDivertChecksumHelperParam.All);
diff --git a/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj b/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj
index 08a71e8..782704c 100644
--- a/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj
+++ b/FastGithub.PacketIntercept/FastGithub.PacketIntercept.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/FastGithub.PacketIntercept/Tcp/TcpInterceptor.cs b/FastGithub.PacketIntercept/Tcp/TcpInterceptor.cs
index db7bf15..1cccfcc 100644
--- a/FastGithub.PacketIntercept/Tcp/TcpInterceptor.cs
+++ b/FastGithub.PacketIntercept/Tcp/TcpInterceptor.cs
@@ -1,12 +1,11 @@
-using Microsoft.Extensions.Logging;
+using FastGithub.WinDiverts;
+using Microsoft.Extensions.Logging;
using System;
-using System.Buffers.Binary;
using System.ComponentModel;
using System.Net;
using System.Runtime.Versioning;
using System.Threading;
using System.Threading.Tasks;
-using WinDivertSharp;
namespace FastGithub.PacketIntercept.Tcp
{
@@ -30,8 +29,8 @@ namespace FastGithub.PacketIntercept.Tcp
public TcpInterceptor(int oldServerPort, int newServerPort, ILogger logger)
{
this.filter = $"loopback and (tcp.DstPort == {oldServerPort} or tcp.SrcPort == {newServerPort})";
- this.oldServerPort = BinaryPrimitives.ReverseEndianness((ushort)oldServerPort);
- this.newServerPort = BinaryPrimitives.ReverseEndianness((ushort)newServerPort);
+ this.oldServerPort = (ushort)oldServerPort;
+ this.newServerPort = (ushort)newServerPort;
this.logger = logger;
}
@@ -55,7 +54,7 @@ namespace FastGithub.PacketIntercept.Tcp
throw new Win32Exception();
}
- this.logger.LogInformation($"tcp://{IPAddress.Loopback}:{BinaryPrimitives.ReverseEndianness(this.oldServerPort)} => tcp://{IPAddress.Loopback}:{BinaryPrimitives.ReverseEndianness(this.newServerPort)}");
+ this.logger.LogInformation($"tcp://{IPAddress.Loopback}:{this.oldServerPort} => tcp://{IPAddress.Loopback}:{this.newServerPort}");
cancellationToken.Register(hwnd => WinDivert.WinDivertClose((IntPtr)hwnd!), handle);
var packetLength = 0U;
diff --git a/FastGithub.sln b/FastGithub.sln
index 7bfdb8e..af46f5e 100644
--- a/FastGithub.sln
+++ b/FastGithub.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.0.31612.314
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31507.150
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub", "FastGithub\FastGithub.csproj", "{C1099390-6103-4917-A740-A3002B542FE0}"
EndProject
diff --git a/pack.sh b/pack.sh
index 16317ee..b9c57a1 100644
--- a/pack.sh
+++ b/pack.sh
@@ -2,14 +2,14 @@
cd ./FastGithub/bin/publish
# win-x64
-zip -r fastgithub_win-x64.zip fastgithub_win-x64 -x "./fastgithub_win-x64/x86/*" -x "./fastgithub_win-x64/*.pdb"
+zip -r fastgithub_win-x64.zip fastgithub_win-x64
# linux-x64
chmod 777 ./fastgithub_linux-x64/fastgithub
chmod 777 ./fastgithub_linux-x64/dnscrypt-proxy/dnscrypt-proxy
-zip -r fastgithub_linux-x64.zip fastgithub_linux-x64 -x "./fastgithub_linux-x64/x64/*" -x "./fastgithub_linux-x64/x86/*" -x "./fastgithub_linux-x64/*.pdb"
+zip -r fastgithub_linux-x64.zip fastgithub_linux-x64
# osx-x64
chmod 777 ./fastgithub_osx-x64/fastgithub
chmod 777 ./fastgithub_osx-x64/dnscrypt-proxy/dnscrypt-proxy
-zip -r fastgithub_osx-x64.zip fastgithub_osx-x64 -x "./fastgithub_osx-x64/x64/*" -x "./fastgithub_osx-x64/x86/*" -x "./fastgithub_osx-x64/*.pdb"
+zip -r fastgithub_osx-x64.zip fastgithub_osx-x64