From cd33f35ab61f212962480ad0f298b094fde7719a Mon Sep 17 00:00:00 2001 From: Xsear Date: Thu, 27 Aug 2026 22:45:14 +0200 Subject: [PATCH] Update SharPcap to 6.3.1 and project to .NET 8 --- .github/workflows/buildAndPublish.yml | 2 +- FauCap/Converter.cs | 9 +++++---- FauCap/FauCap.csproj | 10 +++++----- FauCap/PacketUtil.cs | 16 ++++++++-------- FauCapParser/FauCapParser.csproj | 8 ++++---- Test/Test.csproj | 4 ++-- publish.bat | 6 +++--- 7 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/buildAndPublish.yml b/.github/workflows/buildAndPublish.yml index 906016e..05332df 100644 --- a/.github/workflows/buildAndPublish.yml +++ b/.github/workflows/buildAndPublish.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 8.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/FauCap/Converter.cs b/FauCap/Converter.cs index efae653..3d7c5d3 100644 --- a/FauCap/Converter.cs +++ b/FauCap/Converter.cs @@ -47,12 +47,13 @@ public List PcapFileToFaucap(string InFile) return Sessions; } - void OnPacketArrival(object sender, CaptureEventArgs e) + void OnPacketArrival(object sender, PacketCapture e) { - if (e.Packet.LinkLayerType == PacketDotNet.LinkLayers.Ethernet || e.Packet.LinkLayerType == PacketDotNet.LinkLayers.Null) + var linkLayerType = ((ICaptureDevice)sender).LinkType; + if (linkLayerType == PacketDotNet.LinkLayers.Ethernet || linkLayerType == PacketDotNet.LinkLayers.Null) { - var packet = PacketDotNet.Packet.ParsePacket(e.Packet.LinkLayerType, e.Packet.Data); + var packet = PacketDotNet.Packet.ParsePacket(linkLayerType, e.Data.ToArray()); var udpPacket = (PacketDotNet.UdpPacket)packet.Extract(); @@ -61,7 +62,7 @@ void OnPacketArrival(object sender, CaptureEventArgs e) if (udpPacket == null) { return; } byte[] data = udpPacket.PayloadData; - DateTime time = e.Packet.Timeval.Date; + DateTime time = e.Header.Timeval.Date; if (IsHandshakePacket(data)) { switch (Handshake.ReadName(data)) diff --git a/FauCap/FauCap.csproj b/FauCap/FauCap.csproj index b655e09..a1784c7 100644 --- a/FauCap/FauCap.csproj +++ b/FauCap/FauCap.csproj @@ -2,21 +2,21 @@ Exe - netcoreapp3.1 + net8.0 freakbyte TheMeldingWars https://github.com/themeldingwars/FauCap icon.ico FauCap - 1.12.0.0 - 1.14.0.0 + 1.15.0.0 + 1.15.0.0 true - 1.14.0.0 + 1.15.0.0 - + diff --git a/FauCap/PacketUtil.cs b/FauCap/PacketUtil.cs index 108ecdc..b0aeee4 100644 --- a/FauCap/PacketUtil.cs +++ b/FauCap/PacketUtil.cs @@ -8,7 +8,7 @@ namespace FauCap { static class PacketUtil { - public static bool IsControlPacket(Span data) + public static bool IsControlPacket(ReadOnlySpan data) { if (data.Length >= 4) { @@ -17,7 +17,7 @@ public static bool IsControlPacket(Span data) return false; } - public static bool IsHandshakePacket(Span data) + public static bool IsHandshakePacket(ReadOnlySpan data) { if (data.Length > 8) { @@ -39,27 +39,27 @@ public static bool IsHandshakePacket(Span data) public static class Handshake { - public static string ReadName(Span data) + public static string ReadName(ReadOnlySpan data) { return Encoding.ASCII.GetString(data.Slice(4, 4)); } - public static uint ReadProtocolVersion(Span data) + public static uint ReadProtocolVersion(ReadOnlySpan data) { return MemoryMarshal.Read(data.Slice(8, 4)); } - public static uint ReadSocketId(Span data) + public static uint ReadSocketId(ReadOnlySpan data) { return MemoryMarshal.Read(data.Slice(8, 4)); } - public static ushort ReadStreamingProtocol(Span data) + public static ushort ReadStreamingProtocol(ReadOnlySpan data) { return MemoryMarshal.Read(data.Slice(12, 2)); } - public static ushort ReadSequenceStart(Span data) + public static ushort ReadSequenceStart(ReadOnlySpan data) { return ReadUInt16BigEndian(data.Slice(8, 2)); } - public static ushort ReadGameServerPort(Span data) + public static ushort ReadGameServerPort(ReadOnlySpan data) { return ReadUInt16BigEndian(data.Slice(10, 2)); } diff --git a/FauCapParser/FauCapParser.csproj b/FauCapParser/FauCapParser.csproj index de90eb9..0049e1e 100644 --- a/FauCapParser/FauCapParser.csproj +++ b/FauCapParser/FauCapParser.csproj @@ -3,12 +3,12 @@ https://github.com/themeldingwars/FauCap 9 - netstandard2.1 + netstandard2.1;net8.0 true TheMeldingWars - 1.14.0.0 - 1.12.0.0 - 1.14.0.0 + 1.15.0.0 + 1.15.0.0 + 1.15.0.0 diff --git a/Test/Test.csproj b/Test/Test.csproj index 42d82fb..198a3a8 100644 --- a/Test/Test.csproj +++ b/Test/Test.csproj @@ -2,7 +2,7 @@ Exe - net5.0 + net8.0 @@ -11,7 +11,7 @@ - + diff --git a/publish.bat b/publish.bat index 45bb5d8..468bbb5 100644 --- a/publish.bat +++ b/publish.bat @@ -1,11 +1,11 @@ dotnet clean dotnet restore dotnet build -c release -dotnet publish -c release -r win7-x64 -o FauCap/bin/dist/win-x64 --self-contained false +dotnet publish -c release -r win-x64 -o FauCap/bin/dist/win-x64 --self-contained false dotnet publish -c release -r linux-x64 -o FauCap/bin/dist/linux-x64 --self-contained false dotnet publish -c release -r osx-x64 -o FauCap/bin/dist/osx-x64 --self-contained false REM publish the package to github nuget dotnet pack --configuration Release -dotnet nuget push "FauCap/bin/Release/FauCap.1.1.0.nupkg" --source "tmw" -dotnet nuget push "FauCapParser/bin/Release/FauCapParser.1.0.0.nupkg" --source "tmw" \ No newline at end of file +dotnet nuget push "FauCap/bin/Release/FauCap.1.15.0.0.nupkg" --source "tmw" +dotnet nuget push "FauCapParser/bin/Release/FauCapParser.1.15.0.0.nupkg" --source "tmw" \ No newline at end of file