Compare commits

...
12 Commits
Author SHA1 Message Date
miniduikboot ff49e895ec make stylecop happy 2023-06-15 22:38:03 +02:00
miniduikboot 0e9fb4b41c Bump version to 1.8.3 2023-06-15 22:38:03 +02:00
miniduikboot 4f00bf1ee7 Add GameVersion for 2023.6.13
There seem to be no functional changes
2023-06-15 22:38:03 +02:00
miniduikboot a519c0daed Allow multiple SetName commands per CheckName
Some mods use SetName to set player-specific names, for example to set
player-specific roles. When Anticheat is disabled, this should be
allowed for feature-parity with officials.
2023-06-01 19:39:46 +02:00
yukieiji 1f98102e5a update:config 2023-05-23 21:39:09 +02:00
yukieiji 93fdc83ce7 refactor:ConnectionTimeout 2023-05-23 21:39:09 +02:00
yukieiji e29552ca28 refactor:SpawnInTime to config 2023-05-23 21:39:09 +02:00
yukieiji 8eee7f888f feat:timeout config 2023-05-23 21:39:09 +02:00
miniduikboot a77e4e17c2 Bump version to 1.8.2 2023-04-09 16:54:38 +02:00
danbudworthmead 9ebf5cd8e9 Adding missing 2023.3.13 version for android 2023-03-30 21:29:37 +02:00
miniduikboot 4ffca69714 Update to 2023.3.28 2023-03-28 20:15:11 +02:00
miniduikboot dede1c5b09 Reorder GameFull and GameStarted join errors
If a game is in progress, a player can't join it anyway and spam-joining
to see if a spot becomes available is useless. So the GameFull error is
more important than the GameStarted error, therefore reorder them.

