Revert "A bit of DB model cleanup (#5016)"
This reverts commit 8a3cee9a10.
This commit is contained in:
@@ -104,7 +104,7 @@ namespace Content.Server.Database
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId)
|
||||
{
|
||||
if (address != null && ban.Address is not null && IPAddressExt.IsInSubnet(address, ban.Address.Value))
|
||||
if (address != null && ban.Address != null && IPAddressExt.IsInSubnet(address, ban.Address))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -126,9 +126,15 @@ namespace Content.Server.Database
|
||||
{
|
||||
await using var db = await GetDbImpl();
|
||||
|
||||
string? addrStr = null;
|
||||
if (serverBan.Address is { } addr)
|
||||
{
|
||||
addrStr = $"{addr.address}/{addr.cidrMask}";
|
||||
}
|
||||
|
||||
db.SqliteDbContext.Ban.Add(new SqliteServerBan
|
||||
{
|
||||
Address = serverBan.Address,
|
||||
Address = addrStr,
|
||||
Reason = serverBan.Reason,
|
||||
BanningAdmin = serverBan.BanningAdmin?.UserId,
|
||||
HWId = serverBan.HWId?.ToArray(),
|
||||
@@ -239,12 +245,20 @@ namespace Content.Server.Database
|
||||
aUid = new NetUserId(aGuid);
|
||||
}
|
||||
|
||||
(IPAddress, int)? addrTuple = null;
|
||||
if (ban.Address != null)
|
||||
{
|
||||
var idx = ban.Address.IndexOf('/', StringComparison.Ordinal);
|
||||
addrTuple = (IPAddress.Parse(ban.Address.AsSpan(0, idx)),
|
||||
int.Parse(ban.Address.AsSpan(idx + 1), provider: CultureInfo.InvariantCulture));
|
||||
}
|
||||
|
||||
var unban = ConvertUnban(ban.Unban);
|
||||
|
||||
return new ServerBanDef(
|
||||
ban.Id,
|
||||
uid,
|
||||
ban.Address,
|
||||
addrTuple,
|
||||
ban.HWId == null ? null : ImmutableArray.Create(ban.HWId),
|
||||
ban.BanTime,
|
||||
ban.ExpirationTime,
|
||||
|
||||
Reference in New Issue
Block a user