mirror of
https://github.com/Impostor/Impostor.git
synced 2026-10-20 01:46:11 +00:00
Make ban for cheating configurable
This commit is contained in:
1 parent
a6b3cd10f4
commit
93394e7e77
8 files changed
+31
-7
No files matched your search
@@ -17,6 +17,7 @@ Server:PublicIp=127.0.0.1
|
|||||||
Server:PublicPort=22023
|
Server:PublicPort=22023
|
||||||
Server:ListenIp=0.0.0.0
|
Server:ListenIp=0.0.0.0
|
||||||
Server:listenPort=22023
|
Server:listenPort=22023
|
||||||
|
AntiCheat:BanIpFromGame=true
|
||||||
ServerRedirector:Enabled=false
|
ServerRedirector:Enabled=false
|
||||||
ServerRedirector:Master=true
|
ServerRedirector:Master=true
|
||||||
ServerRedirector:Locator:Redis=127.0.0.1.6379
|
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__PublicPort=22023
|
||||||
IMPOSTOR_Server__ListenIp=0.0.0.0
|
IMPOSTOR_Server__ListenIp=0.0.0.0
|
||||||
IMPOSTOR_Server__listenPort=22023
|
IMPOSTOR_Server__listenPort=22023
|
||||||
|
IMPOSTOR_AntiCheat__BanIpFromGame=true
|
||||||
IMPOSTOR_ServerRedirector__Enabled=false
|
IMPOSTOR_ServerRedirector__Enabled=false
|
||||||
IMPOSTOR_ServerRedirector__Master=true
|
IMPOSTOR_ServerRedirector__Master=true
|
||||||
IMPOSTOR_ServerRedirector__Locator__Redis=127.0.0.1.6379
|
IMPOSTOR_ServerRedirector__Locator__Redis=127.0.0.1.6379
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Impostor.Server.Config
|
||||||
|
{
|
||||||
|
public class AntiCheatConfig
|
||||||
|
{
|
||||||
|
public const string Section = "AntiCheat";
|
||||||
|
|
||||||
|
public bool BanIpFromGame { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@
|
|||||||
public const string Section = "Debug";
|
public const string Section = "Debug";
|
||||||
|
|
||||||
public bool GameRecorderEnabled { get; set; }
|
public bool GameRecorderEnabled { get; set; }
|
||||||
|
|
||||||
public string GameRecorderPath { get; set; }
|
public string GameRecorderPath { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,21 +9,25 @@ using Impostor.Api.Net.Messages.C2S;
|
|||||||
using Impostor.Api.Net.Messages.S2C;
|
using Impostor.Api.Net.Messages.S2C;
|
||||||
using Impostor.Hazel;
|
using Impostor.Hazel;
|
||||||
using Impostor.Server.Config;
|
using Impostor.Server.Config;
|
||||||
|
using Impostor.Server.Net.Hazel;
|
||||||
using Impostor.Server.Net.Manager;
|
using Impostor.Server.Net.Manager;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Impostor.Server.Net
|
namespace Impostor.Server.Net
|
||||||
{
|
{
|
||||||
internal class Client : ClientBase
|
internal class Client : ClientBase
|
||||||
{
|
{
|
||||||
private readonly ILogger<Client> _logger;
|
private readonly ILogger<Client> _logger;
|
||||||
|
private readonly AntiCheatConfig _antiCheatConfig;
|
||||||
private readonly ClientManager _clientManager;
|
private readonly ClientManager _clientManager;
|
||||||
private readonly GameManager _gameManager;
|
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)
|
: base(name, connection)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_antiCheatConfig = antiCheatOptions.Value;
|
||||||
_clientManager = clientManager;
|
_clientManager = clientManager;
|
||||||
_gameManager = gameManager;
|
_gameManager = gameManager;
|
||||||
}
|
}
|
||||||
@@ -172,7 +176,10 @@ namespace Impostor.Server.Net
|
|||||||
}
|
}
|
||||||
catch (ImpostorCheatException e)
|
catch (ImpostorCheatException e)
|
||||||
{
|
{
|
||||||
Player.Game.BanIp(Connection.EndPoint.Address);
|
if (_antiCheatConfig.BanIpFromGame)
|
||||||
|
{
|
||||||
|
Player.Game.BanIp(Connection.EndPoint.Address);
|
||||||
|
}
|
||||||
|
|
||||||
await DisconnectAsync(DisconnectReason.Hacking, e.Message);
|
await DisconnectAsync(DisconnectReason.Hacking, e.Message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ namespace Impostor.Server
|
|||||||
.Get<ServerRedirectorConfig>() ?? new ServerRedirectorConfig();
|
.Get<ServerRedirectorConfig>() ?? new ServerRedirectorConfig();
|
||||||
|
|
||||||
services.Configure<DebugConfig>(host.Configuration.GetSection(DebugConfig.Section));
|
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<ServerConfig>(host.Configuration.GetSection(ServerConfig.Section));
|
||||||
services.Configure<ServerRedirectorConfig>(host.Configuration.GetSection(ServerRedirectorConfig.Section));
|
services.Configure<ServerRedirectorConfig>(host.Configuration.GetSection(ServerRedirectorConfig.Section));
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Impostor.Api.Net.Messages;
|
using Impostor.Api.Net.Messages;
|
||||||
|
using Impostor.Server.Config;
|
||||||
using Impostor.Server.Net;
|
using Impostor.Server.Net;
|
||||||
using Impostor.Server.Net.Hazel;
|
using Impostor.Server.Net.Hazel;
|
||||||
using Impostor.Server.Net.Manager;
|
using Impostor.Server.Net.Manager;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Impostor.Server.Recorder
|
namespace Impostor.Server.Recorder
|
||||||
{
|
{
|
||||||
@@ -14,8 +16,8 @@ namespace Impostor.Server.Recorder
|
|||||||
private bool _createdGame;
|
private bool _createdGame;
|
||||||
private bool _recordAfter;
|
private bool _recordAfter;
|
||||||
|
|
||||||
public ClientRecorder(ILogger<Client> logger, ClientManager clientManager, GameManager gameManager, string name, HazelConnection connection, PacketRecorder recorder)
|
public ClientRecorder(ILogger<Client> logger, IOptions<AntiCheatConfig> antiCheatOptions, ClientManager clientManager, GameManager gameManager, string name, HazelConnection connection, PacketRecorder recorder)
|
||||||
: base(logger, clientManager, gameManager, name, connection)
|
: base(logger, antiCheatOptions, clientManager, gameManager, name, connection)
|
||||||
{
|
{
|
||||||
_recorder = recorder;
|
_recorder = recorder;
|
||||||
_isFirst = true;
|
_isFirst = true;
|
||||||
|
|||||||
@@ -5,6 +5,9 @@
|
|||||||
"ListenIp": "0.0.0.0",
|
"ListenIp": "0.0.0.0",
|
||||||
"ListenPort": 22023
|
"ListenPort": 22023
|
||||||
},
|
},
|
||||||
|
"AntiCheat": {
|
||||||
|
"BanIpFromGame": true
|
||||||
|
},
|
||||||
"ServerRedirector": {
|
"ServerRedirector": {
|
||||||
"Enabled": false,
|
"Enabled": false,
|
||||||
"Master": true,
|
"Master": true,
|
||||||
|
|||||||
@@ -5,8 +5,7 @@
|
|||||||
"ListenIp": "0.0.0.0",
|
"ListenIp": "0.0.0.0",
|
||||||
"ListenPort": 22023
|
"ListenPort": 22023
|
||||||
},
|
},
|
||||||
"Debug": {
|
"AntiCheat": {
|
||||||
"GameRecorderEnabled": false,
|
"BanIpFromGame": true
|
||||||
"GameRecorderPath": ""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user