From e49ce88e3487f424b2fc824d13b08086f00f633e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 4 Feb 2024 16:00:49 -0600 Subject: add global limits --- src/slskd/Core/Options.cs | 102 ++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 2aadf206..992541bc 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -786,6 +786,12 @@ namespace slskd [Validate] public GlobalUploadOptions Upload { get; init; } = new GlobalUploadOptions(); + /// + /// Gets global limits. + /// + [Validate] + public LimitsOptions Limits { get; init; } = new LimitsOptions(); + /// /// Gets global download options. /// @@ -843,6 +849,54 @@ namespace slskd } } + /// + /// 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. + /// + public class Limits + { + /// + /// Gets the limit for number of files. + /// + [Range(1, int.MaxValue)] + public int? Files { get; init; } = null; + + /// + /// Gets the limit for number of megabytes. + /// + [Range(1, int.MaxValue)] + public int? Megabytes { get; init; } = null; + + /// + /// Gets the limit for number of failures. + /// + [Range(1, int.MaxValue)] + public int? Failures { get; init; } = null; + } + } + /// /// User groups. /// @@ -1027,54 +1081,6 @@ namespace slskd [Range(1, int.MaxValue)] public int SpeedLimit { get; init; } = int.MaxValue; } - - /// - /// Upload limit options. - /// - public class LimitsOptions - { - /// - /// Gets limits for queued transfers. - /// - [Validate] - public LimitsExtendedOptions Queued { get; init; } = new LimitsExtendedOptions(); - - /// - /// Gets daily limits for transfers. - /// - [Validate] - public LimitsExtendedOptions Daily { get; init; } = new LimitsExtendedOptions(); - - /// - /// Gets weekly limits for transfers. - /// - [Validate] - public LimitsExtendedOptions Weekly { get; init; } = new LimitsExtendedOptions(); - } - - /// - /// Extended limit options. - /// - public class LimitsExtendedOptions - { - /// - /// Gets the limit for number of files. - /// - [Range(-1, int.MaxValue)] - public int? Files { get; init; } = null; - - /// - /// Gets the limit for number of megabytes. - /// - [Range(-1, int.MaxValue)] - public int? Megabytes { get; init; } = null; - - /// - /// Gets the limit for number of failures. - /// - [Range(-1, int.MaxValue)] - public int? Failures { get; init; } = null; - } } /// -- cgit v1.2.3