Add per game anticheat configuration option for issue #203

This commit is contained in:
RaidMax 2022-06-02 18:24:13 -05:00
parent 26853a0005
commit e459b2fcde
2 changed files with 19 additions and 4 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using static IW4MAdmin.Plugins.Stats.Cheat.Detection;
using static SharedLibraryCore.Server;
@ -7,7 +8,9 @@ namespace Stats.Config
public class AnticheatConfiguration
{
public bool Enable { get; set; }
[Obsolete]
public IDictionary<long, DetectionType[]> ServerDetectionTypes { get; set; } = new Dictionary<long, DetectionType[]>();
public IDictionary<Game, DetectionType[]> GameDetectionTypes { get; set; } = new Dictionary<Game, DetectionType[]>();
public IList<long> IgnoredClientIds { get; set; } = new List<long>();
public IDictionary<Game, IDictionary<DetectionType, string[]>> IgnoredDetectionSpecification{ get; set; } = new Dictionary<Game, IDictionary<DetectionType, string[]>>
{

View File

@ -818,7 +818,8 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
private bool ShouldUseDetection(Server server, DetectionType detectionType, long clientId)
{
var detectionTypes = Plugin.Config.Configuration().AnticheatConfiguration.ServerDetectionTypes;
var serverDetectionTypes = Plugin.Config.Configuration().AnticheatConfiguration.ServerDetectionTypes;
var gameDetectionTypes = Plugin.Config.Configuration().AnticheatConfiguration.GameDetectionTypes;
var ignoredClients = Plugin.Config.Configuration().AnticheatConfiguration.IgnoredClientIds;
if (ignoredClients.Contains(clientId))
@ -826,10 +827,9 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
return false;
}
try
{
if (!detectionTypes[server.EndPoint].Contains(detectionType))
if (!serverDetectionTypes[server.EndPoint].Contains(detectionType))
{
return false;
}
@ -839,6 +839,18 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
{
}
try
{
if (!gameDetectionTypes[server.GameName].Contains(detectionType))
{
return false;
}
}
catch
{
// ignored
}
return true;
}