From fc15a615429f4f093ca1ff8fff5ac70eb3e9c7a0 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 25 Jul 2026 10:45:47 -0700 Subject: [PATCH] Cleanup --- Projects/Server/Network/ConnectionFilters.cs | 2 +- Projects/Server/Network/IConnectionFilter.cs | 2 +- .../UOContent/Misc/Blocklist/BlocklistBans.cs | 32 ------------------- .../Misc/Blocklist/BlocklistConfiguration.cs | 2 +- .../UOContent/Misc/Blocklist/BlocklistFile.cs | 2 +- .../Misc/Blocklist/BlocklistFilter.cs | 10 ++++-- .../Misc/Blocklist/BlocklistSnapshot.cs | 2 +- .../UOContent/Misc/Blocklist/PromotedGuard.cs | 2 +- Projects/UOContent/Misc/Firewall/Firewall.cs | 7 ++-- .../Misc/Firewall/FirewallConnectionFilter.cs | 2 +- 10 files changed, 18 insertions(+), 45 deletions(-) delete mode 100644 Projects/UOContent/Misc/Blocklist/BlocklistBans.cs diff --git a/Projects/Server/Network/ConnectionFilters.cs b/Projects/Server/Network/ConnectionFilters.cs index 458ef2f16..eebeae912 100644 --- a/Projects/Server/Network/ConnectionFilters.cs +++ b/Projects/Server/Network/ConnectionFilters.cs @@ -55,7 +55,7 @@ public static class ConnectionFilters } } - filter.Configure(); + filter.Register(); var updated = new IConnectionFilter[_filters.Length + 1]; Array.Copy(_filters, updated, _filters.Length); diff --git a/Projects/Server/Network/IConnectionFilter.cs b/Projects/Server/Network/IConnectionFilter.cs index 225b54be1..48e971c85 100644 --- a/Projects/Server/Network/IConnectionFilter.cs +++ b/Projects/Server/Network/IConnectionFilter.cs @@ -44,7 +44,7 @@ public interface IConnectionFilter string Name { get; } /// Reads configuration. Called by . No I/O beyond config. - void Configure(); + void Register(); /// Starts any background hydration. The token is cancelled on shutdown. void Start(CancellationToken token); diff --git a/Projects/UOContent/Misc/Blocklist/BlocklistBans.cs b/Projects/UOContent/Misc/Blocklist/BlocklistBans.cs deleted file mode 100644 index 6c2ee8a04..000000000 --- a/Projects/UOContent/Misc/Blocklist/BlocklistBans.cs +++ /dev/null @@ -1,32 +0,0 @@ -/************************************************************************* - * ModernUO * - * Copyright 2019-2026 - ModernUO Development Team * - * Email: hi@modernuo.com * - * File: BlocklistBans.cs * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 3 of the License, or * - * (at your option) any later version. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - *************************************************************************/ - -using Server.Network; -using Server.Network.Bans.Blocklist; - -namespace Server.Misc; - -/// -/// Registers the file-backed blocklist with the Core registry during the -/// Configure sweep. Registration is unconditional: the filter self-disables when blocklist.json -/// names no file, or when that file does not exist yet, so no config gate is needed here. -/// -public static class BlocklistBans -{ - public static void Configure() - { - ConnectionFilters.Register(new BlocklistFilter()); - } -} diff --git a/Projects/UOContent/Misc/Blocklist/BlocklistConfiguration.cs b/Projects/UOContent/Misc/Blocklist/BlocklistConfiguration.cs index 8f1413ae8..5379991c9 100644 --- a/Projects/UOContent/Misc/Blocklist/BlocklistConfiguration.cs +++ b/Projects/UOContent/Misc/Blocklist/BlocklistConfiguration.cs @@ -18,7 +18,7 @@ using System.IO; using System.Text.Json.Serialization; using Server.Json; -namespace Server.Network.Bans.Blocklist; +namespace Server.Network.Bans; /// /// Loads the from Configuration/blocklist.json (matching the diff --git a/Projects/UOContent/Misc/Blocklist/BlocklistFile.cs b/Projects/UOContent/Misc/Blocklist/BlocklistFile.cs index 6fbc4a12a..882102bce 100644 --- a/Projects/UOContent/Misc/Blocklist/BlocklistFile.cs +++ b/Projects/UOContent/Misc/Blocklist/BlocklistFile.cs @@ -16,7 +16,7 @@ using System; using System.IO; -namespace Server.Network.Bans.Blocklist; +namespace Server.Network.Bans; public readonly record struct BlocklistHeader(string Generated, int Count, bool Present); diff --git a/Projects/UOContent/Misc/Blocklist/BlocklistFilter.cs b/Projects/UOContent/Misc/Blocklist/BlocklistFilter.cs index 5b9e43177..1617e2169 100644 --- a/Projects/UOContent/Misc/Blocklist/BlocklistFilter.cs +++ b/Projects/UOContent/Misc/Blocklist/BlocklistFilter.cs @@ -20,7 +20,7 @@ using System.Threading; using System.Threading.Tasks; using Server.Logging; -namespace Server.Network.Bans.Blocklist; +namespace Server.Network.Bans; /// /// Accept-path gate for a large, file-sourced IP blocklist, hydrated from the file a generator @@ -57,9 +57,13 @@ public sealed class BlocklistFilter : IConnectionFilter public int Count => _snapshot.Count; - public void Configure() + public static void Configure() + { + ConnectionFilters.Register(new BlocklistFilter()); + } + + public void Register() { - BlocklistConfiguration.Configure(); var s = BlocklistConfiguration.Settings; _path = ResolvePath(s.File); diff --git a/Projects/UOContent/Misc/Blocklist/BlocklistSnapshot.cs b/Projects/UOContent/Misc/Blocklist/BlocklistSnapshot.cs index e2e6857a8..52839512c 100644 --- a/Projects/UOContent/Misc/Blocklist/BlocklistSnapshot.cs +++ b/Projects/UOContent/Misc/Blocklist/BlocklistSnapshot.cs @@ -20,7 +20,7 @@ using System.Net.Sockets; using System.Text; using Server.Collections; -namespace Server.Network.Bans.Blocklist; +namespace Server.Network.Bans; /// /// Immutable dual-stack blocklist. Singles and CIDRs are folded into a single sorted, coalesced diff --git a/Projects/UOContent/Misc/Blocklist/PromotedGuard.cs b/Projects/UOContent/Misc/Blocklist/PromotedGuard.cs index baec5dfbf..dea8f038d 100644 --- a/Projects/UOContent/Misc/Blocklist/PromotedGuard.cs +++ b/Projects/UOContent/Misc/Blocklist/PromotedGuard.cs @@ -16,7 +16,7 @@ using System; using System.Collections.Generic; -namespace Server.Network.Bans.Blocklist; +namespace Server.Network.Bans; /// Suppresses re-reporting the same IP within a TTL. Accept-path thread only. public sealed class PromotedGuard diff --git a/Projects/UOContent/Misc/Firewall/Firewall.cs b/Projects/UOContent/Misc/Firewall/Firewall.cs index 69af4c4e1..fcb90f5d1 100644 --- a/Projects/UOContent/Misc/Firewall/Firewall.cs +++ b/Projects/UOContent/Misc/Firewall/Firewall.cs @@ -14,6 +14,7 @@ *************************************************************************/ using System; +using System.Buffers; using System.Collections.Generic; using System.IO; using System.Net; @@ -324,7 +325,7 @@ public static class Firewall { _dirty = false; var path = Path.Join(Core.BaseDirectory, _path); - var tmp = path + ".tmp"; + var tmp = $"{path}.tmp"; JsonConfig.Serialize(tmp, ToSettings()); File.Move(tmp, path, overwrite: true); // atomic swap } @@ -348,7 +349,7 @@ public static class Firewall private static void MigrateLegacyCfg(string legacyPath) { - var searchValues = System.Buffers.SearchValues.Create("*Xx?"); + var searchValues = SearchValues.Create("*Xx?"); using var reader = new StreamReader(legacyPath); while (reader.ReadLine() is { } line) @@ -384,7 +385,7 @@ public static class Firewall { try { - File.Move(legacyPath, legacyPath + ".migrated", overwrite: true); + File.Move(legacyPath, $"{legacyPath}.migrated", overwrite: true); } catch (Exception e) { diff --git a/Projects/UOContent/Misc/Firewall/FirewallConnectionFilter.cs b/Projects/UOContent/Misc/Firewall/FirewallConnectionFilter.cs index efab6c609..7695eba48 100644 --- a/Projects/UOContent/Misc/Firewall/FirewallConnectionFilter.cs +++ b/Projects/UOContent/Misc/Firewall/FirewallConnectionFilter.cs @@ -37,7 +37,7 @@ internal sealed class FirewallConnectionFilter : IConnectionFilter // Firewall.Configure() owns loading/persistence and does the registering, so there is nothing to do // here; Register() calling this back is harmless. - public void Configure() + public void Register() { }