Add data management, randomized HTML drip and public README
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3671019e60
commit
f5d8ca7484
46 files changed
+1601
-172
No files matched your search
@@ -9,9 +9,8 @@ public static partial class RuntimeSettingsParser
|
||||
private const int MaxPathLength = 256;
|
||||
private const int MaxHostLength = 253;
|
||||
private const int MaxLimit = 100_000;
|
||||
private const int MaxRetentionDays = 3650;
|
||||
|
||||
private static readonly TimeSpan MinInterval = TimeSpan.FromMilliseconds(100);
|
||||
private static readonly TimeSpan MaxInterval = TimeSpan.FromHours(1);
|
||||
private static readonly TimeSpan MinHold = TimeSpan.FromSeconds(1);
|
||||
private static readonly TimeSpan MaxHold = TimeSpan.FromDays(7);
|
||||
|
||||
@@ -24,10 +23,10 @@ public static partial class RuntimeSettingsParser
|
||||
|
||||
var paths = ParseList(input.TrapPaths, nameof(input.TrapPaths), ValidatePath, errors);
|
||||
var hosts = ParseList(input.ExtraKnownHosts, nameof(input.ExtraKnownHosts), ValidateHost, errors);
|
||||
var interval = ParseTimeSpan(input.DripInterval, nameof(input.DripInterval), MinInterval, MaxInterval, errors);
|
||||
var hold = ParseTimeSpan(input.MaxHoldDuration, nameof(input.MaxHoldDuration), MinHold, MaxHold, errors);
|
||||
var maxConnections = ParseInt(input.MaxConnections, nameof(input.MaxConnections), errors);
|
||||
var perIp = ParseInt(input.MaxConnectionsPerIp, nameof(input.MaxConnectionsPerIp), errors);
|
||||
var maxConnections = ParseInt(input.MaxConnections, nameof(input.MaxConnections), 1, MaxLimit, errors);
|
||||
var perIp = ParseInt(input.MaxConnectionsPerIp, nameof(input.MaxConnectionsPerIp), 1, MaxLimit, errors);
|
||||
var retention = ParseInt(input.RetentionDays, nameof(input.RetentionDays), 0, MaxRetentionDays, errors);
|
||||
|
||||
if (maxConnections is { } total && perIp is { } single && single > total
|
||||
&& !errors.ContainsKey(nameof(input.MaxConnectionsPerIp)))
|
||||
@@ -40,7 +39,14 @@ public static partial class RuntimeSettingsParser
|
||||
return new RuntimeSettingsParseResult(null, errors);
|
||||
}
|
||||
|
||||
var settings = new RuntimeSettings(paths!, interval!.Value, maxConnections!.Value, perIp!.Value, hold!.Value, hosts!);
|
||||
var settings = new RuntimeSettings(
|
||||
paths!,
|
||||
maxConnections!.Value,
|
||||
perIp!.Value,
|
||||
hold!.Value,
|
||||
hosts!,
|
||||
retention!.Value,
|
||||
input.IgnorePrivateNetworks);
|
||||
return new RuntimeSettingsParseResult(settings, errors);
|
||||
}
|
||||
|
||||
@@ -137,7 +143,7 @@ public static partial class RuntimeSettingsParser
|
||||
return value;
|
||||
}
|
||||
|
||||
private static int? ParseInt(string? raw, string field, Dictionary<string, string> errors)
|
||||
private static int? ParseInt(string? raw, string field, int min, int max, Dictionary<string, string> errors)
|
||||
{
|
||||
var text = raw?.Trim();
|
||||
if (string.IsNullOrEmpty(text))
|
||||
@@ -146,9 +152,9 @@ public static partial class RuntimeSettingsParser
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!int.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out var value) || value is < 1 or > MaxLimit)
|
||||
if (!int.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out var value) || value < min || value > max)
|
||||
{
|
||||
errors[field] = $"Ganze Zahl zwischen 1 und {MaxLimit}.";
|
||||
errors[field] = $"Ganze Zahl zwischen {min} und {max}.";
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user