Holy crap auth works (#2099)
* Holy crap auth works * Fix some usages of UserID instead of UserName * Refactor preferences. They be non-async now. Also faster. * Rename DbContext. * Guest username assignment. * Fix saving of profiles. * Don't store data for guests. * Fix generating invalid random colors. * Don't allow dumb garbage for char preferences. * Bans. * Lol forgot to fill out the command description. * Connection log. * Rename all the tables and columns to be snake_case. * Re-do migrations. * Fixing tests and warnings. * Update submodule
This commit is contained in:
committed by
GitHub
parent
8a33e0a9bd
commit
66c8a68891
41
Content.Server/Database/ServerBanDef.cs
Normal file
41
Content.Server/Database/ServerBanDef.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using Robust.Shared.Network;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Content.Server.Database
|
||||
{
|
||||
public sealed class ServerBanDef
|
||||
{
|
||||
public NetUserId? UserId { get; }
|
||||
public (IPAddress address, int cidrMask)? Address { get; }
|
||||
|
||||
public DateTimeOffset BanTime { get; }
|
||||
public DateTimeOffset? ExpirationTime { get; }
|
||||
public string Reason { get; }
|
||||
public NetUserId? BanningAdmin { get; }
|
||||
|
||||
public ServerBanDef(NetUserId? userId, (IPAddress, int)? address, DateTimeOffset banTime, DateTimeOffset? expirationTime, string reason, NetUserId? banningAdmin)
|
||||
{
|
||||
if (userId == null && address == null)
|
||||
{
|
||||
throw new ArgumentException("Must have a banned user, banned address, or both.");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
UserId = userId;
|
||||
Address = address;
|
||||
BanTime = banTime;
|
||||
ExpirationTime = expirationTime;
|
||||
Reason = reason;
|
||||
BanningAdmin = banningAdmin;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user