This commit is contained in:
陈国伟 2021-09-18 08:33:05 +08:00
parent a568a05bf7
commit f78b2f7888

View File

@ -123,7 +123,7 @@ namespace FastGithub.Dns
// 修改payload和包长
responsePayload.CopyTo(new Span<byte>(packet.PacketPayload, responsePayload.Length));
packetLength += (uint)responsePayload.Length - packet.PacketPayloadLength;
packetLength = (uint)((int)packetLength + responsePayload.Length - requestPayload.Length);
// 修改ip包
if (packet.IPv4Header != null)
@ -145,7 +145,7 @@ namespace FastGithub.Dns
var destPort = packet.UdpHeader->DstPort;
packet.UdpHeader->DstPort = packet.UdpHeader->SrcPort;
packet.UdpHeader->SrcPort = destPort;
packet.UdpHeader->Length = BinaryPrimitives.ReverseEndianness((ushort)(responsePayload.Length + 8));
packet.UdpHeader->Length = BinaryPrimitives.ReverseEndianness((ushort)(sizeof(UdpHeader) + responsePayload.Length));
// 反转方向
if (winDivertAddress.Direction == WinDivertDirection.Inbound)