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.
74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using System.Linq;
|
|
using Content.Server.Administration.BanList;
|
|
using Content.Server.Database;
|
|
using Content.Server.EUI;
|
|
using Content.Shared.Administration;
|
|
using Robust.Server.Player;
|
|
using Robust.Shared.Console;
|
|
|
|
namespace Content.Server.Administration.Commands;
|
|
|
|
/// <summary>
|
|
/// Lists someones active Ban Ids or opens a window to see them.
|
|
/// </summary>
|
|
[AdminCommand(AdminFlags.Ban)]
|
|
public sealed class BanListCommand : LocalizedCommands
|
|
{
|
|
[Dependency] private readonly IServerDbManager _dbManager = default!;
|
|
[Dependency] private readonly EuiManager _eui = default!;
|
|
[Dependency] private readonly IPlayerLocator _locator = default!;
|
|
|
|
public override string Command => "banlist";
|
|
|
|
public override async void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
{
|
|
if (args.Length != 1)
|
|
{
|
|
shell.WriteError(Help);
|
|
return;
|
|
}
|
|
|
|
var data = await _locator.LookupIdByNameOrIdAsync(args[0]);
|
|
|
|
if (data == null)
|
|
{
|
|
shell.WriteError(Loc.GetString("cmd-ban-player"));
|
|
return;
|
|
}
|
|
|
|
if (shell.Player is not { } player)
|
|
{
|
|
var bans = await _dbManager.GetServerBansAsync(data.LastAddress, data.UserId, data.LastLegacyHWId, data.LastModernHWIds, false);
|
|
|
|
if (bans.Count == 0)
|
|
{
|
|
shell.WriteLine(Loc.GetString("cmd-banlist-empty", ("user", data.Username)));
|
|
return;
|
|
}
|
|
|
|
foreach (var ban in bans)
|
|
{
|
|
var msg = $"{ban.Id}: {ban.Reason}";
|
|
shell.WriteLine(msg);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
var ui = new BanListEui();
|
|
_eui.OpenEui(ui, player);
|
|
await ui.ChangeBanListPlayer(data.UserId);
|
|
}
|
|
|
|
|
|
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
{
|
|
if (args.Length != 1)
|
|
return CompletionResult.Empty;
|
|
|
|
var playerMgr = IoCManager.Resolve<IPlayerManager>();
|
|
var options = playerMgr.Sessions.Select(c => c.Name).OrderBy(c => c).ToArray();
|
|
return CompletionResult.FromHintOptions(options, Loc.GetString("cmd-banlist-hint"));
|
|
}
|
|
}
|