This should be the primary changes for the future-proof "Modern HWID" system implemented into Robust and the auth server. HWIDs in the database have been given an additional column representing their version, legacy or modern. This is implemented via an EF Core owned entity. By manually setting the column name of the main value column, we can keep DB compatibility and the migration is just adding some type columns. This new HWID type has to be plumbed through everywhere, resulting in some breaking changes for the DB layer and such. New bans and player records are placed with the new modern HWID. Old bans are still checked against legacy HWIDs. Modern HWIDs are presented with a "V2-" prefix to admins, to allow distinguishing them. This is also integrated into the parsing logic for placing new bans. There's also some code cleanup to reduce copy pasting around the place from my changes. Requires latest engine to support ImmutableArray<byte> in NetSerializer.
66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
using System.Net;
|
|
using Content.Shared.Database;
|
|
using Robust.Shared.Network;
|
|
|
|
namespace Content.Server.Database;
|
|
|
|
public sealed class ServerRoleBanDef
|
|
{
|
|
public int? Id { get; }
|
|
public NetUserId? UserId { get; }
|
|
public (IPAddress address, int cidrMask)? Address { get; }
|
|
public ImmutableTypedHwid? HWId { get; }
|
|
|
|
public DateTimeOffset BanTime { get; }
|
|
public DateTimeOffset? ExpirationTime { get; }
|
|
public int? RoundId { get; }
|
|
public TimeSpan PlaytimeAtNote { get; }
|
|
public string Reason { get; }
|
|
public NoteSeverity Severity { get; set; }
|
|
public NetUserId? BanningAdmin { get; }
|
|
public ServerRoleUnbanDef? Unban { get; }
|
|
public string Role { get; }
|
|
|
|
public ServerRoleBanDef(
|
|
int? id,
|
|
NetUserId? userId,
|
|
(IPAddress, int)? address,
|
|
ImmutableTypedHwid? hwId,
|
|
DateTimeOffset banTime,
|
|
DateTimeOffset? expirationTime,
|
|
int? roundId,
|
|
TimeSpan playtimeAtNote,
|
|
string reason,
|
|
NoteSeverity severity,
|
|
NetUserId? banningAdmin,
|
|
ServerRoleUnbanDef? unban,
|
|
string role)
|
|
{
|
|
if (userId == null && address == null && hwId == null)
|
|
{
|
|
throw new ArgumentException("Must have at least one of banned user, banned address or hardware ID");
|
|
}
|
|
|
|
if (address is {} addr && addr.Item1.IsIPv4MappedToIPv6)
|
|
{
|
|
// Fix IPv6-mapped IPv4 addresses
|
|
// So that IPv4 addresses are consistent between separate-socket and dual-stack socket modes.
|
|
address = (addr.Item1.MapToIPv4(), addr.Item2 - 96);
|
|
}
|
|
|
|
Id = id;
|
|
UserId = userId;
|
|
Address = address;
|
|
HWId = hwId;
|
|
BanTime = banTime;
|
|
ExpirationTime = expirationTime;
|
|
RoundId = roundId;
|
|
PlaytimeAtNote = playtimeAtNote;
|
|
Reason = reason;
|
|
Severity = severity;
|
|
BanningAdmin = banningAdmin;
|
|
Unban = unban;
|
|
Role = role;
|
|
}
|
|
}
|