Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CS2-SimpleAdmin/Managers/CacheManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ FROM sa_bans
if (CS2_SimpleAdmin.Instance.Config.OtherSettings.CheckMultiAccountsByIp)
{
// Optimization: Load IP history and build cache in single pass
var ipHistory = await connection.QueryAsync<(ulong steamid, string? name, uint address, DateTime used_at)>(
var ipHistory = await connection.QueryAsync<(ulong steamid, string? name, long address, DateTime used_at)>(
"SELECT steamid, name, address, used_at FROM sa_players_ips ORDER BY steamid, address, used_at DESC");

var unknownName = CS2_SimpleAdmin._localizer?["sa_unknown"] ?? "Unknown";
Expand All @@ -94,12 +94,12 @@ FROM sa_bans
currentSteamId = record.steamid;

// Only keep the latest timestamp for each IP
if (!latestIpTimestamps.TryGetValue(record.address, out var existingTimestamp) ||
if (!latestIpTimestamps.TryGetValue(((uint)(record.address & 0xFFFFFFFF)), out var existingTimestamp) ||
record.used_at > existingTimestamp)
{
latestIpTimestamps[record.address] = record.used_at;
latestIpTimestamps[((uint)(record.address & 0xFFFFFFFF))] = record.used_at;
currentIpSet.Add(new IpRecord(
record.address,
((uint)(record.address & 0xFFFFFFFF)),
record.used_at,
string.IsNullOrEmpty(record.name) ? unknownName : record.name
));
Expand Down Expand Up @@ -283,15 +283,15 @@ status AS Status

if (CS2_SimpleAdmin.Instance.Config.OtherSettings.CheckMultiAccountsByIp)
{
var ipHistory = (await connection.QueryAsync<(ulong steamid, string? name, uint address, DateTime used_at)>(
var ipHistory = (await connection.QueryAsync<(ulong steamid, string? name, long address, DateTime used_at)>(
"SELECT steamid, name, address, used_at FROM sa_players_ips WHERE used_at >= @lastUpdate ORDER BY used_at DESC LIMIT 300",
new { lastUpdate = _lastUpdateTime }));

foreach (var group in ipHistory.AsValueEnumerable().GroupBy(x => x.steamid))
{
var ipSet = new HashSet<IpRecord>(
group
.GroupBy(x => x.address)
.GroupBy(x => (uint)(x.address & 0xFFFFFFFF))
.Select(g =>
{
var latest = g.MaxBy(x => x.used_at);
Expand Down