update api controller to support actually filtering events by server

fix up stats manager async semaphore wait
add new shared guids
fix regex parsing with empty name
This commit is contained in:
RaidMax 2019-08-28 13:45:53 -05:00
parent 11d2df1fe8
commit 27a05ce6db
4 changed files with 20 additions and 16 deletions

View File

@ -38,7 +38,7 @@ namespace IW4MAdmin.Application.RconParsers
}, },
}; };
Configuration.Status.Pattern = @"^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){8,32}|(?:[a-z]|[0-9]){8,32}|bot[0-9]+|(?:[0-9]+)) +(.{0,32}) +([0-9]+) +(\d+\.\d+\.\d+.\d+\:-*\d{1,5}|0+.0+:-*\d{1,5}|loopback) +(-*[0-9]+) +([0-9]+) *$"; Configuration.Status.Pattern = @"^ *([0-9]+) +-?([0-9]+) +((?:[A-Z]+|[0-9]+)) +((?:[a-z]|[0-9]){8,32}|(?:[a-z]|[0-9]){8,32}|bot[0-9]+|(?:[0-9]+)) *(.{0,32}) +([0-9]+) +(\d+\.\d+\.\d+.\d+\:-*\d{1,5}|0+.0+:-*\d{1,5}|loopback) +(-*[0-9]+) +([0-9]+) *$";
Configuration.Status.AddMapping(ParserRegex.GroupType.RConClientNumber, 1); Configuration.Status.AddMapping(ParserRegex.GroupType.RConClientNumber, 1);
Configuration.Status.AddMapping(ParserRegex.GroupType.RConScore, 2); Configuration.Status.AddMapping(ParserRegex.GroupType.RConScore, 2);
Configuration.Status.AddMapping(ParserRegex.GroupType.RConPing, 3); Configuration.Status.AddMapping(ParserRegex.GroupType.RConPing, 3);

View File

@ -16,12 +16,13 @@ var plugin = {
gameEvent.Origin.NetworkId === 3150799945255696069 || gameEvent.Origin.NetworkId === 3150799945255696069 ||
gameEvent.Origin.NetworkId === 5859032128210324569 || gameEvent.Origin.NetworkId === 5859032128210324569 ||
gameEvent.Origin.NetworkId === 2908745942105435771 || gameEvent.Origin.NetworkId === 2908745942105435771 ||
gameEvent.Origin.NetworkId === -6492697076432899192) { gameEvent.Origin.NetworkId === -6492697076432899192 ||
gameEvent.Origin.NetworkId === 1145760003260769995 ||
gameEvent.Origin.NetworkId === -7102887284306116957) {
gameEvent.Origin.Kick('Your GUID is generic. Delete players/guids.dat and rejoin', _IW4MAdminClient); gameEvent.Origin.Kick('Your GUID is generic. Delete players/guids.dat and rejoin', _IW4MAdminClient);
} }
} }
}, },
onLoadAsync: function (manager) { onLoadAsync: function (manager) {
}, },

View File

