Require hwid (#35331)

* Make cvar to require that the client has a modern hwid

* Ignore guests and don't disable cvar on dev

* Rename and add docs
This commit is contained in:
nikthechampiongr
2025-02-20 10:04:45 -08:00
committed by GitHub
parent 93021c4879
commit 09f75394be
4 changed files with 15 additions and 0 deletions

View File

@@ -987,6 +987,8 @@ namespace Content.Server.Database
BabyJail = 4, BabyJail = 4,
/// Results from rejected connections with external API checking tools /// Results from rejected connections with external API checking tools
IPChecks = 5, IPChecks = 5,
/// Results from rejected connections who are authenticated but have no modern hwid associated with them.
NoHwid = 6
} }
public class ServerBanHit public class ServerBanHit

View File

@@ -220,6 +220,11 @@ namespace Content.Server.Connection
var modernHwid = e.UserData.ModernHWIds; var modernHwid = e.UserData.ModernHWIds;
if (modernHwid.Length == 0 && e.AuthType == LoginType.LoggedIn && _cfg.GetCVar(CCVars.RequireModernHardwareId))
{
return (ConnectionDenyReason.NoHwid, Loc.GetString("hwid-required"), null);
}
var bans = await _db.GetServerBansAsync(addr, userId, hwId, modernHwid, includeUnbanned: false); var bans = await _db.GetServerBansAsync(addr, userId, hwId, modernHwid, includeUnbanned: false);
if (bans.Count > 0) if (bans.Count > 0)
{ {

View File

@@ -183,6 +183,12 @@ public sealed partial class CCVars
public static readonly CVarDef<bool> BanHardwareIds = public static readonly CVarDef<bool> BanHardwareIds =
CVarDef.Create("ban.hardware_ids", true, CVar.SERVERONLY); CVarDef.Create("ban.hardware_ids", true, CVar.SERVERONLY);
/// <summary>
/// Determines if we'll reject connections from clients who don't have a modern hwid.
/// </summary>
public static readonly CVarDef<bool> RequireModernHardwareId =
CVarDef.Create("admin.require_modern_hwid", true, CVar.SERVERONLY);
/// <summary> /// <summary>
/// If true, players are allowed to connect to multiple game servers at once. /// If true, players are allowed to connect to multiple game servers at once.
/// If false, they will be kicked from the first when connecting to another. /// If false, they will be kicked from the first when connecting to another.

View File

@@ -60,3 +60,5 @@ generic-misconfigured = The server is misconfigured and is not accepting players
ipintel-server-ratelimited = This server uses a security system with external verification, which has reached its maximum verification limit. Please contact the administration team of the server for assistance and try again later. ipintel-server-ratelimited = This server uses a security system with external verification, which has reached its maximum verification limit. Please contact the administration team of the server for assistance and try again later.
ipintel-unknown = This server uses a security system with external verification, but it encountered an error. Please contact the administration team of the server for assistance and try again later. ipintel-unknown = This server uses a security system with external verification, but it encountered an error. Please contact the administration team of the server for assistance and try again later.
ipintel-suspicious = You seem to be connecting through a datacenter or VPN. For administrative reasons we do not allow VPN connections to play. Please contact the administration team of the server for assistance if you believe this is false. ipintel-suspicious = You seem to be connecting through a datacenter or VPN. For administrative reasons we do not allow VPN connections to play. Please contact the administration team of the server for assistance if you believe this is false.
hwid-required = Your client has refused to send a hardware id. Please contact the administration team for further assistance.