Skip to content

Commit ac10d7b

Browse files
committed
Blacklist and Whitelist functionality.
1 parent 0958352 commit ac10d7b

File tree

10 files changed

+2324
-112
lines changed

10 files changed

+2324
-112
lines changed

BHD-ServerManager/Classes/CoreObjects/CommonCore.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ public static void InitializeCore()
2727
// Instances
2828
theInstance = new theInstance();
2929
instanceChat = new chatInstance();
30-
instanceBans = new banInstance();
3130
instanceStats = new statInstance();
3231

32+
// Initialize Ban Instance
33+
CommonCore.instanceBans = DatabaseManager.LoadBanInstance();
34+
3335
// Initialize the Ticker
3436
Ticker = new Ticker();
3537
}

BHD-ServerManager/Classes/InstanceManagers/theInstanceManager.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public static class theInstanceManager
1717
private static ServerManagerUI thisServer => Program.ServerManagerUI!;
1818
private static theInstance thisInstance => CommonCore.theInstance!;
1919

20-
public static string lastKnownSettingsPath = Path.Combine(CommonCore.AppDataPath, "lastKnownSettings.json");
21-
2220
// The Instances (Data)
2321
private static theInstance theInstance => CommonCore.theInstance!;
2422

BHD-ServerManager/Classes/Instances/banInstance.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class banInstancePlayerName
2323
public required string PlayerName { get; set; }
2424
public DateTime Date { get; set; }
2525
public DateTime? ExpireDate { get; set; }
26-
public int AssociatedIP { get; set; }
26+
public int? AssociatedIP { get; set; }
2727
public required banInstanceRecordType RecordType { get; set; }
2828
public required int RecordCategory { get; set; }
2929
public string Notes { get; set; } = string.Empty;
@@ -38,7 +38,7 @@ public class banInstancePlayerIP
3838
public required int SubnetMask { get; set; }
3939
public DateTime Date { get; set; }
4040
public DateTime? ExpireDate { get; set; }
41-
public int AssociatedName { get; set; }
41+
public int? AssociatedName { get; set; }
4242
public required banInstanceRecordType RecordType { get; set; }
4343
public required int RecordCategory { get; set; }
4444
public string Notes { get; set; } = string.Empty;

BHD-ServerManager/Classes/Services/NetLimiter/NetLimiterClient.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public static class NetLimiterClient
1515
private const string PipeName = "NetLimiterPipe";
1616
private const int Timeout = 5000;
1717

18-
private static NamedPipeClientStream _pipeClient;
18+
private static NamedPipeClientStream? _pipeClient;
1919
private static SemaphoreSlim _pipeLock = new SemaphoreSlim(1, 1);
2020

21-
private static Process _bridgeProcess;
21+
private static Process? _bridgeProcess;
2222

2323
private static readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions
2424
{
@@ -51,7 +51,7 @@ public static async Task<Response> SendCommandAsync(Command command)
5151
// Receive response
5252
using (var reader = new StreamReader(_pipeClient, Encoding.UTF8, false, 1024, true))
5353
{
54-
string responseJson = await reader.ReadLineAsync();
54+
string? responseJson = await reader.ReadLineAsync();
5555
if (string.IsNullOrEmpty(responseJson))
5656
{
5757
throw new InvalidOperationException("No response received from server");
@@ -195,7 +195,7 @@ public static async Task<List<string>> GetFilterIpAddressesAsync(string filterNa
195195
{
196196
if (range.Start == range.End)
197197
{
198-
ipList.Add(range.Start);
198+
ipList.Add(range.Start!);
199199
}
200200
else
201201
{
@@ -211,8 +211,8 @@ public static async Task<List<string>> GetFilterIpAddressesAsync(string filterNa
211211

212212
private class IpRange
213213
{
214-
public string Start { get; set; }
215-
public string End { get; set; }
214+
public string? Start { get; set; }
215+
public string? End { get; set; }
216216
}
217217

218218
public static void StartBridgeProcess(string hostname = "localhost", ushort port = 11111, string username = "", string password = "")
@@ -247,7 +247,7 @@ public static void StartBridgeProcess(string hostname = "localhost", ushort port
247247
_bridgeProcess = Process.Start(startInfo);
248248

249249
// Optional: Capture output for debugging
250-
_bridgeProcess.OutputDataReceived += (sender, e) =>
250+
_bridgeProcess!.OutputDataReceived += (sender, e) =>
251251
{
252252
if (!string.IsNullOrEmpty(e.Data))
253253
AppDebug.Log("NetLimiterBridge", e.Data);

0 commit comments

Comments
 (0)