IClientPlayer GetClientPlayer(int clientId);
+ /// <summary>
+ /// Adds an <see cref="IPAddress"/> to the ban list of this game.
+ /// Prevents all future joins from this <see cref="IPAddress"/>.
+ ///
+ /// This does not kick the player with that <see cref="IPAddress"/> from the lobby.
+ /// </summary>
+ /// <param name="ipAddress">
+ /// The <see cref="IPAddress"/> to ban.
+ /// </param>
+ void BanIp(IPAddress ipAddress);
+
/// <summary>
/// Syncs the internal <see cref="GameOptionsData"/> to all players.
/// Necessary to do if you modified it, otherwise it won't be used.
}
catch (ImpostorCheatException e)
{
+ Player.Game.BanIp(Connection.EndPoint.Address);
+
await DisconnectAsync(DisconnectReason.Hacking, e.Message);
}
internal partial class ClientPlayer : IClientPlayer
{
private readonly ILogger<ClientPlayer> _logger;
-
- private Timer _spawnTimeout;
+ private readonly Timer _spawnTimeout;
public ClientPlayer(ILogger<ClientPlayer> logger, ClientBase client, Game game)
{
using System.IO;
+using System.Net;
using System.Threading.Tasks;
using Impostor.Api.Games;
using Impostor.Api.Innersloth;
IGameNet IGame.GameNet => GameNet;
+ public void BanIp(IPAddress ipAddress)
+ {
+ _bannedIps.Add(ipAddress);
+ }
+
public async ValueTask SyncSettingsAsync()
{
using (var writer = StartRpc(Host.Character.NetId, RpcCalls.SyncSettings))
if (isBan && player.Client.Connection != null)
{
- _bannedIps.Add(player.Client.Connection.EndPoint.Address);
+ BanIp(player.Client.Connection.EndPoint.Address);
}
await _eventManager.CallAsync(new PlayerLeftGameEvent(this, player, isBan));