Closes: #518
2023-03-08 20:46:29 +01:00
11 changed files with 68 additions and 48 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11</LangVersion>
<VersionPrefix>1.8.1</VersionPrefix>
<VersionPrefix>1.8.3</VersionPrefix>
<VersionSuffix>dev</VersionSuffix>
<EnforceCodeStyleInBuild Condition="$(MSBuildProjectName)!='Hazel'">true</EnforceCodeStyleInBuild>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
+11
View File
@@ -0,0 +1,11 @@
namespace Impostor.Api.Config
{
public class TimeoutConfig
{
public const string Section = "Timeout";
public int SpawnTimeout { get; set; } = 2500;
public int ConnectionTimeout { get; set; } = 2500;
}
}
-8
View File
@@ -1,8 +0,0 @@
namespace Impostor.Server
{
internal static class Constants
{
public const int SpawnTimeout = 2500;
public const int ConnectionTimeout = 2500;
}
}
@@ -513,36 +513,40 @@ namespace Impostor.Server.Net.Inner.Objects
}
else
{
if (!RequestedPlayerName.Any())
if (RequestedPlayerName.Any())
{
_logger.LogWarning($"Client sent {nameof(RpcCalls.SetName)} for a player that didn't request it");
return false;
}
var expected = RequestedPlayerName.Dequeue();
var expected = RequestedPlayerName.Dequeue();
if (Game.Players.Any(x => x.Character != null && x.Character != this && x.Character.PlayerInfo.PlayerName == expected))
{
var i = 1;
while (true)
if (Game.Players.Any(x => x.Character != null && x.Character != this && x.Character.PlayerInfo.PlayerName == expected))
{
var text = expected + " " + i;
if (Game.Players.All(x => x.Character == null || x.Character == this || x.Character.PlayerInfo.PlayerName != text))
var i = 1;
while (true)
{
expected = text;
break;
}
var text = expected + " " + i;
i++;
if (Game.Players.All(x => x.Character == null || x.Character == this || x.Character.PlayerInfo.PlayerName != text))
{
expected = text;
break;
}
i++;
}
}
if (name != expected)
{
_logger.LogWarning($"Client sent {nameof(RpcCalls.SetName)} with incorrect name");
await SetNameAsync(expected);
return false;
}
}
if (name != expected)
else
{
_logger.LogWarning($"Client sent {nameof(RpcCalls.SetName)} with incorrect name");
await SetNameAsync(expected);
return false;
if (await sender.Client.ReportCheatAsync(RpcCalls.SetName, $"Client sent {nameof(RpcCalls.SetName)} for a player that didn't request it"))
{
return false;
}
}
}
@@ -24,6 +24,9 @@ namespace Impostor.Server.Net.Manager
GameVersion.GetVersion(2022, 11, 1), // 2022.12.8
GameVersion.GetVersion(2022, 11, 9), // 2022.12.14
GameVersion.GetVersion(2022, 12, 2), // 2023.2.28
GameVersion.GetVersion(2023, 1, 11), // 2023.3.28s
GameVersion.GetVersion(2023, 3, 13), // 2023.3.28a
GameVersion.GetVersion(2023, 4, 21), // 2023.6.13
};
private readonly ILogger<ClientManager> _logger;
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading;
using System.Threading.Tasks;
using Impostor.Api.Net;
@@ -13,11 +13,13 @@ namespace Impostor.Server.Net.State
{
private readonly ILogger<ClientPlayer> _logger;
private readonly Timer _spawnTimeout;
private readonly int _spawnTimeoutTime;
public ClientPlayer(ILogger<ClientPlayer> logger, ClientBase client, Game game)
public ClientPlayer(ILogger<ClientPlayer> logger, ClientBase client, Game game, int timeOutTime)
{
_logger = logger;
_spawnTimeout = new Timer(RunSpawnTimeout!, null, -1, -1);
_spawnTimeoutTime = timeOutTime;
Game = game;
Client = client;
@@ -41,7 +43,7 @@ namespace Impostor.Server.Net.State
public void InitializeSpawnTimeout()
{
_spawnTimeout.Change(Constants.SpawnTimeout, -1);
_spawnTimeout.Change(_spawnTimeoutTime, -1);
}
public void DisableSpawnTimeout()
+10 -10
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading;
using System.Threading.Tasks;
using Impostor.Api.Games;
@@ -166,14 +166,6 @@ namespace Impostor.Server.Net.State
}
}
// Check if;
// - The player is already in this game.
// - The game is full.
if (player?.Game != this && _players.Count >= Options.MaxPlayers)
{
return GameJoinResult.FromError(GameJoinError.GameFull);
}
if (GameState == GameStates.Starting || GameState == GameStates.Started)
{
return GameJoinResult.FromError(GameJoinError.GameStarted);
@@ -184,11 +176,19 @@ namespace Impostor.Server.Net.State
return GameJoinResult.FromError(GameJoinError.GameDestroyed);
}
// Check if;
// - The player is already in this game.
// - The game is full.
if (player?.Game != this && _players.Count >= Options.MaxPlayers)
{
return GameJoinResult.FromError(GameJoinError.GameFull);
}
var isNew = false;
if (player == null || player.Game != this)
{
var clientPlayer = new ClientPlayer(_serviceProvider.GetRequiredService<ILogger<ClientPlayer>>(), client, this);
var clientPlayer = new ClientPlayer(_serviceProvider.GetRequiredService<ILogger<ClientPlayer>>(), client, this, _timeoutConfig.SpawnTimeout);
if (!_clientManager.Validate(client))
{
+2 -2
View File
@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using Impostor.Api;
using Impostor.Api.Innersloth;
@@ -76,7 +76,7 @@ namespace Impostor.Server.Net.State
// Player can refuse to be kicked and keep the connection open, check for this.
_ = Task.Run(async () =>
{
await Task.Delay(Constants.ConnectionTimeout);
await Task.Delay(_timeoutConfig.ConnectionTimeout);
if (player.Client.Connection.IsConnected && player.Client.Connection is HazelConnection hazel)
{
+4 -1
View File
@@ -30,6 +30,7 @@ namespace Impostor.Server.Net.State
private readonly HashSet<IPAddress> _bannedIps;
private readonly IEventManager _eventManager;
private readonly CompatibilityConfig _compatibilityConfig;
private readonly TimeoutConfig _timeoutConfig;
public Game(
ILogger<Game> logger,
@@ -41,7 +42,8 @@ namespace Impostor.Server.Net.State
GameFilterOptions filterOptions,
ClientManager clientManager,
IEventManager eventManager,
IOptions<CompatibilityConfig> compatibilityConfig)
IOptions<CompatibilityConfig> compatibilityConfig,
IOptions<TimeoutConfig> timeoutConfig)
{
_logger = logger;
_serviceProvider = serviceProvider;
@@ -59,6 +61,7 @@ namespace Impostor.Server.Net.State
_clientManager = clientManager;
_eventManager = eventManager;
_compatibilityConfig = compatibilityConfig.Value;
_timeoutConfig = timeoutConfig.Value;
Items = new ConcurrentDictionary<object, object>();
}
+2 -1
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -99,6 +99,7 @@ namespace Impostor.Server
services.Configure<AntiCheatConfig>(host.Configuration.GetSection(AntiCheatConfig.Section));
services.Configure<CompatibilityConfig>(host.Configuration.GetSection(CompatibilityConfig.Section));
services.Configure<ServerConfig>(host.Configuration.GetSection(ServerConfig.Section));
services.Configure<TimeoutConfig>(host.Configuration.GetSection(TimeoutConfig.Section));
services.AddSingleton<ClientManager>();
services.AddSingleton<IClientManager>(p => p.GetRequiredService<ClientManager>());
+4
View File
@@ -9,6 +9,10 @@
"Enabled": true,
"BanIpFromGame": true
},
"Timeout": {
"SpawnTimeout": 2500,
"ConnectionTimeout": 2500
},
"Compatibility": {
"AllowFutureGameVersions": false,
"AllowVersionMixing": false