mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-03-07 23:37:56 +00:00
1.7.7-alpha-fix
- Added missing migration - Added missing ignoredips
This commit is contained in:
@@ -26,6 +26,9 @@
|
|||||||
<None Update="Database\Migrations\010_CreateWarnsTable.sql">
|
<None Update="Database\Migrations\010_CreateWarnsTable.sql">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="Database\Migrations\012_AddUpdatedAtColumnToSaBansTable.sql">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `sa_bans` ADD COLUMN `updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP AFTER `status`;
|
||||||
@@ -9,6 +9,7 @@ internal class CacheManager
|
|||||||
{
|
{
|
||||||
private readonly ConcurrentDictionary<int, BanRecord> _banCache = new();
|
private readonly ConcurrentDictionary<int, BanRecord> _banCache = new();
|
||||||
private readonly ConcurrentDictionary<ulong, (HashSet<string> ips, DateTime used_at)> _playerIpsCache = new();
|
private readonly ConcurrentDictionary<ulong, (HashSet<string> ips, DateTime used_at)> _playerIpsCache = new();
|
||||||
|
private readonly HashSet<string> _cachedIgnoredIps = [..CS2_SimpleAdmin.Instance.Config.OtherSettings.IgnoredIps];
|
||||||
|
|
||||||
private DateTime _lastUpdateTime = DateTime.MinValue;
|
private DateTime _lastUpdateTime = DateTime.MinValue;
|
||||||
private bool _isInitialized;
|
private bool _isInitialized;
|
||||||
@@ -132,7 +133,8 @@ internal class CacheManager
|
|||||||
return _banCache.Values.Any(b =>
|
return _banCache.Values.Any(b =>
|
||||||
b.Status == "ACTIVE" &&
|
b.Status == "ACTIVE" &&
|
||||||
!string.IsNullOrEmpty(b.PlayerIp) &&
|
!string.IsNullOrEmpty(b.PlayerIp) &&
|
||||||
b.PlayerIp.Equals(ipAddress, StringComparison.OrdinalIgnoreCase));
|
b.PlayerIp.Equals(ipAddress, StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!_cachedIgnoredIps.Contains(ipAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsPlayerBanned(string? steamId, string? ipAddress) =>
|
public bool IsPlayerBanned(string? steamId, string? ipAddress) =>
|
||||||
@@ -143,7 +145,8 @@ internal class CacheManager
|
|||||||
b.PlayerSteamId.Equals(steamId, StringComparison.OrdinalIgnoreCase)) ||
|
b.PlayerSteamId.Equals(steamId, StringComparison.OrdinalIgnoreCase)) ||
|
||||||
(ipAddress != null &&
|
(ipAddress != null &&
|
||||||
b.PlayerIp != null &&
|
b.PlayerIp != null &&
|
||||||
b.PlayerIp.Equals(ipAddress, StringComparison.OrdinalIgnoreCase))
|
b.PlayerIp.Equals(ipAddress, StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
!_cachedIgnoredIps.Contains(ipAddress))
|
||||||
));
|
));
|
||||||
|
|
||||||
public bool IsPlayerOrAnyIpBanned(ulong steamId)
|
public bool IsPlayerOrAnyIpBanned(ulong steamId)
|
||||||
@@ -156,7 +159,8 @@ internal class CacheManager
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _playerIpsCache.TryGetValue(steamId, out var ipList) && ipList.ips.Any(IsIpBanned);
|
return _playerIpsCache.TryGetValue(steamId, out var ipList) && ipList.ips.Any(ip =>
|
||||||
|
!_cachedIgnoredIps.Contains(ip) && IsIpBanned(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasIpForPlayer(ulong steamId, string ipAddress)
|
public bool HasIpForPlayer(ulong steamId, string ipAddress)
|
||||||
|
|||||||
Reference in New Issue
Block a user