fix: Fixes networking issues (#1958)
### Summary - Puts back `EventSink.SocketConnect`. - Reverts networking change to push the networking to a separate thread. - Reverts changes to the firewall by removing the firewall queue. - Fixes listeners not shutting down with the server. - Fixes race condition causing connections to get stuck even after they are disposed. > [!NOTE] > **Developer Note** > Networking has been reverted back to using the main thread instead of a background thread. This alleviated complexity and the requirement for concurrent queues all over the place.
This commit is contained in:
parent
97c53e656e
commit
e0fcde885c
10 changed files with 211 additions and 340 deletions
|
|
@ -169,7 +169,7 @@ namespace Server.Gumps
|
|||
AddLabel(150, 150, LabelHue, banned.ToString());
|
||||
|
||||
AddLabel(20, 170, LabelHue, "Firewalled:");
|
||||
AddLabel(150, 170, LabelHue, AdminFirewall.Set.Count.ToString());
|
||||
AddLabel(150, 170, LabelHue, Firewall.FirewallSet.Count.ToString());
|
||||
|
||||
AddLabel(20, 190, LabelHue, "Clients:");
|
||||
AddLabel(150, 190, LabelHue, NetState.Instances.Count.ToString());
|
||||
|
|
@ -1161,7 +1161,7 @@ namespace Server.Gumps
|
|||
{
|
||||
AddFirewallHeader();
|
||||
|
||||
m_List ??= AdminFirewall.Set.ToList<object>();
|
||||
m_List ??= Firewall.FirewallSet.ToList<object>();
|
||||
|
||||
AddLabelCropped(12, 120, 358, 20, LabelHue, "IP Address");
|
||||
|
||||
|
|
@ -3464,7 +3464,7 @@ namespace Server.Gumps
|
|||
}
|
||||
else
|
||||
{
|
||||
foreach (var check in AdminFirewall.Set)
|
||||
foreach (var check in Firewall.FirewallSet)
|
||||
{
|
||||
var checkStr = check.ToString();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
|
@ -13,7 +12,6 @@ public static class AdminFirewall
|
|||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(AdminFirewall));
|
||||
|
||||
private static readonly HashSet<IFirewallEntry> _firewallSet = [];
|
||||
private const string firewallConfigPath = "firewall.cfg";
|
||||
|
||||
public static void Configure()
|
||||
|
|
@ -44,9 +42,6 @@ public static class AdminFirewall
|
|||
}
|
||||
}
|
||||
|
||||
// Note: This is not optimized, so do not use this in hot paths
|
||||
public static IReadOnlySet<IFirewallEntry> Set => _firewallSet;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static IFirewallEntry ToFirewallEntry(object entry)
|
||||
{
|
||||
|
|
@ -91,41 +86,49 @@ public static class AdminFirewall
|
|||
}
|
||||
}
|
||||
|
||||
public static void Remove(object obj, bool save = true)
|
||||
public static bool Remove(object obj, bool save = true)
|
||||
{
|
||||
var entry = ToFirewallEntry(obj);
|
||||
|
||||
if (entry != null)
|
||||
if (entry == null)
|
||||
{
|
||||
_firewallSet.Remove(entry);
|
||||
Firewall.RequestRemoveEntry(entry); // Request that the TcpServer also remove the entry
|
||||
|
||||
if (save)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool Add(object obj) => Add(ToFirewallEntry(obj));
|
||||
|
||||
public static bool Add(IFirewallEntry entry, bool save = true)
|
||||
{
|
||||
var added = _firewallSet.Add(entry);
|
||||
Firewall.RequestAddEntry(entry); // Request that the TcpServer also add the entry
|
||||
if (!Firewall.Remove(entry))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (save)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
||||
return added;
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Add(object obj) => Add(ToFirewallEntry(obj));
|
||||
|
||||
public static bool Add(IFirewallEntry entry, bool save = true)
|
||||
{
|
||||
if (!Firewall.Add(entry))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (save)
|
||||
{
|
||||
Save();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
using var op = new StreamWriter(firewallConfigPath);
|
||||
foreach (var entry in Set)
|
||||
foreach (var entry in Firewall.FirewallSet)
|
||||
{
|
||||
op.WriteLine(entry);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue