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.
85 lines
2.6 KiB
C#
85 lines
2.6 KiB
C#
using System.Linq;
|
|
using System.Text;
|
|
using Content.Server.Administration.BanList;
|
|
using Content.Server.EUI;
|
|
using Content.Server.Database;
|
|
using Content.Shared.Administration;
|
|
using Robust.Server.Player;
|
|
using Robust.Shared.Console;
|
|
|
|
namespace Content.Server.Administration.Commands;
|
|
|
|
[AdminCommand(AdminFlags.Ban)]
|
|
public sealed class RoleBanListCommand : IConsoleCommand
|
|
{
|
|
[Dependency] private readonly IServerDbManager _dbManager = default!;
|
|
|
|
[Dependency] private readonly EuiManager _eui = default!;
|
|
|
|
[Dependency] private readonly IPlayerLocator _locator = default!;
|
|
|
|
public string Command => "rolebanlist";
|
|
public string Description => Loc.GetString("cmd-rolebanlist-desc");
|
|
public string Help => Loc.GetString("cmd-rolebanlist-help");
|
|
|
|
public async void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length != 1 && args.Length != 2)
|
|
{
|
|
shell.WriteLine($"Invalid amount of args. {Help}");
|
|
return;
|
|
}
|
|
|
|
var includeUnbanned = true;
|
|
if (args.Length == 2 && !bool.TryParse(args[1], out includeUnbanned))
|
|
{
|
|
shell.WriteLine($"Argument two ({args[1]}) is not a boolean.");
|
|
return;
|
|
}
|
|
|
|
var data = await _locator.LookupIdByNameOrIdAsync(args[0]);
|
|
|
|
if (data == null)
|
|
{
|
|
shell.WriteError("Unable to find a player with that name or id.");
|
|
return;
|
|
}
|
|
|
|
if (shell.Player is not { } player)
|
|
{
|
|
|
|
var bans = await _dbManager.GetServerRoleBansAsync(data.LastAddress, data.UserId, data.LastLegacyHWId, data.LastModernHWIds, includeUnbanned);
|
|
|
|
if (bans.Count == 0)
|
|
{
|
|
shell.WriteLine("That user has no bans in their record.");
|
|
return;
|
|
}
|
|
|
|
foreach (var ban in bans)
|
|
{
|
|
var msg = $"ID: {ban.Id}: Role: {ban.Role} Reason: {ban.Reason}";
|
|
shell.WriteLine(msg);
|
|
}
|
|
return;
|
|
}
|
|
|
|
var ui = new BanListEui();
|
|
_eui.OpenEui(ui, player);
|
|
await ui.ChangeBanListPlayer(data.UserId);
|
|
|
|
}
|
|
|
|
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
{
|
|
return args.Length switch
|
|
{
|
|
1 => CompletionResult.FromHintOptions(CompletionHelper.SessionNames(),
|
|
Loc.GetString("cmd-rolebanlist-hint-1")),
|
|
2 => CompletionResult.FromHintOptions(CompletionHelper.Booleans,
|
|
Loc.GetString("cmd-rolebanlist-hint-2")),
|
|
_ => CompletionResult.Empty
|
|
};
|
|
}
|
|
}
|