diff options
| author | JP Dillingham <jp@dillingham.me> | 2024-01-20 11:15:23 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-20 11:15:23 -0600 |
| commit | 9c0a10048e34106fdf744cb2351da6a5b6f6223d (patch) | |
| tree | 609f0f7c6645fc1f6bf05c1c413b881f8dd1971a /src/slskd/Core/Options.cs | |
| parent | 8bfce5d955aeea9a95ee76a5eecd5fa77454425a (diff) | |
| parent | 84acaed78564bed6c251de7b0d94bea43fecc7dc (diff) | |
| download | slskd-9c0a10048e34106fdf744cb2351da6a5b6f6223d.tar.gz | |
Merge pull request #1035 from slskd/quotas
Add configurable limits for number (and size) of queued files, daily and weekly completions
Diffstat (limited to 'src/slskd/Core/Options.cs')
| -rw-r--r-- | src/slskd/Core/Options.cs | 77 |
1 files changed, 61 insertions, 16 deletions
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 94f8618d..c1f4d558 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -682,7 +682,9 @@ namespace slskd return (share, matches[0].Groups[2].Value, matches[0].Groups[3].Value); } +#pragma warning disable S3878 // Arrays should not be created for params parameters return (share, share.Split(new[] { '/', '\\' }).Last(), share); +#pragma warning restore S3878 // Arrays should not be created for params parameters } var digestedShared = directories @@ -882,15 +884,28 @@ namespace slskd } /// <summary> - /// Built in user group options. + /// Options that are common to all groups. /// </summary> - public class BuiltInOptions + public class GroupOptions { /// <summary> /// Gets upload options. /// </summary> [Validate] public UploadOptions Upload { get; init; } = new UploadOptions(); + + /// <summary> + /// Gets limit options. + /// </summary> + [Validate] + public LimitsOptions Limits { get; init; } = new LimitsOptions(); + } + + /// <summary> + /// Built in user group options. + /// </summary> + public class BuiltInOptions : GroupOptions + { } /// <summary> @@ -936,19 +951,13 @@ namespace slskd /// <summary> /// Built in leecher group options. /// </summary> - public class LeecherOptions + public class LeecherOptions : GroupOptions { /// <summary> /// Gets leecher threshold options. /// </summary> [Validate] public ThresholdOptions Thresholds { get; init; } = new ThresholdOptions(); - - /// <summary> - /// Gets upload options. - /// </summary> - [Validate] - public UploadOptions Upload { get; init; } = new UploadOptions(); } /// <summary> @@ -972,15 +981,9 @@ namespace slskd /// <summary> /// User defined user group options. /// </summary> - public class UserDefinedOptions + public class UserDefinedOptions : GroupOptions { /// <summary> - /// Gets upload options. - /// </summary> - [Validate] - public UploadOptions Upload { get; init; } = new UploadOptions(); - - /// <summary> /// Gets the list of group member usernames. /// </summary> public string[] Members { get; init; } = Array.Empty<string>(); @@ -1015,6 +1018,48 @@ namespace slskd [Range(1, int.MaxValue)] public int SpeedLimit { get; init; } = int.MaxValue; } + + /// <summary> + /// Upload limit options. + /// </summary> + public class LimitsOptions + { + /// <summary> + /// Gets limits for queued transfers. + /// </summary> + [Validate] + public LimitsExtendedOptions Queued { get; init; } = new LimitsExtendedOptions(); + + /// <summary> + /// Gets daily limits for transfers. + /// </summary> + [Validate] + public LimitsExtendedOptions Daily { get; init; } = new LimitsExtendedOptions(); + + /// <summary> + /// Gets weekly limits for transfers. + /// </summary> + [Validate] + public LimitsExtendedOptions Weekly { get; init; } = new LimitsExtendedOptions(); + } + + /// <summary> + /// Extended limit options. + /// </summary> + public class LimitsExtendedOptions + { + /// <summary> + /// Gets the limit for number of files. + /// </summary> + [Range(1, int.MaxValue)] + public int? Files { get; init; } = null; + + /// <summary> + /// Gets the limit for number of megabytes. + /// </summary> + [Range(1, int.MaxValue)] + public int? Megabytes { get; init; } = null; + } } /// <summary> |
