From 1fb7b1d85d04546dda66616030f427badff48ebd Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 1 Mar 2026 13:44:22 -0600 Subject: move transfer options into the same type, move limits under upload --- src/slskd/Core/Options.cs | 380 +++++++++++++++++++++++----------------------- 1 file changed, 186 insertions(+), 194 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 1464cf99..c68b6131 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -239,16 +239,9 @@ namespace slskd public SharesOptions Shares { get; init; } = new SharesOptions(); /// - /// Gets global options. + /// Gets transfer options. /// - [Validate] - public GlobalOptions Global { get; init; } = new GlobalOptions(); - - /// - /// Gets user groups. - /// - [Validate] - public GroupsOptions Groups { get; init; } = new GroupsOptions(); + public TransfersOptions Transfers { get; init; } = new TransfersOptions(); /// /// Gets blacklist options. @@ -904,9 +897,9 @@ namespace slskd } /// - /// Global options. + /// Transfer options. /// - public class GlobalOptions + public class TransfersOptions { /// /// Gets global upload options. @@ -915,16 +908,16 @@ namespace slskd public GlobalUploadOptions Upload { get; init; } = new GlobalUploadOptions(); /// - /// Gets global limits. + /// Gets global download options. /// [Validate] - public LimitsOptions Limits { get; init; } = new LimitsOptions(); + public GlobalDownloadOptions Download { get; init; } = new GlobalDownloadOptions(); /// - /// Gets global download options. + /// Gets user groups. /// [Validate] - public GlobalDownloadOptions Download { get; init; } = new GlobalDownloadOptions(); + public GroupsOptions Groups { get; init; } = new GroupsOptions(); /// /// Global upload options. @@ -949,6 +942,12 @@ namespace slskd [Description("the total upload speed limit")] [Range(1, int.MaxValue)] public int SpeedLimit { get; init; } = int.MaxValue; + + /// + /// Gets global limits. + /// + [Validate] + public LimitsOptions Limits { get; init; } = new LimitsOptions(); } /// @@ -975,244 +974,237 @@ namespace slskd [Range(1, int.MaxValue)] public int SpeedLimit { get; init; } = int.MaxValue; } - } - - /// - /// Limit options. - /// - public class LimitsOptions - { - /// - /// Gets limits for queued transfers. - /// - [Validate] - public Limits Queued { get; init; } = new Limits(); - - /// - /// Gets daily limits for transfers. - /// - [Validate] - public Limits Daily { get; init; } = new Limits(); - - /// - /// Gets weekly limits for transfers. - /// - [Validate] - public Limits Weekly { get; init; } = new Limits(); /// - /// Limits. + /// User groups. /// - public class Limits + public class GroupsOptions : IValidatableObject { /// - /// Gets the limit for number of files. + /// Gets options for the default user group. /// - [Range(1, int.MaxValue)] - public int? Files { get; init; } = null; + /// + /// These options apply to users that are not privileged, have not been identified as leechers, + /// and have not been added as a member of any group. + /// + [Validate] + public GroupOptions Default { get; init; } = new GroupOptions(); /// - /// Gets the limit for number of megabytes. + /// Gets options for the leecher user group. /// - [Range(1, int.MaxValue)] - public int? Megabytes { get; init; } = null; + /// + /// These options apply to users that have been identified as leechers, and have not been added as a member of any group. + /// + [Validate] + public LeecherOptions Leechers { get; init; } = new LeecherOptions(); /// - /// Gets the limit for number of failures. + /// Gets options for the blacklisted user group. /// - [Range(1, int.MaxValue)] - public int? Failures { get; init; } = null; - } - } - - /// - /// User groups. - /// - public class GroupsOptions : IValidatableObject - { - /// - /// Gets options for the default user group. - /// - /// - /// These options apply to users that are not privileged, have not been identified as leechers, - /// and have not been added as a member of any group. - /// - [Validate] - public BuiltInOptions Default { get; init; } = new BuiltInOptions(); - - /// - /// Gets options for the leecher user group. - /// - /// - /// These options apply to users that have been identified as leechers, and have not been added as a member of any group. - /// - [Validate] - public LeecherOptions Leechers { get; init; } = new LeecherOptions(); - - /// - /// Gets options for the blacklisted user group. - /// - [Validate] - public BlacklistedOptions Blacklisted { get; init; } = new BlacklistedOptions(); - - /// - /// Gets user defined groups and options. - /// - [Validate] - public Dictionary UserDefined { get; init; } = new Dictionary(); - - /// - /// Extended validation. - /// - /// - /// - public IEnumerable Validate(ValidationContext validationContext) - { - var builtInGroups = new[] { Application.PrivilegedGroup, Application.DefaultGroup, Application.LeecherGroup }; - var intersection = UserDefined.Keys.Intersect(builtInGroups); - - return intersection.Select(group => new ValidationResult($"User defined group '{group}' collides with a built in group. Choose a different name.")); - } + [Validate] + public BlacklistedOptions Blacklisted { get; init; } = new BlacklistedOptions(); - /// - /// Options that are common to all groups. - /// - public class GroupOptions - { /// - /// Gets upload options. + /// Gets user defined groups and options. /// [Validate] - public UploadOptions Upload { get; init; } = new UploadOptions(); + public Dictionary UserDefined { get; init; } = new Dictionary(); /// - /// Gets limit options. + /// Extended validation. /// - [Validate] - public LimitsOptions Limits { get; init; } = new LimitsOptions(); - } + /// + /// + public IEnumerable Validate(ValidationContext validationContext) + { + var builtInGroups = new[] { Application.PrivilegedGroup, Application.DefaultGroup, Application.LeecherGroup }; + var intersection = UserDefined.Keys.Intersect(builtInGroups); - /// - /// Built in user group options. - /// - public class BuiltInOptions : GroupOptions - { - } + return intersection.Select(group => new ValidationResult($"User defined group '{group}' collides with a built in group. Choose a different name.")); + } - /// - /// Built in blacklisted group options. - /// - public class BlacklistedOptions : IValidatableObject - { /// - /// Gets the list of group member usernames. + /// Options that are common to all groups. /// - public string[] Members { get; init; } = Array.Empty(); + public class GroupOptions + { + /// + /// Gets upload options. + /// + [Validate] + public GroupUploadOptions Upload { get; init; } = new GroupUploadOptions(); + + /// + /// User group upload options. + /// + public class GroupUploadOptions + { + /// + /// Gets the priority of the group. + /// + [Range(1, int.MaxValue)] + public int Priority { get; init; } = 1; + + /// + /// Gets the queue strategy for the group. + /// + [Enum(typeof(Transfers.QueueStrategy))] + public string Strategy { get; init; } = slskd.Transfers.QueueStrategy.RoundRobin.ToString().ToLowerInvariant(); + + /// + /// Gets the limit for the total number of upload slots for the group. + /// + [Range(1, int.MaxValue)] + public int Slots { get; init; } = int.MaxValue; + + /// + /// Gets the total upload speed limit for the group, in kibibytes. + /// + [Range(1, int.MaxValue)] + public int SpeedLimit { get; init; } = int.MaxValue; + + /// + /// Gets limit options. + /// + [Validate] + public LimitsOptions Limits { get; init; } = new LimitsOptions(); + } + } /// - /// Gets the list of group CIDRs. + /// Built in leecher group options. /// - public string[] Cidrs { get; init; } = Array.Empty(); + public class LeecherOptions : GroupOptions + { + /// + /// Gets leecher threshold options. + /// + [Validate] + public ThresholdOptions Thresholds { get; init; } = new ThresholdOptions(); + + /// + /// Leecher threshold options. + /// + public class ThresholdOptions + { + /// + /// Gets the minimum number of shared files required to avoid being classified as a leecher. + /// + [Range(1, int.MaxValue)] + public int Files { get; init; } = 1; + + /// + /// Gets the minimum number of shared directories required to avoid being classified as a leecher. + /// + [Range(1, int.MaxValue)] + public int Directories { get; init; } = 1; + } + } /// - /// Extended validation. + /// Built in blacklisted group options. /// - /// - /// - public IEnumerable Validate(ValidationContext validationContext) + public class BlacklistedOptions : IValidatableObject { - var results = new List(); + /// + /// Gets the list of group member usernames. + /// + public string[] Members { get; init; } = Array.Empty(); + + /// + /// Gets the list of group CIDRs. + /// + public string[] Cidrs { get; init; } = Array.Empty(); - foreach (var cidr in Cidrs ?? Array.Empty()) + /// + /// Extended validation. + /// + /// + /// + public IEnumerable Validate(ValidationContext validationContext) { - try + var results = new List(); + + foreach (var cidr in Cidrs ?? Array.Empty()) { - if (cidr.StartsWith("::ffff", StringComparison.OrdinalIgnoreCase)) + try { - throw new Exception("IPv4 mapped IPv6 addresses are not allowed"); - } + if (cidr.StartsWith("::ffff", StringComparison.OrdinalIgnoreCase)) + { + throw new Exception("IPv4 mapped IPv6 addresses are not allowed"); + } - _ = IPAddressRange.Parse(cidr); - } - catch (Exception ex) - { - results.Add(new ValidationResult($"CIDR {cidr} is invalid: {ex.Message}")); + _ = IPAddressRange.Parse(cidr); + } + catch (Exception ex) + { + results.Add(new ValidationResult($"CIDR {cidr} is invalid: {ex.Message}")); + } } - } - return results; + return results; + } } - } - /// - /// Built in leecher group options. - /// - public class LeecherOptions : GroupOptions - { /// - /// Gets leecher threshold options. + /// User defined user group options. /// - [Validate] - public ThresholdOptions Thresholds { get; init; } = new ThresholdOptions(); + public class UserDefinedOptions : GroupOptions + { + /// + /// Gets the list of group member usernames. + /// + public string[] Members { get; init; } = Array.Empty(); + } } /// - /// Leecher threshold options. + /// Limit options. /// - public class ThresholdOptions + public class LimitsOptions { /// - /// Gets the minimum number of shared files required to avoid being classified as a leecher. - /// - [Range(1, int.MaxValue)] - public int Files { get; init; } = 1; - - /// - /// Gets the minimum number of shared directories required to avoid being classified as a leecher. + /// Gets limits for queued transfers. /// - [Range(1, int.MaxValue)] - public int Directories { get; init; } = 1; - } + [Validate] + public Limits Queued { get; init; } = new Limits(); - /// - /// User defined user group options. - /// - public class UserDefinedOptions : GroupOptions - { /// - /// Gets the list of group member usernames. + /// Gets daily limits for transfers. /// - public string[] Members { get; init; } = Array.Empty(); - } + [Validate] + public Limits Daily { get; init; } = new Limits(); - /// - /// User group upload options. - /// - public class UploadOptions - { /// - /// Gets the priority of the group. + /// Gets weekly limits for transfers. /// - [Range(1, int.MaxValue)] - public int Priority { get; init; } = 1; + [Validate] + public Limits Weekly { get; init; } = new Limits(); /// - /// Gets the queue strategy for the group. + /// Limits. /// - [Enum(typeof(Transfers.QueueStrategy))] - public string Strategy { get; init; } = Transfers.QueueStrategy.RoundRobin.ToString().ToLowerInvariant(); + public class Limits + { + /// + /// Gets the limit for number of files. + /// + [Range(1, int.MaxValue)] + public int? Files { get; init; } = null; - /// - /// Gets the limit for the total number of upload slots for the group. - /// - [Range(1, int.MaxValue)] - public int Slots { get; init; } = int.MaxValue; + /// + /// Gets the limit for number of megabytes. + /// + [Range(1, int.MaxValue)] + public int? Megabytes { get; init; } = null; - /// - /// Gets the total upload speed limit for the group, in kibibytes. - /// - [Range(1, int.MaxValue)] - public int SpeedLimit { get; init; } = int.MaxValue; + /// + /// Gets the limit for number of failures. + /// + [Range(1, int.MaxValue)] + public int? Failures { get; init; } = null; + } } } -- cgit v1.2.3 From 5ef316ac858ba31bb35be670491fc4fd3acdda4f Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 1 Mar 2026 16:49:49 -0600 Subject: fix stuff broken by options refactor --- src/slskd/Application.cs | 30 ++-- src/slskd/Program.cs | 4 +- src/slskd/Transfers/Uploads/UploadGovernor.cs | 14 +- src/slskd/Transfers/Uploads/UploadQueue.cs | 22 +-- src/slskd/Users/UserService.cs | 10 +- .../Transfers/Uploads/UploadGovernorTests.cs | 24 ++- .../Transfers/Uploads/UploadQueueTests.cs | 190 +++++++++++---------- tests/slskd.Tests.Unit/Users/UserServiceTests.cs | 72 ++++---- 8 files changed, 195 insertions(+), 171 deletions(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index daed5d3f..2e9639c6 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -421,8 +421,8 @@ namespace slskd distributedChildLimit: OptionsAtStartup.Soulseek.DistributedNetwork.ChildLimit, enableDistributedNetwork: !OptionsAtStartup.Soulseek.DistributedNetwork.Disabled, acceptDistributedChildren: !OptionsAtStartup.Soulseek.DistributedNetwork.DisableChildren, - maximumUploadSpeed: OptionsAtStartup.Global.Upload.SpeedLimit, - maximumDownloadSpeed: OptionsAtStartup.Global.Download.SpeedLimit, + maximumUploadSpeed: OptionsAtStartup.Transfers.Upload.SpeedLimit, + maximumDownloadSpeed: OptionsAtStartup.Transfers.Download.SpeedLimit, autoAcknowledgePrivateMessages: false, acceptPrivateRoomInvitations: true, serverConnectionOptions: serverOptions, @@ -660,26 +660,26 @@ namespace slskd } // we'll fall back to global limits for any limit that isn't set at the group level - var global = Options.Global.Limits; + var global = Options.Transfers.Upload.Limits; // resolve the limits for this user's group. - Options.LimitsOptions limits; + Options.TransfersOptions.LimitsOptions limits; - if (Options.Groups.UserDefined.TryGetValue(group, out var userDefinedOptions)) + if (Options.Transfers.Groups.UserDefined.TryGetValue(group, out var userDefinedOptions)) { - limits = userDefinedOptions.Limits; + limits = userDefinedOptions.Upload.Limits; } else { limits = group switch { - DefaultGroup => Options.Groups.Default.Limits, - LeecherGroup => Options.Groups.Leechers.Limits, - _ => Options.Groups.Default.Limits, // that's weird! we'll just go with defaults.. + DefaultGroup => Options.Transfers.Groups.Default.Upload.Limits, + LeecherGroup => Options.Transfers.Groups.Leechers.Upload.Limits, + _ => Options.Transfers.Groups.Default.Upload.Limits, // that's weird! we'll just go with defaults.. }; } - bool IsNull(Options.LimitsOptions.Limits lim, Options.LimitsOptions.Limits global) + bool IsNull(Options.TransfersOptions.LimitsOptions.Limits lim, Options.TransfersOptions.LimitsOptions.Limits global) => (lim is null && global is null) || ((lim?.Files ?? global?.Files ?? lim?.Megabytes ?? global?.Megabytes ?? lim.Failures ?? global.Failures) is null); /* @@ -692,8 +692,8 @@ namespace slskd (bool Files, bool Megabytes) OverLimits( int files, long bytes, - Options.LimitsOptions.Limits options, - Options.LimitsOptions.Limits defaults, + Options.TransfersOptions.LimitsOptions.Limits options, + Options.TransfersOptions.LimitsOptions.Limits defaults, long size) { var filesOver = false; @@ -1482,7 +1482,7 @@ namespace slskd // determine whether any Soulseek options changed. if so, we need to construct a patch and invoke ReconfigureOptionsAsync(). var slskDiff = PreviousOptions.Soulseek.DiffWith(newOptions.Soulseek); - var globalDiff = PreviousOptions.Global.DiffWith(newOptions.Global); + var globalDiff = PreviousOptions.Transfers.DiffWith(newOptions.Transfers); if (slskDiff.Any() || globalDiff.Any()) { @@ -1544,8 +1544,8 @@ namespace slskd enableDistributedNetwork: old.DistributedNetwork.Disabled == update.DistributedNetwork.Disabled ? null : !update.DistributedNetwork.Disabled, distributedChildLimit: old.DistributedNetwork.ChildLimit == update.DistributedNetwork.ChildLimit ? null : update.DistributedNetwork.ChildLimit, acceptDistributedChildren: old.DistributedNetwork.DisableChildren == update.DistributedNetwork.DisableChildren ? null : !update.DistributedNetwork.DisableChildren, - maximumUploadSpeed: newOptions.Global.Upload.SpeedLimit, - maximumDownloadSpeed: newOptions.Global.Download.SpeedLimit, + maximumUploadSpeed: newOptions.Transfers.Upload.SpeedLimit, + maximumDownloadSpeed: newOptions.Transfers.Download.SpeedLimit, serverConnectionOptions: serverPatch, peerConnectionOptions: connectionPatch, transferConnectionOptions: transferPatch, diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 948bb9a6..8d67e803 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -681,8 +681,8 @@ namespace slskd // complete configuration at startup. services.AddSingleton(_ => new SoulseekClient(options: new SoulseekClientOptions( - maximumConcurrentUploads: OptionsAtStartup.Global.Upload.Slots, - maximumConcurrentDownloads: OptionsAtStartup.Global.Download.Slots, + maximumConcurrentUploads: OptionsAtStartup.Transfers.Upload.Slots, + maximumConcurrentDownloads: OptionsAtStartup.Transfers.Download.Slots, minimumDiagnosticLevel: OptionsAtStartup.Soulseek.DiagnosticLevel.ToEnum(), maximumConcurrentSearches: 2, raiseEventsAsynchronously: true))); diff --git a/src/slskd/Transfers/Uploads/UploadGovernor.cs b/src/slskd/Transfers/Uploads/UploadGovernor.cs index 11fc4dcf..8a035f13 100644 --- a/src/slskd/Transfers/Uploads/UploadGovernor.cs +++ b/src/slskd/Transfers/Uploads/UploadGovernor.cs @@ -139,9 +139,9 @@ namespace slskd.Transfers return new(capacity, interval: intervalInMs); } - var optionsHash = Compute.Sha1Hash(options.Groups.ToJson()); + var optionsHash = Compute.Sha1Hash(options.Transfers.Groups.ToJson()); - if (optionsHash == LastOptionsHash && options.Global.Upload.SpeedLimit == LastGlobalSpeedLimit) + if (optionsHash == LastOptionsHash && options.Transfers.Upload.SpeedLimit == LastGlobalSpeedLimit) { return; } @@ -153,19 +153,19 @@ namespace slskd.Transfers // also, so transfers in progress will briefly exceed the intended speeds. var tokenBuckets = new Dictionary() { - { Application.PrivilegedGroup, CreateBucket(speedInKiB: options.Global.Upload.SpeedLimit) }, - { Application.DefaultGroup, CreateBucket(speedInKiB: options.Groups.Default.Upload.SpeedLimit) }, - { Application.LeecherGroup, CreateBucket(speedInKiB: options.Groups.Leechers.Upload.SpeedLimit) }, + { Application.PrivilegedGroup, CreateBucket(speedInKiB: options.Transfers.Upload.SpeedLimit) }, + { Application.DefaultGroup, CreateBucket(speedInKiB: options.Transfers.Groups.Default.Upload.SpeedLimit) }, + { Application.LeecherGroup, CreateBucket(speedInKiB: options.Transfers.Groups.Leechers.Upload.SpeedLimit) }, }; - foreach (var group in options.Groups.UserDefined) + foreach (var group in options.Transfers.Groups.UserDefined) { tokenBuckets.Add(group.Key, CreateBucket(group.Value.Upload.SpeedLimit)); } TokenBuckets = tokenBuckets; - LastGlobalSpeedLimit = options.Global.Upload.SpeedLimit; + LastGlobalSpeedLimit = options.Transfers.Upload.SpeedLimit; LastOptionsHash = optionsHash; } } diff --git a/src/slskd/Transfers/Uploads/UploadQueue.cs b/src/slskd/Transfers/Uploads/UploadQueue.cs index c20e2312..1ecf264f 100644 --- a/src/slskd/Transfers/Uploads/UploadQueue.cs +++ b/src/slskd/Transfers/Uploads/UploadQueue.cs @@ -403,14 +403,14 @@ namespace slskd.Transfers try { - var optionsHash = Compute.Sha1Hash(options.Groups.ToJson()); + var optionsHash = Compute.Sha1Hash(options.Transfers.Groups.ToJson()); - if (optionsHash == LastOptionsHash && options.Global.Upload.Slots == LastGlobalSlots) + if (optionsHash == LastOptionsHash && options.Transfers.Upload.Slots == LastGlobalSlots) { return; } - GlobalSlots = options.Global.Upload.Slots; + GlobalSlots = options.Transfers.Upload.Slots; // statically add built-in groups var groups = new List() @@ -431,23 +431,23 @@ namespace slskd.Transfers new UploadGroup() { Name = Application.DefaultGroup, - Priority = options.Groups.Default.Upload.Priority, - Slots = Math.Min(options.Groups.Default.Upload.Slots, GlobalSlots), + Priority = options.Transfers.Groups.Default.Upload.Priority, + Slots = Math.Min(options.Transfers.Groups.Default.Upload.Slots, GlobalSlots), UsedSlots = GetExistingUsedSlotsOrDefault(Application.DefaultGroup), - Strategy = options.Groups.Default.Upload.Strategy.ToEnum(), + Strategy = options.Transfers.Groups.Default.Upload.Strategy.ToEnum(), }, new UploadGroup() { Name = Application.LeecherGroup, - Priority = options.Groups.Leechers.Upload.Priority, - Slots = Math.Min(options.Groups.Leechers.Upload.Slots, GlobalSlots), + Priority = options.Transfers.Groups.Leechers.Upload.Priority, + Slots = Math.Min(options.Transfers.Groups.Leechers.Upload.Slots, GlobalSlots), UsedSlots = GetExistingUsedSlotsOrDefault(Application.LeecherGroup), - Strategy = options.Groups.Leechers.Upload.Strategy.ToEnum(), + Strategy = options.Transfers.Groups.Leechers.Upload.Strategy.ToEnum(), }, }; // dynamically add user-defined groups - groups.AddRange(options.Groups.UserDefined.Select(kvp => new UploadGroup() + groups.AddRange(options.Transfers.Groups.UserDefined.Select(kvp => new UploadGroup() { Name = kvp.Key, Priority = kvp.Value.Upload.Priority, @@ -458,7 +458,7 @@ namespace slskd.Transfers Groups = groups.ToDictionary(g => g.Name); - LastGlobalSlots = options.Global.Upload.Slots; + LastGlobalSlots = options.Transfers.Upload.Slots; LastOptionsHash = optionsHash; } finally diff --git a/src/slskd/Users/UserService.cs b/src/slskd/Users/UserService.cs index ead1d812..2939fd17 100644 --- a/src/slskd/Users/UserService.cs +++ b/src/slskd/Users/UserService.cs @@ -172,7 +172,7 @@ namespace slskd.Users return user.Group; } - var thresholds = OptionsMonitor.CurrentValue.Groups.Leechers.Thresholds; + var thresholds = OptionsMonitor.CurrentValue.Transfers.Groups.Leechers.Thresholds; if (user.Statistics?.FileCount < thresholds.Files || user.Statistics?.DirectoryCount < thresholds.Directories) { @@ -276,7 +276,7 @@ namespace slskd.Users /// A value indicating whether the specified user and/or IP are blacklisted. public bool IsBlacklisted(string username, IPAddress ipAddress = null) { - var blacklist = OptionsMonitor.CurrentValue.Groups.Blacklisted; + var blacklist = OptionsMonitor.CurrentValue.Transfers.Groups.Blacklisted; if (blacklist.Members.Contains(username)) { @@ -364,14 +364,14 @@ namespace slskd.Users private void Configure(Options options, bool force = false) { - var optionsHash = Compute.Sha1Hash(options.Groups.UserDefined.ToJson()); + var optionsHash = Compute.Sha1Hash(options.Transfers.Groups.UserDefined.ToJson()); if (optionsHash != LastOptionsHash || force) { // get a list of tracked names that haven't been explicitly added to any group, including those that were previously // configured but have now been removed var usernamesBeforeUpdate = UserDictionary.Keys.ToList(); - var usernamesAfterUpdate = options.Groups.UserDefined.SelectMany(g => g.Value.Members); + var usernamesAfterUpdate = options.Transfers.Groups.UserDefined.SelectMany(g => g.Value.Members); var usernamesRemoved = usernamesBeforeUpdate.Except(usernamesAfterUpdate); // clear the configured group for anyone that was removed from config, or that was added transiently @@ -385,7 +385,7 @@ namespace slskd.Users // sort by priority, descending. this will cause the highest priority group for the user to be persisted when the // operation is complete. - foreach (var group in options.Groups.UserDefined.OrderByDescending(kvp => kvp.Value.Upload.Priority)) + foreach (var group in options.Transfers.Groups.UserDefined.OrderByDescending(kvp => kvp.Value.Upload.Priority)) { foreach (var username in group.Value.Members) { diff --git a/tests/slskd.Tests.Unit/Transfers/Uploads/UploadGovernorTests.cs b/tests/slskd.Tests.Unit/Transfers/Uploads/UploadGovernorTests.cs index 4052236f..acf74e61 100644 --- a/tests/slskd.Tests.Unit/Transfers/Uploads/UploadGovernorTests.cs +++ b/tests/slskd.Tests.Unit/Transfers/Uploads/UploadGovernorTests.cs @@ -30,12 +30,15 @@ { var options = new Options() { - Groups = new Options.GroupsOptions() + Transfers = new Options.TransfersOptions { - UserDefined = new Dictionary() + Groups = new Options.TransfersOptions.GroupsOptions() { - { group1, new Options.GroupsOptions.UserDefinedOptions() }, - { group2, new Options.GroupsOptions.UserDefinedOptions() }, + UserDefined = new Dictionary() + { + { group1, new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() }, + { group2, new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() }, + } } } }; @@ -199,12 +202,15 @@ { var options = new Options() { - Groups = new Options.GroupsOptions() + Transfers = new Options.TransfersOptions { - UserDefined = new Dictionary() - { - { group, new Options.GroupsOptions.UserDefinedOptions() }, - } + Groups = new Options.TransfersOptions.GroupsOptions() + { + UserDefined = new Dictionary() + { + { group, new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() }, + } + } } }; diff --git a/tests/slskd.Tests.Unit/Transfers/Uploads/UploadQueueTests.cs b/tests/slskd.Tests.Unit/Transfers/Uploads/UploadQueueTests.cs index 925ad9b2..e5d6e1b5 100644 --- a/tests/slskd.Tests.Unit/Transfers/Uploads/UploadQueueTests.cs +++ b/tests/slskd.Tests.Unit/Transfers/Uploads/UploadQueueTests.cs @@ -39,7 +39,7 @@ Assert.Equal(Application.PrivilegedGroup, p.Name); Assert.Equal(0, p.Priority); - Assert.Equal(new Options().Global.Upload.Slots, p.Slots); + Assert.Equal(new Options().Transfers.Upload.Slots, p.Slots); Assert.Equal(0, p.UsedSlots); Assert.Equal(QueueStrategy.FirstInFirstOut, p.Strategy); } @@ -49,25 +49,25 @@ { var (queue, _) = GetFixture(new Options() { - Global = new Options.GlobalOptions + Transfers = new Options.TransfersOptions { - Upload = new Options.GlobalOptions.GlobalUploadOptions + Upload = new Options.TransfersOptions.GlobalUploadOptions { Slots = int.MaxValue, }, - }, - Groups = new Options.GroupsOptions() - { - Default = new Options.GroupsOptions.BuiltInOptions() + Groups = new Options.TransfersOptions.GroupsOptions() { - Upload = new Options.GroupsOptions.UploadOptions() + Default = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions() { - Priority = priority, - Slots = slots, - Strategy = strategy.ToString(), + Upload = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions.GroupUploadOptions() + { + Priority = priority, + Slots = slots, + Strategy = strategy.ToString(), + } } } - } + }, }); var groups = queue.GetProperty>("Groups"); @@ -86,23 +86,23 @@ { var (queue, _) = GetFixture(new Options() { - Global = new Options.GlobalOptions + Transfers = new Options.TransfersOptions { - Upload = new Options.GlobalOptions.GlobalUploadOptions + Upload = new Options.TransfersOptions.GlobalUploadOptions { Slots = int.MaxValue, }, - }, - Groups = new Options.GroupsOptions() - { - Leechers = new Options.GroupsOptions.LeecherOptions() + Groups = new Options.TransfersOptions.GroupsOptions() { - Thresholds = new Options.GroupsOptions.ThresholdOptions(), - Upload = new Options.GroupsOptions.UploadOptions() + Leechers = new Options.TransfersOptions.GroupsOptions.LeecherOptions() { - Priority = priority, - Slots = slots, - Strategy = strategy.ToString(), + Thresholds = new Options.TransfersOptions.GroupsOptions.LeecherOptions.ThresholdOptions(), + Upload = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions.GroupUploadOptions() + { + Priority = priority, + Slots = slots, + Strategy = strategy.ToString(), + } } } } @@ -124,38 +124,38 @@ { var (queue, _) = GetFixture(new Options() { - Global = new Options.GlobalOptions + Transfers = new Options.TransfersOptions { - Upload = new Options.GlobalOptions.GlobalUploadOptions + Upload = new Options.TransfersOptions.GlobalUploadOptions { Slots = int.MaxValue, }, - }, - Groups = new Options.GroupsOptions() - { - UserDefined = new Dictionary() + Groups = new Options.TransfersOptions.GroupsOptions() { + UserDefined = new Dictionary() { - group1, - new Options.GroupsOptions.UserDefinedOptions() { - Upload = new Options.GroupsOptions.UploadOptions() + group1, + new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() { - Priority = priority1, - Slots = slots1, - Strategy = strategy1.ToString(), + Upload = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions.GroupUploadOptions() + { + Priority = priority1, + Slots = slots1, + Strategy = strategy1.ToString(), + } } - } - }, - { - group2, - new Options.GroupsOptions.UserDefinedOptions() + }, { - Upload = new Options.GroupsOptions.UploadOptions() + group2, + new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() { - Priority = priority2, - Slots = slots2, - Strategy = strategy2.ToString(), + Upload = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions.GroupUploadOptions() + { + Priority = priority2, + Slots = slots2, + Strategy = strategy2.ToString(), + } } } } @@ -189,29 +189,29 @@ { var options = new Options() { - Global = new Options.GlobalOptions + Transfers = new Options.TransfersOptions { - Upload = new Options.GlobalOptions.GlobalUploadOptions + Upload = new Options.TransfersOptions.GlobalUploadOptions { Slots = int.MaxValue, }, - }, - Groups = new Options.GroupsOptions() - { - UserDefined = new Dictionary() + Groups = new Options.TransfersOptions.GroupsOptions() { + UserDefined = new Dictionary() { - group, - new Options.GroupsOptions.UserDefinedOptions() { - Upload = new Options.GroupsOptions.UploadOptions() + group, + new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() { - Priority = priority, - Slots = slots, - Strategy = strategy.ToString(), + Upload = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions.GroupUploadOptions() + { + Priority = priority, + Slots = slots, + Strategy = strategy.ToString(), + } } - } - }, + }, + } } } }; @@ -246,29 +246,29 @@ { var options = new Options() { - Global = new Options.GlobalOptions + Transfers = new Options.TransfersOptions { - Upload = new Options.GlobalOptions.GlobalUploadOptions + Upload = new Options.TransfersOptions.GlobalUploadOptions { Slots = 42, }, - }, - Groups = new Options.GroupsOptions() - { - UserDefined = new Dictionary() + Groups = new Options.TransfersOptions.GroupsOptions() { + UserDefined = new Dictionary() { - group, - new Options.GroupsOptions.UserDefinedOptions() { - Upload = new Options.GroupsOptions.UploadOptions() + group, + new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() { - Priority = priority, - Slots = int.MaxValue, // lots - Strategy = strategy.ToString(), + Upload = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions.GroupUploadOptions() + { + Priority = priority, + Slots = int.MaxValue, // lots + Strategy = strategy.ToString(), + } } - } - }, + }, + } } } }; @@ -303,22 +303,25 @@ { var options = new Options() { - Groups = new Options.GroupsOptions() + Transfers = new Options.TransfersOptions { - UserDefined = new Dictionary() + Groups = new Options.TransfersOptions.GroupsOptions() { + UserDefined = new Dictionary() { - group, - new Options.GroupsOptions.UserDefinedOptions() { - Upload = new Options.GroupsOptions.UploadOptions() + group, + new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() { - Priority = 0, - Slots = 0, - Strategy = QueueStrategy.FirstInFirstOut.ToString(), + Upload = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions.GroupUploadOptions() + { + Priority = 0, + Slots = 0, + Strategy = QueueStrategy.FirstInFirstOut.ToString(), + } } - } - }, + }, + } } } }; @@ -331,22 +334,25 @@ // reconfigure with different options to bypass the hash check options = new Options() { - Groups = new Options.GroupsOptions() + Transfers = new Options.TransfersOptions { - UserDefined = new Dictionary() + Groups = new Options.TransfersOptions.GroupsOptions() { + UserDefined = new Dictionary() { - group, - new Options.GroupsOptions.UserDefinedOptions() { - Upload = new Options.GroupsOptions.UploadOptions() + group, + new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() { - Priority = newPriority, // change priority - Slots = 0, - Strategy = QueueStrategy.FirstInFirstOut.ToString(), + Upload = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions.GroupUploadOptions() + { + Priority = newPriority, // change priority + Slots = 0, + Strategy = QueueStrategy.FirstInFirstOut.ToString(), + } } - } - }, + }, + } } } }; diff --git a/tests/slskd.Tests.Unit/Users/UserServiceTests.cs b/tests/slskd.Tests.Unit/Users/UserServiceTests.cs index ca45d5b9..7680ec11 100644 --- a/tests/slskd.Tests.Unit/Users/UserServiceTests.cs +++ b/tests/slskd.Tests.Unit/Users/UserServiceTests.cs @@ -32,18 +32,21 @@ { var options = new Options() { - Groups = new Options.GroupsOptions() - { - UserDefined = new Dictionary() + Transfers = new Options.TransfersOptions { + Groups = new Options.TransfersOptions.GroupsOptions() { - group, - new Options.GroupsOptions.UserDefinedOptions() + UserDefined = new Dictionary() { - Members = new[] { username }, + { + group, + new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() + { + Members = new[] { username }, + } + }, } - }, - } + } } }; @@ -60,15 +63,21 @@ { var options = new Options() { - Groups = new Options.GroupsOptions() - { - UserDefined = new Dictionary() + Transfers = new Options.TransfersOptions { - { group, new Options.GroupsOptions.UserDefinedOptions() + Groups = new Options.TransfersOptions.GroupsOptions() { - Members = new[] { user }, - } }, - } + UserDefined = new Dictionary() + { + { + group, + new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() + { + Members = new[] { user }, + } + }, + } + } } }; @@ -89,26 +98,29 @@ { var options = new Options() { - Groups = new Options.GroupsOptions() + Transfers = new Options.TransfersOptions { - UserDefined = new Dictionary() + Groups = new Options.TransfersOptions.GroupsOptions() { + UserDefined = new Dictionary() { - group100, - new Options.GroupsOptions.UserDefinedOptions() { - Upload = new Options.GroupsOptions.UploadOptions() { Priority = 100 }, - Members = new[] { user }, - } - }, - { - group0, - new Options.GroupsOptions.UserDefinedOptions() + group100, + new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() + { + Upload = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions.GroupUploadOptions() { Priority = 100 }, + Members = new[] { user }, + } + }, { - Upload = new Options.GroupsOptions.UploadOptions() { Priority = 0 }, - Members = new[] { user }, - } - }, + group0, + new Options.TransfersOptions.GroupsOptions.UserDefinedOptions() + { + Upload = new Options.TransfersOptions.GroupsOptions.BaseGroupOptions.GroupUploadOptions() { Priority = 0 }, + Members = new[] { user }, + } + }, + } } } }; -- cgit v1.2.3 From 1defeecb62616cad13bdcf2c5c1f1f7e2f5254cb Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 1 Mar 2026 16:50:23 -0600 Subject: disambiguate BaseGroupOptions --- src/slskd/Core/Options.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index c68b6131..bf1378e6 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -988,7 +988,7 @@ namespace slskd /// and have not been added as a member of any group. /// [Validate] - public GroupOptions Default { get; init; } = new GroupOptions(); + public BaseGroupOptions Default { get; init; } = new BaseGroupOptions(); /// /// Gets options for the leecher user group. @@ -1027,7 +1027,7 @@ namespace slskd /// /// Options that are common to all groups. /// - public class GroupOptions + public class BaseGroupOptions { /// /// Gets upload options. @@ -1075,7 +1075,7 @@ namespace slskd /// /// Built in leecher group options. /// - public class LeecherOptions : GroupOptions + public class LeecherOptions : BaseGroupOptions { /// /// Gets leecher threshold options. @@ -1150,7 +1150,7 @@ namespace slskd /// /// User defined user group options. /// - public class UserDefinedOptions : GroupOptions + public class UserDefinedOptions : BaseGroupOptions { /// /// Gets the list of group member usernames. -- cgit v1.2.3 From 83d10be53819a2185e8dc514e96ea6f76f87aa60 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 15 Mar 2026 15:32:35 -0500 Subject: also rename integrations while we're at it --- config/slskd.example.yml | 2 +- src/slskd/Application.cs | 4 ++-- src/slskd/Core/ConnectionWatchdog.cs | 4 ++-- src/slskd/Core/Options.cs | 5 +++-- src/slskd/Integrations/FTP/FTPClientFactory.cs | 4 ++-- src/slskd/Integrations/FTP/FTPService.cs | 4 ++-- src/slskd/Integrations/Pushbullet/PushbulletService.cs | 4 ++-- src/slskd/Integrations/Scripts/ScriptService.cs | 2 +- src/slskd/Integrations/VPN/Clients/Gluetun.cs | 6 +++--- src/slskd/Integrations/VPN/VPNService.cs | 8 ++++---- src/slskd/Integrations/Webhooks/WebhookService.cs | 2 +- src/slskd/Transfers/Downloads/DownloadService.cs | 2 +- 12 files changed, 24 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/config/slskd.example.yml b/config/slskd.example.yml index d0c0f27a..b4843df6 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -230,7 +230,7 @@ # port: ~ # username: ~ # password: ~ -# integration: +# integrations: # vpn: # enabled: false # port_forwarding: false diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 2e9639c6..5519eeac 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1068,7 +1068,7 @@ namespace slskd Messaging.Conversations.HandleMessageAsync(args.Username, PrivateMessage.FromEventArgs(args)); - if (Options.Integration.Pushbullet.Enabled && !args.Replayed) + if (Options.Integrations.Pushbullet.Enabled && !args.Replayed) { _ = Pushbullet.PushAsync($"Private Message from {args.Username}", args.Username, args.Message); } @@ -1086,7 +1086,7 @@ namespace slskd var message = RoomMessage.FromEventArgs(args, DateTime.UtcNow); - if (Options.Integration.Pushbullet.Enabled && message.Message.Contains(Client.Username)) + if (Options.Integrations.Pushbullet.Enabled && message.Message.Contains(Client.Username)) { _ = Pushbullet.PushAsync($"Room Mention by {message.Username} in {message.RoomName}", message.RoomName, message.Message); } diff --git a/src/slskd/Core/ConnectionWatchdog.cs b/src/slskd/Core/ConnectionWatchdog.cs index 1cf1779f..c802e489 100644 --- a/src/slskd/Core/ConnectionWatchdog.cs +++ b/src/slskd/Core/ConnectionWatchdog.cs @@ -115,7 +115,7 @@ namespace slskd /// This should be called at application startup. public virtual void Start() { - if (OptionsAtStartup.Integration.Vpn.Enabled) + if (OptionsAtStartup.Integrations.Vpn.Enabled) { VPN.StartPolling(); } @@ -250,7 +250,7 @@ namespace slskd return; } - if (OptionsAtStartup.Integration.Vpn.Enabled && !VPN.IsReady) + if (OptionsAtStartup.Integrations.Vpn.Enabled && !VPN.IsReady) { IsAwaitingVpn = true; return; diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index bf1378e6..fca2f91c 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -241,6 +241,7 @@ namespace slskd /// /// Gets transfer options. /// + [Validate] public TransfersOptions Transfers { get; init; } = new TransfersOptions(); /// @@ -312,7 +313,7 @@ namespace slskd /// Gets options for external integrations. /// [Validate] - public IntegrationOptions Integration { get; init; } = new IntegrationOptions(); + public IntegrationsOptions Integrations { get; init; } = new IntegrationsOptions(); /// /// Handles top-level validation that doesn't fit anywhere else. @@ -2264,7 +2265,7 @@ namespace slskd /// /// Options for external integrations. /// - public class IntegrationOptions + public class IntegrationsOptions { /// /// Gets VPN options. diff --git a/src/slskd/Integrations/FTP/FTPClientFactory.cs b/src/slskd/Integrations/FTP/FTPClientFactory.cs index 9e5dfc2e..13f78554 100644 --- a/src/slskd/Integrations/FTP/FTPClientFactory.cs +++ b/src/slskd/Integrations/FTP/FTPClientFactory.cs @@ -20,7 +20,7 @@ using Microsoft.Extensions.Options; namespace slskd.Integrations.FTP { using FluentFTP; - using static slskd.Options.IntegrationOptions; + using static slskd.Options.IntegrationsOptions; /// /// FTP client factory. @@ -36,7 +36,7 @@ namespace slskd.Integrations.FTP OptionsMonitor = optionsMonitor; } - private FtpOptions FtpOptions => OptionsMonitor.CurrentValue.Integration.Ftp; + private FtpOptions FtpOptions => OptionsMonitor.CurrentValue.Integrations.Ftp; private IOptionsMonitor OptionsMonitor { get; set; } /// diff --git a/src/slskd/Integrations/FTP/FTPService.cs b/src/slskd/Integrations/FTP/FTPService.cs index ebf34708..81defaaa 100644 --- a/src/slskd/Integrations/FTP/FTPService.cs +++ b/src/slskd/Integrations/FTP/FTPService.cs @@ -26,7 +26,7 @@ namespace slskd.Integrations.FTP using FluentFTP; using FluentFTP.Exceptions; using Microsoft.Extensions.Logging; - using static slskd.Options.IntegrationOptions; + using static slskd.Options.IntegrationsOptions; /// /// FTP Integration service. @@ -50,7 +50,7 @@ namespace slskd.Integrations.FTP } private IFTPClientFactory Factory { get; set; } - private FtpOptions FtpOptions => OptionsMonitor.CurrentValue.Integration.Ftp; + private FtpOptions FtpOptions => OptionsMonitor.CurrentValue.Integrations.Ftp; private ILogger Log { get; set; } private IOptionsMonitor OptionsMonitor { get; } diff --git a/src/slskd/Integrations/Pushbullet/PushbulletService.cs b/src/slskd/Integrations/Pushbullet/PushbulletService.cs index 4c9df98c..2f24befd 100644 --- a/src/slskd/Integrations/Pushbullet/PushbulletService.cs +++ b/src/slskd/Integrations/Pushbullet/PushbulletService.cs @@ -26,7 +26,7 @@ namespace slskd.Integrations.Pushbullet using System.Threading.Tasks; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Logging; - using static slskd.Options.IntegrationOptions; + using static slskd.Options.IntegrationsOptions; /// /// Pushbullet integration service. @@ -57,7 +57,7 @@ namespace slskd.Integrations.Pushbullet private IHttpClientFactory HttpClientFactory { get; } private ILogger Log { get; } private IOptionsMonitor OptionsMonitor { get; } - private PushbulletOptions PushbulletOptions => OptionsMonitor.CurrentValue.Integration.Pushbullet; + private PushbulletOptions PushbulletOptions => OptionsMonitor.CurrentValue.Integrations.Pushbullet; private IMemoryCache RecentlySent { get; } /// diff --git a/src/slskd/Integrations/Scripts/ScriptService.cs b/src/slskd/Integrations/Scripts/ScriptService.cs index f5cc4d4c..9b47afe7 100644 --- a/src/slskd/Integrations/Scripts/ScriptService.cs +++ b/src/slskd/Integrations/Scripts/ScriptService.cs @@ -88,7 +88,7 @@ public class ScriptService bool EqualsLiterallyAnyEvent(string type) => type.Equals(EventType.Any.ToString(), StringComparison.OrdinalIgnoreCase); var options = OptionsMonitor.CurrentValue; - var scriptsTriggeredByThisEventType = options.Integration.Scripts + var scriptsTriggeredByThisEventType = options.Integrations.Scripts .Where(kvp => kvp.Value.On.Any(EqualsThisEvent) || kvp.Value.On.Any(EqualsLiterallyAnyEvent)); foreach (var script in scriptsTriggeredByThisEventType) diff --git a/src/slskd/Integrations/VPN/Clients/Gluetun.cs b/src/slskd/Integrations/VPN/Clients/Gluetun.cs index d22c15f7..136c9c05 100644 --- a/src/slskd/Integrations/VPN/Clients/Gluetun.cs +++ b/src/slskd/Integrations/VPN/Clients/Gluetun.cs @@ -26,7 +26,7 @@ using System.Net.Http.Json; using System.Text.Json.Serialization; using System.Threading.Tasks; using Serilog; -using static slskd.Options.IntegrationOptions.VpnOptions; +using static slskd.Options.IntegrationsOptions.VpnOptions; /// /// Gluetun VPN client. @@ -47,7 +47,7 @@ public class Gluetun : IVPNClient private ILogger Log { get; } = Serilog.Log.ForContext(); private IHttpClientFactory HttpClientFactory { get; } private IOptionsMonitor OptionsMonitor { get; } - private GluetunVpnOptions Options => OptionsMonitor.CurrentValue.Integration.Vpn.Gluetun; + private GluetunVpnOptions Options => OptionsMonitor.CurrentValue.Integrations.Vpn.Gluetun; /// /// Fetch the VPN connection status from the Gluetun control server. @@ -85,7 +85,7 @@ public class Gluetun : IVPNClient int? port = null; - if (OptionsMonitor.CurrentValue.Integration.Vpn.PortForwarding) + if (OptionsMonitor.CurrentValue.Integrations.Vpn.PortForwarding) { port = (await MakeRequest(http, "/v1/portforward"))?.Port; diff --git a/src/slskd/Integrations/VPN/VPNService.cs b/src/slskd/Integrations/VPN/VPNService.cs index db09c041..c0a65f00 100644 --- a/src/slskd/Integrations/VPN/VPNService.cs +++ b/src/slskd/Integrations/VPN/VPNService.cs @@ -52,9 +52,9 @@ public class VPNService : IDisposable SoulseekClient = soulseekClient; HttpClientFactory = httpClientFactory; - if (OptionsAtStartup.Integration.Vpn.Enabled) + if (OptionsAtStartup.Integrations.Vpn.Enabled) { - Timer = new System.Timers.Timer(interval: OptionsAtStartup.Integration.Vpn.PollingInterval) + Timer = new System.Timers.Timer(interval: OptionsAtStartup.Integrations.Vpn.PollingInterval) { AutoReset = true, }; @@ -63,7 +63,7 @@ public class VPNService : IDisposable // detect VPN based on the configuration provided; this logic will determine the order // we can revisit this if/when we add other options besides gluetun - if (!string.IsNullOrEmpty(OptionsMonitor.CurrentValue.Integration.Vpn.Gluetun.Url)) + if (!string.IsNullOrEmpty(OptionsMonitor.CurrentValue.Integrations.Vpn.Gluetun.Url)) { Client = new Gluetun(HttpClientFactory, OptionsMonitor); @@ -154,7 +154,7 @@ public class VPNService : IDisposable throw new VPNClientException("VPN client not properly initialized; something went seriously wrong! Please report to GitHub."); } - var options = OptionsMonitor.CurrentValue.Integration.Vpn; + var options = OptionsMonitor.CurrentValue.Integrations.Vpn; bool isReadyNow = false; VPNStatus status = new VPNStatus(); diff --git a/src/slskd/Integrations/Webhooks/WebhookService.cs b/src/slskd/Integrations/Webhooks/WebhookService.cs index 8a009623..deff3368 100644 --- a/src/slskd/Integrations/Webhooks/WebhookService.cs +++ b/src/slskd/Integrations/Webhooks/WebhookService.cs @@ -73,7 +73,7 @@ public class WebhookService bool EqualsLiterallyAnyEvent(string type) => type.Equals(EventType.Any.ToString(), StringComparison.OrdinalIgnoreCase); var options = OptionsMonitor.CurrentValue; - var webhooksTriggeredByThisEventType = options.Integration.Webhooks + var webhooksTriggeredByThisEventType = options.Integrations.Webhooks .Where(kvp => kvp.Value.On.Any(EqualsThisEvent) || kvp.Value.On.Any(EqualsLiterallyAnyEvent)); foreach (var webhook in webhooksTriggeredByThisEventType) diff --git a/src/slskd/Transfers/Downloads/DownloadService.cs b/src/slskd/Transfers/Downloads/DownloadService.cs index e6a65dcd..0affc4de 100644 --- a/src/slskd/Transfers/Downloads/DownloadService.cs +++ b/src/slskd/Transfers/Downloads/DownloadService.cs @@ -1089,7 +1089,7 @@ namespace slskd.Transfers.Downloads }); } - if (OptionsMonitor.CurrentValue.Integration.Ftp.Enabled) + if (OptionsMonitor.CurrentValue.Integrations.Ftp.Enabled) { _ = FTP.UploadAsync(finalFilename); } -- cgit v1.2.3 From 95a9480978b1cc413fb493d92ed858c05d5f509a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 15 Mar 2026 15:35:41 -0500 Subject: update option diff logic to include only upload/download settings --- src/slskd/Application.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index 5519eeac..5a81ae8f 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -1482,9 +1482,12 @@ namespace slskd // determine whether any Soulseek options changed. if so, we need to construct a patch and invoke ReconfigureOptionsAsync(). var slskDiff = PreviousOptions.Soulseek.DiffWith(newOptions.Soulseek); - var globalDiff = PreviousOptions.Transfers.DiffWith(newOptions.Transfers); - if (slskDiff.Any() || globalDiff.Any()) + // determine whether any global upload or download options changed + var transfersUploadDiff = PreviousOptions.Transfers.DiffWith(newOptions.Transfers.Upload); + var transfersDownloadDiff = PreviousOptions.Transfers.DiffWith(newOptions.Transfers.Download); + + if (slskDiff.Any() || transfersUploadDiff.Any() || transfersDownloadDiff.Any()) { var old = PreviousOptions.Soulseek; var update = newOptions.Soulseek; -- cgit v1.2.3