From 7033851e42d1412c34c4022f6a8dd1632c64586e Mon Sep 17 00:00:00 2001 From: ofernander Date: Sun, 12 Apr 2026 18:40:01 -0700 Subject: feat: add username reg pattern matching to blacklist group Adds a field to that accepts a list of regular expressions matched against usernames. --- src/slskd/Core/Options.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/slskd/Core') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 7b38143e..dda1b7b5 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1149,6 +1149,14 @@ namespace slskd /// public string[] Members { get; init; } = Array.Empty(); + /// + /// Gets the list of regular expression patterns matched against usernames. + /// Any username matching one or more patterns will be blacklisted. + /// Follows the same case sensitivity rules as other user-defined regular expressions + /// (case insensitive by default; controlled by the flags.case_sensitive_regex option). + /// + public string[] Patterns { get; init; } = Array.Empty(); + /// /// Gets the list of group CIDRs. /// @@ -1163,6 +1171,14 @@ namespace slskd { var results = new List(); + foreach (var pattern in Patterns ?? Array.Empty()) + { + if (!pattern.IsValidRegex()) + { + results.Add(new ValidationResult($"Blacklist username pattern '{pattern}' is not a valid regular expression")); + } + } + foreach (var cidr in Cidrs ?? Array.Empty()) { try -- cgit v1.2.3 From 73634ad0b54d486cc278c4950583754ad77aac00 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 21 Apr 2026 19:28:35 -0500 Subject: consistent options --- src/slskd/Core/Options.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/slskd/Core') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index dda1b7b5..fcc65c3b 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -1151,9 +1151,6 @@ namespace slskd /// /// Gets the list of regular expression patterns matched against usernames. - /// Any username matching one or more patterns will be blacklisted. - /// Follows the same case sensitivity rules as other user-defined regular expressions - /// (case insensitive by default; controlled by the flags.case_sensitive_regex option). /// public string[] Patterns { get; init; } = Array.Empty(); @@ -1175,7 +1172,7 @@ namespace slskd { if (!pattern.IsValidRegex()) { - results.Add(new ValidationResult($"Blacklist username pattern '{pattern}' is not a valid regular expression")); + results.Add(new ValidationResult($"Pattern '{pattern}' is not a valid regular expression")); } } -- cgit v1.2.3