]> git.deb.at Git - rhonda/impostor.git/commitdiff
Make ban for cheating configurable
authorAeonLucid <aeonlucid@outlook.com>
Sun, 25 Oct 2020 22:13:09 +0000 (23:13 +0100)
committerAeonLucid <aeonlucid@outlook.com>
Sun, 25 Oct 2020 22:13:09 +0000 (23:13 +0100)
docs/Server-configuration.md
src/Impostor.Server/Config/AntiCheatConfig.cs [new file with mode: 0644]
src/Impostor.Server/Config/DebugConfig.cs
src/Impostor.Server/Net/Client.cs
src/Impostor.Server/Program.cs
src/Impostor.Server/Recorder/ClientRecorder.cs
src/Impostor.Server/config-full.json
src/Impostor.Server/config.json

index 12c5a5a3fda119a7084960b520c926e20455160d..1205d06f8dce4531290288225cb824fa9720b767 100644 (file)
@@ -17,6 +17,7 @@ Server:PublicIp=127.0.0.1
 Server:PublicPort=22023
 Server:ListenIp=0.0.0.0
 Server:listenPort=22023
+AntiCheat:BanIpFromGame=true
 ServerRedirector:Enabled=false
 ServerRedirector:Master=true
 ServerRedirector:Locator:Redis=127.0.0.1.6379
@@ -36,6 +37,7 @@ IMPOSTOR_Server__PublicIp=127.0.0.1
 IMPOSTOR_Server__PublicPort=22023
 IMPOSTOR_Server__ListenIp=0.0.0.0
 IMPOSTOR_Server__listenPort=22023
+IMPOSTOR_AntiCheat__BanIpFromGame=true
 IMPOSTOR_ServerRedirector__Enabled=false
 IMPOSTOR_ServerRedirector__Master=true
 IMPOSTOR_ServerRedirector__Locator__Redis=127.0.0.1.6379
diff --git a/src/Impostor.Server/Config/AntiCheatConfig.cs b/src/Impostor.Server/Config/AntiCheatConfig.cs
new file mode 100644 (file)
index 0000000..f4807e7
--- /dev/null
@@ -0,0 +1,9 @@
+namespace Impostor.Server.Config
+{
+    public class AntiCheatConfig
+    {
+        public const string Section = "AntiCheat";
+
+        public bool BanIpFromGame { get; set; } = true;
+    }
+}
\ No newline at end of file
index 1758366acb69710dd838e6c677cc7adbdbada0fa..630d1b488a2f494aec8591634639bd41ef9c87b0 100644 (file)
@@ -5,6 +5,7 @@
         public const string Section = "Debug";
 
         public bool GameRecorderEnabled { get; set; }
+
         public string GameRecorderPath { get; set; }
     }
 }
\ No newline at end of file
index b6fe4f0307b9b32ba79c083028e2481bc113567b..189ae4d4617bd9648b87fee14ad3b89895298583 100644 (file)
@@ -9,21 +9,25 @@ using Impostor.Api.Net.Messages.C2S;
 using Impostor.Api.Net.Messages.S2C;
 using Impostor.Hazel;
 using Impostor.Server.Config;
+using Impostor.Server.Net.Hazel;
 using Impostor.Server.Net.Manager;
 using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
 
 namespace Impostor.Server.Net
 {
     internal class Client : ClientBase
     {
         private readonly ILogger<Client> _logger;
+        private readonly AntiCheatConfig _antiCheatConfig;
         private readonly ClientManager _clientManager;
         private readonly GameManager _gameManager;
 
-        public Client(ILogger<Client> logger, ClientManager clientManager, GameManager gameManager, string name, IHazelConnection connection)
+        public Client(ILogger<Client> logger, IOptions<AntiCheatConfig> antiCheatOptions, ClientManager clientManager, GameManager gameManager, string name, IHazelConnection connection)
             : base(name, connection)
         {
             _logger = logger;
+            _antiCheatConfig = antiCheatOptions.Value;
             _clientManager = clientManager;
             _gameManager = gameManager;
         }
@@ -172,7 +176,10 @@ namespace Impostor.Server.Net
                     }
                     catch (ImpostorCheatException e)
                     {
-                        Player.Game.BanIp(Connection.EndPoint.Address);
+                        if (_antiCheatConfig.BanIpFromGame)
+                        {
+                            Player.Game.BanIp(Connection.EndPoint.Address);
+                        }
 
                         await DisconnectAsync(DisconnectReason.Hacking, e.Message);
                     }
index 54c49690decc12f14f82286ccd8dbdbb4463fae6..f699e739df03743644893f74437c79e4d169c2fc 100644 (file)
@@ -92,6 +92,7 @@ namespace Impostor.Server
                         .Get<ServerRedirectorConfig>() ?? new ServerRedirectorConfig();
 
                     services.Configure<DebugConfig>(host.Configuration.GetSection(DebugConfig.Section));
+                    services.Configure<AntiCheatConfig>(host.Configuration.GetSection(AntiCheatConfig.Section));
                     services.Configure<ServerConfig>(host.Configuration.GetSection(ServerConfig.Section));
                     services.Configure<ServerRedirectorConfig>(host.Configuration.GetSection(ServerRedirectorConfig.Section));
 
index 90d644ffb0c629fb2d6c59be29ad0b7d7b1a53d9..94b320edc85e2deaef3ef1601279aff938d88e5f 100644 (file)
@@ -1,9 +1,11 @@
 using System.Threading.Tasks;
 using Impostor.Api.Net.Messages;
+using Impostor.Server.Config;
 using Impostor.Server.Net;
 using Impostor.Server.Net.Hazel;
 using Impostor.Server.Net.Manager;
 using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
 
 namespace Impostor.Server.Recorder
 {
@@ -14,8 +16,8 @@ namespace Impostor.Server.Recorder
         private bool _createdGame;
         private bool _recordAfter;
 
-        public ClientRecorder(ILogger<Client> logger, ClientManager clientManager, GameManager gameManager, string name, HazelConnection connection, PacketRecorder recorder)
-            : base(logger, clientManager, gameManager, name, connection)
+        public ClientRecorder(ILogger<Client> logger, IOptions<AntiCheatConfig> antiCheatOptions, ClientManager clientManager, GameManager gameManager, string name, HazelConnection connection, PacketRecorder recorder)
+            : base(logger, antiCheatOptions, clientManager, gameManager, name, connection)
         {
             _recorder = recorder;
             _isFirst = true;
index e509ca039293de36f3251a32660cf082943e9e58..dfee1bcbfc7d5b373b4834e0c40ac3d6c52c41cc 100644 (file)
@@ -5,6 +5,9 @@
     "ListenIp": "0.0.0.0",
     "ListenPort": 22023
   },
+  "AntiCheat": {
+    "BanIpFromGame": true
+  },
   "ServerRedirector": {
     "Enabled": false,
     "Master": true,
index 474569694248d40d51e2d8e3920e94e88c2b43fc..d477c74526cac56b6157a1a5442f4e92e4f38758 100644 (file)
@@ -5,8 +5,7 @@
     "ListenIp": "0.0.0.0",
     "ListenPort": 22023
   },
-  "Debug": {
-    "GameRecorderEnabled": false,
-    "GameRecorderPath": ""
+  "AntiCheat": {
+    "BanIpFromGame": true
   }
 }
\ No newline at end of file