public bool IpBanned(IPAddress ipAddress, out PlayerBan ban) { uint ip = ipAddress.ToUint32(); ban = BannedPlayers.FirstOrDefault(_ban => _ban.BanType == IdentityType.Ip && _ban.Ip == ip); return(ban != null && !ban.Expired()); }
public PlayerBan BanSteamId(ulong steamId, string reason = null, DateTime?expirationDate = null, string referenceName = null) { Config.RemoveExpiredBans(); if (SteamIdBanned(steamId, out var existingBan)) { return(existingBan); } PlayerBan ban = new PlayerBan(steamId, reason, expirationDate, referenceName); BannedPlayers.Add(ban); Config.Save(); return(ban); }
public PlayerBan BanIp(IPAddress ip, string reason = null, DateTime?expirationDate = null, string referenceName = null) { Config.RemoveExpiredBans(); uint uintIp = ip.ToUint32(); if (IpBanned(ip, out var existingBan)) { return(existingBan); } PlayerBan ban = new PlayerBan(uintIp, reason, expirationDate, referenceName); BannedPlayers.Add(ban); Config.Save(); return(ban); }
public void RemoveBan(PlayerBan ban) { BannedPlayers.Remove(ban); Config.Save(); }
public bool SteamIdBanned(ulong steamId, out PlayerBan ban) { ban = BannedPlayers.FirstOrDefault(_ban => _ban.BanType == IdentityType.SteamId && _ban.SteamId == steamId); return(ban != null && !ban.Expired()); }