~ruther/NosSmooth

8c094d4604a7c0834cde6c821592beafb844fe0c — Rutherther 2 years ago a29b2cd
feat(pcap): delete only not seen connections
M Pcap/NosSmooth.Pcap/ConnectionData.cs => Pcap/NosSmooth.Pcap/ConnectionData.cs +7 -1
@@ 25,4 25,10 @@ public record ConnectionData
    int DestinationPort,
    List<byte[]> SniffedData,
    DateTimeOffset FirstObservedAt
);
\ No newline at end of file
)
{
    /// <summary>
    /// Gets or sets the date time offset at which last data were sniffed.
    /// </summary>
    public DateTimeOffset LastReceivedAt { get; set; }
}
\ No newline at end of file

M Pcap/NosSmooth.Pcap/PcapNostaleManager.cs => Pcap/NosSmooth.Pcap/PcapNostaleManager.cs +2 -1
@@ 205,6 205,7 @@ public class PcapNostaleManager
        }

        var data = _connections[tcpConnection];
        data.LastReceivedAt = DateTimeOffset.Now;
        if (data.SniffedData.Count < 5 && tcpPacket.PayloadData.Length < 500
            && data.FirstObservedAt.AddMilliseconds(_options.CleanSniffedDataInterval) > DateTimeOffset.Now)
        {


@@ 247,7 248,7 @@ public class PcapNostaleManager
                _connections.TryRemove(connectionData);
            }

            if (connectionData.Value.SniffedData.Count > 0 && connectionData.Value.FirstObservedAt.AddMilliseconds
            if (connectionData.Value.SniffedData.Count > 0 && connectionData.Value.LastReceivedAt.AddMilliseconds
                    (_options.CleanSniffedDataInterval) < DateTimeOffset.Now)
            {
                connectionData.Value.SniffedData.Clear();

M Pcap/NosSmooth.Pcap/PcapNostaleOptions.cs => Pcap/NosSmooth.Pcap/PcapNostaleOptions.cs +2 -2
@@ 22,7 22,7 @@ public class PcapNostaleOptions
    public long CleanSniffedDataInterval { get; set; } = 10 * 1000;

    /// <summary>
    /// Gets or sets the time tcp connection should be forgotten in milliseconds. Default 10 minutes.
    /// Gets or sets the time tcp connection should be forgotten in milliseconds. Default 1 minute.
    /// </summary>
    public long ForgetConnectionInterval { get; set; } = 10 * 60 * 1000;
    public long ForgetConnectionInterval { get; set; } = 60 * 1000;
}
\ No newline at end of file

Do not follow this link