@ -547,12 +547,14 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
hit.DeathType == IW4Info.MeansOfDeath.MOD_RIFLE_BULLET || hit.DeathType == IW4Info.MeansOfDeath.MOD_RIFLE_BULLET ||
hit.DeathType == IW4Info.MeansOfDeath.MOD_HEAD_SHOT) hit.DeathType == IW4Info.MeansOfDeath.MOD_HEAD_SHOT)
{ {
clientStats.HitLocations.Single(hl => hl.Location == hit.HitLoc).HitCount += 1; clientStats.HitLocations.First(hl => hl.Location == hit.HitLoc).HitCount += 1;
} }
if (clientStats.SessionKills % Detection.MAX_TRACKED_HIT_COUNT == 0) if (clientStats.SessionKills % Detection.MAX_TRACKED_HIT_COUNT == 0)
{ {
await OnProcessingPenalty.WaitAsync();
await SaveClientStats(clientStats); await SaveClientStats(clientStats);
OnProcessingPenalty.Release(1);
} }
if (hit.IsKillstreakKill) if (hit.IsKillstreakKill)
@ -564,7 +566,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
{ {
if (Plugin.Config.Configuration().StoreClientKills) if (Plugin.Config.Configuration().StoreClientKills)
{ {
OnProcessingPenalty.Wait(); await OnProcessingPenalty.WaitAsync();
_hitCache.Add(hit); _hitCache.Add(hit);
if (_hitCache.Count > Detection.MAX_TRACKED_HIT_COUNT) if (_hitCache.Count > Detection.MAX_TRACKED_HIT_COUNT)
@ -581,10 +583,11 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
OnProcessingPenalty.Release(1); OnProcessingPenalty.Release(1);
} }
if (Plugin.Config.Configuration().EnableAntiCheat && !attacker.IsBot && attacker.ClientId != victim.ClientId) if (Plugin.Config.Configuration().EnableAntiCheat && !attacker.IsBot && attacker.ClientId != victim.ClientId)
{ {
DetectionPenaltyResult result = new DetectionPenaltyResult() { ClientPenalty = EFPenalty.PenaltyType.Any }; DetectionPenaltyResult result = new DetectionPenaltyResult() { ClientPenalty = EFPenalty.PenaltyType.Any };
await OnProcessingPenalty.WaitAsync();
#if DEBUG #if DEBUG
if (clientDetection.TrackedHits.Count > 0) if (clientDetection.TrackedHits.Count > 0)
#else #else
@ -593,7 +596,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
{ {
while (clientDetection.TrackedHits.Count > 0) while (clientDetection.TrackedHits.Count > 0)
{ {
await OnProcessingPenalty.WaitAsync();
var oldestHit = clientDetection.TrackedHits.OrderBy(_hits => _hits.TimeOffset).First(); var oldestHit = clientDetection.TrackedHits.OrderBy(_hits => _hits.TimeOffset).First();
clientDetection.TrackedHits.Remove(oldestHit); clientDetection.TrackedHits.Remove(oldestHit);
@ -611,12 +614,9 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
if (result.ClientPenalty == EFPenalty.PenaltyType.Ban) if (result.ClientPenalty == EFPenalty.PenaltyType.Ban)
{ {
OnProcessingPenalty.Release(1);
break; break;
} }
} }
OnProcessingPenalty.Release(1);
} }
} }
@ -624,6 +624,8 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
{ {
clientDetection.TrackedHits.Add(hit); clientDetection.TrackedHits.Add(hit);
} }
OnProcessingPenalty.Release(1);
} }
} }
@ -634,7 +636,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
if (OnProcessingPenalty.CurrentCount == 0) if (OnProcessingPenalty.CurrentCount == 0)
{ {
OnProcessingPenalty.Release(); OnProcessingPenalty.Release(1);
} }
} }
} }

View File

@ -20,18 +20,19 @@ namespace WebfrontCore.Controllers.API
} }
[HttpGet] [HttpGet]
public IActionResult Status(int id) public IActionResult Status(long? id)
{ {
var serverInfo = Manager.GetServers() var serverInfo = Manager.GetServers()
.Select(server => new .Select(server => new
{ {
Id = server.EndPoint, Id = server.EndPoint,
IsOnline = !server.Throttled,
Name = server.Hostname, Name = server.Hostname,
MaxPlayers = server.MaxClients, MaxPlayers = server.MaxClients,
CurrentPlayers = server.GetClientsAsList().Count, CurrentPlayers = server.GetClientsAsList().Count,
Map = server.CurrentMap, Map = server.CurrentMap,
GameMode = server.Gametype, GameMode = server.Gametype,
Port = server.Port, server.Port,
Game = server.GameName.ToString(), Game = server.GameName.ToString(),
Players = server.GetClientsAsList() Players = server.GetClientsAsList()
.Select(player => new .Select(player => new
@ -46,7 +47,7 @@ namespace WebfrontCore.Controllers.API
}) })
}); });
if (id != 0) if (id != null)
{ {
serverInfo = serverInfo.Where(server => server.Id == id); serverInfo = serverInfo.Where(server => server.Id == id);
} }