diff --git a/FastGithub.PacketIntercept/Tcp/TcpInterceptor.cs b/FastGithub.PacketIntercept/Tcp/TcpInterceptor.cs index f25b0c6..1a41d1e 100644 --- a/FastGithub.PacketIntercept/Tcp/TcpInterceptor.cs +++ b/FastGithub.PacketIntercept/Tcp/TcpInterceptor.cs @@ -71,6 +71,7 @@ namespace FastGithub.PacketIntercept.Tcp while (cancellationToken.IsCancellationRequested == false) { + winDivertAddress.Reset(); if (WinDivert.WinDivertRecv(handle, winDivertBuffer, ref winDivertAddress, ref packetLength) == false) { throw new Win32Exception(); @@ -100,6 +101,15 @@ namespace FastGithub.PacketIntercept.Tcp unsafe private void ModifyTcpPacket(WinDivertBuffer winDivertBuffer, ref WinDivertAddress winDivertAddress, ref uint packetLength) { var packet = WinDivert.WinDivertHelperParsePacket(winDivertBuffer, packetLength); + if (packet.IPv4Header != null && packet.IPv4Header->SrcAddr.Equals(IPAddress.Loopback) == false) + { + return; + } + if (packet.IPv6Header != null && packet.IPv6Header->SrcAddr.Equals(IPAddress.IPv6Loopback) == false) + { + return; + } + if (packet.TcpHeader->DstPort == oldServerPort) { packet.TcpHeader->DstPort = this.newServerPort; diff --git a/FastGithub.sln b/FastGithub.sln index 45ccc94..2be28f9 100644 --- a/FastGithub.sln +++ b/FastGithub.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31320.298 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32203.90 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FastGithub", "FastGithub\FastGithub.csproj", "{C1099390-6103-4917-A740-A3002B542FE0}" EndProject