diff --git a/Projects/Server/Network/Bans/BanChannel.cs b/Projects/Server/Network/Bans/BanChannel.cs index 8b3b917e2..63f903f9d 100644 --- a/Projects/Server/Network/Bans/BanChannel.cs +++ b/Projects/Server/Network/Bans/BanChannel.cs @@ -54,7 +54,7 @@ public static class BanChannel } } - reporter.Configure(); + reporter.Register(); var updated = new IBanReporter[_reporters.Length + 1]; Array.Copy(_reporters, updated, _reporters.Length); diff --git a/Projects/Server/Network/Bans/IBanReporter.cs b/Projects/Server/Network/Bans/IBanReporter.cs index 39cee7780..190c6936e 100644 --- a/Projects/Server/Network/Bans/IBanReporter.cs +++ b/Projects/Server/Network/Bans/IBanReporter.cs @@ -31,7 +31,7 @@ public interface IBanReporter string Name { get; } /// Reads configuration. No network or file I/O here. - void Configure(); + void Register(); /// Starts background delivery. The token is cancelled on shutdown. void Start(CancellationToken token); diff --git a/Projects/UOContent/Misc/Blocklist/BlocklistConfiguration.cs b/Projects/UOContent/Misc/Blocklist/BlocklistConfiguration.cs index 5379991c9..ca39bd53e 100644 --- a/Projects/UOContent/Misc/Blocklist/BlocklistConfiguration.cs +++ b/Projects/UOContent/Misc/Blocklist/BlocklistConfiguration.cs @@ -31,15 +31,8 @@ public static class BlocklistConfiguration public static BlocklistSettings Settings { get; private set; } - public static void Configure() + public static void Load() { - // Idempotent: this Configure() is auto-discovered and also called explicitly by the filter, - // so guard against a redundant second load. - if (Settings != null) - { - return; - } - var path = Path.Join(Core.BaseDirectory, _path); if (File.Exists(path)) diff --git a/Projects/UOContent/Misc/Blocklist/BlocklistFilter.cs b/Projects/UOContent/Misc/Blocklist/BlocklistFilter.cs index 1617e2169..2be16b08b 100644 --- a/Projects/UOContent/Misc/Blocklist/BlocklistFilter.cs +++ b/Projects/UOContent/Misc/Blocklist/BlocklistFilter.cs @@ -64,6 +64,7 @@ public sealed class BlocklistFilter : IConnectionFilter public void Register() { + BlocklistConfiguration.Load(); var s = BlocklistConfiguration.Settings; _path = ResolvePath(s.File); diff --git a/Projects/UOContent/Misc/CrowdSec/CrowdSecBans.cs b/Projects/UOContent/Misc/CrowdSec/CrowdSecBans.cs deleted file mode 100644 index c02ddeecb..000000000 --- a/Projects/UOContent/Misc/CrowdSec/CrowdSecBans.cs +++ /dev/null @@ -1,32 +0,0 @@ -/************************************************************************* - * ModernUO * - * Copyright 2019-2026 - ModernUO Development Team * - * Email: hi@modernuo.com * - * File: CrowdSecBans.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.Bans; -using Server.Network.Bans.CrowdSec; - -namespace Server.Misc; - -/// -/// Registers the CrowdSec ban reporter with the Core during the Configure sweep. -/// Registration is unconditional: the reporter self-disables when crowdsec.json has no credentials -/// (see CrowdSecSettings.ReportingEnabled), so no config gate is needed here. -/// -public static class CrowdSecBans -{ - public static void Configure() - { - BanChannel.Register(new CrowdSecReporter()); - } -} diff --git a/Projects/UOContent/Misc/CrowdSec/CrowdSecConfiguration.cs b/Projects/UOContent/Misc/CrowdSec/CrowdSecConfiguration.cs index a48671ee6..b1376b6a0 100644 --- a/Projects/UOContent/Misc/CrowdSec/CrowdSecConfiguration.cs +++ b/Projects/UOContent/Misc/CrowdSec/CrowdSecConfiguration.cs @@ -31,15 +31,8 @@ public static class CrowdSecConfiguration public static CrowdSecSettings Settings { get; private set; } - public static void Configure() + public static void Load() { - // Idempotent: this Configure() is auto-discovered and also called explicitly by the reporter, - // so guard against a redundant second load. - if (Settings != null) - { - return; - } - var path = Path.Join(Core.BaseDirectory, _path); if (File.Exists(path)) diff --git a/Projects/UOContent/Misc/CrowdSec/CrowdSecReporter.cs b/Projects/UOContent/Misc/CrowdSec/CrowdSecReporter.cs index 1e44dcf1c..7d2492c37 100644 --- a/Projects/UOContent/Misc/CrowdSec/CrowdSecReporter.cs +++ b/Projects/UOContent/Misc/CrowdSec/CrowdSecReporter.cs @@ -69,9 +69,14 @@ public sealed class CrowdSecReporter : IBanReporter /// public int SendFailureCount => _sendFailures; - public void Configure() + public static void Configure() { - CrowdSecConfiguration.Configure(); + BanChannel.Register(new CrowdSecReporter()); + } + + public void Register() + { + CrowdSecConfiguration.Load(); _settings ??= CrowdSecConfiguration.Settings; }