mirror of
https://github.com/daffyyyy/CS2-SimpleAdmin.git
synced 2026-02-17 10:31:01 +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">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Database\Migrations\012_AddUpdatedAtColumnToSaBansTable.sql">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</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<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 bool _isInitialized;
|
||||
@@ -132,7 +133,8 @@ internal class CacheManager
|
||||
return _banCache.Values.Any(b =>
|
||||
b.Status == "ACTIVE" &&
|
||||
!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) =>
|
||||
@@ -143,7 +145,8 @@ internal class CacheManager
|
||||
b.PlayerSteamId.Equals(steamId, StringComparison.OrdinalIgnoreCase)) ||
|
||||
(ipAddress != null &&
|
||||
b.PlayerIp != null &&
|
||||
b.PlayerIp.Equals(ipAddress, StringComparison.OrdinalIgnoreCase))
|
||||
b.PlayerIp.Equals(ipAddress, StringComparison.OrdinalIgnoreCase) &&
|
||||
!_cachedIgnoredIps.Contains(ipAddress))
|
||||
));
|
||||
|
||||
public bool IsPlayerOrAnyIpBanned(ulong steamId)
|
||||
@@ -155,8 +158,9 @@ internal class CacheManager
|
||||
{
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user