From 3f0d3a8d38a2dd5ee84a35164bc37c039e41e4af Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 11 Feb 2023 22:15:24 +0100 Subject: [PATCH] feat(pcap): keep last pcap live device in client --- Pcap/NosSmooth.Pcap/PcapNostaleClient.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Pcap/NosSmooth.Pcap/PcapNostaleClient.cs b/Pcap/NosSmooth.Pcap/PcapNostaleClient.cs index a624852..38fdf7d 100644 --- a/Pcap/NosSmooth.Pcap/PcapNostaleClient.cs +++ b/Pcap/NosSmooth.Pcap/PcapNostaleClient.cs @@ -40,7 +40,9 @@ public class PcapNostaleClient : BaseNostaleClient private CryptographyManager _crypto; private CancellationToken? _stoppingToken; private bool _running; + private LibPcapLiveDevice? _lastDevice; private TcpConnection _connection; + private long _lastPacketIndex; /// /// Initializes a new instance of the class. @@ -183,15 +185,18 @@ public class PcapNostaleClient : BaseNostaleClient /// /// Called when an associated packet has been obtained. /// + /// The device the packet was received at. /// The connection that obtained the packet. /// The raw payload data of the packet. - internal void OnPacketArrival(TcpConnection connection, byte[] payloadData) + internal void OnPacketArrival(LibPcapLiveDevice? device, TcpConnection connection, byte[] payloadData) { + _lastDevice = device; + string data; PacketSource source; bool containsPacketId = false; - if (connection.LocalAddr == _localAddr && connection.LocalPort == _localPort) + if (connection.LocalAddr == _connection.LocalAddr && connection.LocalPort == _connection.LocalPort) { // sent packet source = PacketSource.Client; if (_crypto.EncryptionKey == 0) @@ -236,6 +241,7 @@ public class PcapNostaleClient : BaseNostaleClient var linePacket = line; if (containsPacketId) { + _lastPacketIndex = int.Parse(line.Substring(0, line.IndexOf(' '))); linePacket = line.Substring(line.IndexOf(' ') + 1); } -- 2.48.1