fix: Fixes TCPServer accept async, makes Firewall/IP Limiter multithreaded (#2134)
This commit is contained in:
parent
bcab91255a
commit
2a8c62e8be
15 changed files with 578 additions and 215 deletions
|
|
@ -170,7 +170,7 @@ namespace Server.Gumps
|
|||
AddLabel(150, 150, LabelHue, banned.ToString());
|
||||
|
||||
AddLabel(20, 170, LabelHue, "Firewalled:");
|
||||
AddLabel(150, 170, LabelHue, Firewall.FirewallSet.Count.ToString());
|
||||
AddLabel(150, 170, LabelHue, Firewall.FirewallSetCount.ToString());
|
||||
|
||||
AddLabel(20, 190, LabelHue, "Clients:");
|
||||
AddLabel(150, 190, LabelHue, NetState.Instances.Count.ToString());
|
||||
|
|
@ -1165,7 +1165,16 @@ namespace Server.Gumps
|
|||
{
|
||||
AddFirewallHeader();
|
||||
|
||||
m_List ??= Firewall.FirewallSet.ToList<object>();
|
||||
if (m_List == null)
|
||||
{
|
||||
Firewall.ReadFirewallSet(firewallSet =>
|
||||
{
|
||||
list = new List<object>(firewallSet.Count);
|
||||
list.AddRange(firewallSet);
|
||||
});
|
||||
|
||||
m_List = list;
|
||||
}
|
||||
|
||||
AddLabelCropped(12, 120, 358, 20, LabelHue, "IP Address");
|
||||
|
||||
|
|
@ -1178,7 +1187,7 @@ namespace Server.Gumps
|
|||
AddImage(375, 122, 0x25EA);
|
||||
}
|
||||
|
||||
if ((listPage + 1) * 12 < m_List.Count)
|
||||
if ((listPage + 1) * 12 < m_List!.Count)
|
||||
{
|
||||
AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1));
|
||||
}
|
||||
|
|
@ -3470,19 +3479,22 @@ namespace Server.Gumps
|
|||
|
||||
if (string.IsNullOrEmpty(match))
|
||||
{
|
||||
notice = "You must enter a username to search.";
|
||||
notice = "You must enter an IP to search.";
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var check in Firewall.FirewallSet)
|
||||
Firewall.ReadFirewallSet(firewallSet =>
|
||||
{
|
||||
var checkStr = check.ToString();
|
||||
|
||||
if (checkStr.ContainsOrdinal(match))
|
||||
foreach (var check in firewallSet)
|
||||
{
|
||||
results.Add(check);
|
||||
var checkStr = check.ToString();
|
||||
|
||||
if (checkStr.ContainsOrdinal(match))
|
||||
{
|
||||
results.Add(check);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (results.Count == 1)
|
||||
|
|
|
|||
|
|
@ -127,10 +127,13 @@ public static class AdminFirewall
|
|||
|
||||
public static void Save()
|
||||
{
|
||||
using var op = new StreamWriter(firewallConfigPath);
|
||||
foreach (var entry in Firewall.FirewallSet)
|
||||
Firewall.ReadFirewallSet(firewallSet =>
|
||||
{
|
||||
op.WriteLine(entry);
|
||||
}
|
||||
using var op = new StreamWriter(firewallConfigPath);
|
||||
foreach (var entry in firewallSet)
|
||||
{
|
||||
op.WriteLine(entry);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,14 +27,12 @@ namespace Server.Misc
|
|||
public static bool AllowKR => (AllowedClientTypes & ClientType.KR) != 0;
|
||||
public static bool AllowSA => (AllowedClientTypes & ClientType.SA) != 0;
|
||||
|
||||
public static ClientVersion MinRequired { get; private set; }
|
||||
public static ClientVersion MaxRequired { get; private set; }
|
||||
public static TimeSpan KickDelay { get; private set; }
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
MinRequired = ServerConfiguration.GetSetting("clientVerification.minRequired", (ClientVersion)null);
|
||||
MaxRequired = ServerConfiguration.GetSetting("clientVerification.maxRequired", (ClientVersion)null);
|
||||
UOClient.MinRequired = ServerConfiguration.GetSetting("clientVerification.minRequired", (ClientVersion)null);
|
||||
UOClient.MaxRequired = ServerConfiguration.GetSetting("clientVerification.maxRequired", (ClientVersion)null);
|
||||
|
||||
_enable = ServerConfiguration.GetOrUpdateSetting("clientVerification.enable", true);
|
||||
_invalidClientResponse =
|
||||
|
|
@ -51,12 +49,12 @@ namespace Server.Misc
|
|||
|
||||
public static void Initialize()
|
||||
{
|
||||
if (MinRequired == null && MaxRequired == null)
|
||||
if (UOClient.MinRequired == null && UOClient.MaxRequired == null)
|
||||
{
|
||||
MinRequired = UOClient.ServerClientVersion;
|
||||
UOClient.MinRequired = UOClient.ServerClientVersion;
|
||||
}
|
||||
|
||||
if (MinRequired != null || MaxRequired != null)
|
||||
if (UOClient.MinRequired != null || UOClient.MaxRequired != null)
|
||||
{
|
||||
logger.Information(
|
||||
"Restricting client version to {ClientVersion}. Action to be taken: {Action}",
|
||||
|
|
@ -70,17 +68,17 @@ namespace Server.Misc
|
|||
{
|
||||
if (_versionExpression == null)
|
||||
{
|
||||
if (MinRequired != null && MaxRequired != null)
|
||||
if (UOClient.MinRequired != null && UOClient.MaxRequired != null)
|
||||
{
|
||||
_versionExpression = $"{MinRequired}-{MaxRequired}";
|
||||
_versionExpression = $"{UOClient.MinRequired}-{UOClient.MaxRequired}";
|
||||
}
|
||||
else if (MinRequired != null)
|
||||
else if (UOClient.MinRequired != null)
|
||||
{
|
||||
_versionExpression = $"{MinRequired} or newer";
|
||||
_versionExpression = $"{UOClient.MinRequired} or newer";
|
||||
}
|
||||
else
|
||||
{
|
||||
_versionExpression = $"{MaxRequired} or older";
|
||||
_versionExpression = $"{UOClient.MaxRequired} or older";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -133,14 +131,14 @@ namespace Server.Misc
|
|||
bool shouldKick = false;
|
||||
bool isKRClient = version.Type == ClientType.KR;
|
||||
|
||||
if (!isKRClient && MinRequired != null && version < MinRequired)
|
||||
if (!isKRClient && UOClient.MinRequired != null && version < UOClient.MinRequired)
|
||||
{
|
||||
sb.Append($"This server doesn't support clients older than {MinRequired}.");
|
||||
sb.Append($"This server doesn't support clients older than {UOClient.MinRequired}.");
|
||||
shouldKick = strictRequirement;
|
||||
}
|
||||
else if (!isKRClient && MaxRequired != null && version > MaxRequired)
|
||||
else if (!isKRClient && UOClient.MaxRequired != null && version > UOClient.MaxRequired)
|
||||
{
|
||||
sb.Append($"This server doesn't support clients newer than {MaxRequired}.");
|
||||
sb.Append($"This server doesn't support clients newer than {UOClient.MaxRequired}.");
|
||||
shouldKick = strictRequirement;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ public static class IncomingAccountPackets
|
|||
if (state.Seed == 0)
|
||||
{
|
||||
state.LogInfo("Invalid client detected, disconnecting");
|
||||
state.Disconnect("Duplicate seed sent.");
|
||||
state.Disconnect("Invalid client detected");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue