From 196361b38188276531c005855f9c8d6491762605 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 12 Jan 2022 09:04:57 -0600 Subject: tweak naming of global upload slot limit --- src/slskd/Options.cs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/slskd/Options.cs') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 900f2cd4..6b3d07ac 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify @@ -228,10 +228,11 @@ namespace slskd public DirectoriesOptions Directories { get; init; } = new DirectoriesOptions(); /// - /// Gets limits. + /// Gets global options. /// [Validate] - public LimitsOptions Limits { get; init; } = new LimitsOptions(); + public GlobalOptions Global { get; init; } = new GlobalOptions(); + /// /// Gets filter options. @@ -385,27 +386,27 @@ namespace slskd } /// - /// Limits. + /// Global options. /// - public class LimitsOptions + public class GlobalOptions { /// - /// Gets queue limits. + /// Gets global upload options. /// [Validate] - public LimitsQueueOptions Queue { get; init; } = new LimitsQueueOptions(); + public GlobalUploadOptions Upload { get; init; } = new GlobalUploadOptions(); /// - /// Queue limits. + /// Global upload options. /// - public class LimitsQueueOptions + public class GlobalUploadOptions { /// /// Gets the limit for the total number of queue slots. /// - [Argument(default, "queue-slot-limit")] - [EnvironmentVariable("QUEUE_SLOT_LIMIT")] - [Description("the limit for the total number of queue slots")] + [Argument(default, "upload-slots")] + [EnvironmentVariable("UPLOAD_SLOTS")] + [Description("the total number of upload slots")] [RequiresRestart] [Range(1, int.MaxValue)] public int Slots { get; init; } = 10; -- cgit v1.2.3 From c32e83489eb621a97a5395d31c3d90bd4c7b3666 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Wed, 12 Jan 2022 09:06:17 -0600 Subject: rough in group config --- config/slskd.example.yml | 20 ++++++++++++++++++++ src/slskd/Options.cs | 41 +++++++++++++++++++++++++++++++++++++++-- src/slskd/Startup.cs | 2 +- 3 files changed, 60 insertions(+), 3 deletions(-) (limited to 'src/slskd/Options.cs') diff --git a/config/slskd.example.yml b/config/slskd.example.yml index 56d0348c..72203d5e 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -14,6 +14,26 @@ # global: # upload: # slots: 20 +# groups: +# default: +# upload: +# priority: 500 +# strategy: roundrobin +# slots: 10 +# leechers: +# upload: +# priority: 1000 +# queue_strategy: roundrobin +# slots: 1 +# user_defined: +# my_buddies: +# upload: +# priority: 250 +# queue_strategy: firstinfirstout +# slots: 10 +# members: +# - alice +# - bob # filters: # share: # - \.ini$ diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 6b3d07ac..467c4bec 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify @@ -233,6 +233,11 @@ namespace slskd [Validate] public GlobalOptions Global { get; init; } = new GlobalOptions(); + /// + /// Gets user groups. + /// + [Validate] + public GroupsOptions Groups { get; init; } = new GroupsOptions(); /// /// Gets filter options. @@ -413,6 +418,38 @@ namespace slskd } } + /// + /// User groups. + /// + public class GroupsOptions + { + public BuiltInGroupOptions Default { get; init; } = new BuiltInGroupOptions(); + public BuiltInGroupOptions Leechers { get; init; } = new BuiltInGroupOptions(); + + public class BuiltInGroupOptions + { + public GroupUploadOptions Upload { get; init; } = new GroupUploadOptions(); + } + + public class UserDefinedGroupOptions + { + public GroupUploadOptions Upload { get; init; } = new GroupUploadOptions(); + public string[] Members { get; init; } = Array.Empty(); + } + + public class GroupUploadOptions + { + [Range(1, int.MaxValue)] + public int Priority { get; init; } + + [Enum(typeof(QueueStrategy))] + public string QueueStrategy { get; init; } = slskd.QueueStrategy.RoundRobin.ToString().ToLowerInvariant(); + + [Range(1, int.MaxValue)] + public int Slots { get; init; } = 10; + } + } + /// /// Feature options. /// @@ -973,7 +1010,7 @@ namespace slskd [EnvironmentVariable("FTP_ENCRYPTION_MODE")] [Description("FTP encryption mode; none, implicit, explicit, auto")] [Enum(typeof(FtpEncryptionMode))] - public string EncryptionMode { get; init; } = "auto"; + public string EncryptionMode { get; init; } = FtpEncryptionMode.Auto.ToString().ToLowerInvariant(); /// /// Gets a value indicating whether FTP certificate errors should be ignored. diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs index 59557a81..dfe12824 100644 --- a/src/slskd/Startup.cs +++ b/src/slskd/Startup.cs @@ -1,4 +1,4 @@ -// +// // Copyright (c) slskd Team. All rights reserved. // // This program is free software: you can redistribute it and/or modify -- cgit v1.2.3 From 72641b2f4154cec8b8c470ffcff456be31e6169d Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 14 Jan 2022 15:29:14 -0600 Subject: docs for group options --- src/slskd/Options.cs | 47 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 4 deletions(-) (limited to 'src/slskd/Options.cs') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 467c4bec..e63a3b48 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -407,7 +407,7 @@ namespace slskd public class GlobalUploadOptions { /// - /// Gets the limit for the total number of queue slots. + /// Gets the limit for the total number of upload slots. /// [Argument(default, "upload-slots")] [EnvironmentVariable("UPLOAD_SLOTS")] @@ -423,28 +423,67 @@ namespace slskd /// public class GroupsOptions { + /// + /// Gets options for the default user group. + /// + [Validate] public BuiltInGroupOptions Default { get; init; } = new BuiltInGroupOptions(); - public BuiltInGroupOptions Leechers { get; init; } = new BuiltInGroupOptions(); + /// + /// Gets options for the leecher user group. + /// + [Validate] + public BuiltInGroupOptions Leechers { get; init; } = new BuiltInGroupOptions() { Upload = new GroupUploadOptions() { Priority = 99, Slots = 1 } }; + + /// + /// Built in user group options. + /// public class BuiltInGroupOptions { + /// + /// Gets upload options. + /// + [Validate] public GroupUploadOptions Upload { get; init; } = new GroupUploadOptions(); } + /// + /// User defined user group options. + /// public class UserDefinedGroupOptions { + /// + /// Gets upload options. + /// + [Validate] public GroupUploadOptions Upload { get; init; } = new GroupUploadOptions(); + + /// + /// Gets the list of group member usernames. + /// public string[] Members { get; init; } = Array.Empty(); } + /// + /// User group upload options. + /// public class GroupUploadOptions { + /// + /// Gets the priority of the group. + /// [Range(1, int.MaxValue)] - public int Priority { get; init; } + public int Priority { get; init; } = 1; + /// + /// Gets the queue strategy for the group. + /// [Enum(typeof(QueueStrategy))] - public string QueueStrategy { get; init; } = slskd.QueueStrategy.RoundRobin.ToString().ToLowerInvariant(); + public string Strategy { get; init; } = slskd.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; } = 10; } -- cgit v1.2.3 From ab656f0feed130a1e7e58509a794e08c68de664d Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 24 Jan 2022 08:05:13 -0600 Subject: add global download options --- src/slskd/Options.cs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/slskd/Options.cs') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index e63a3b48..7c9fae0a 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -401,6 +401,12 @@ namespace slskd [Validate] public GlobalUploadOptions Upload { get; init; } = new GlobalUploadOptions(); + /// + /// Gets global download options. + /// + [Validate] + public GlobalDownloadOptions Download { get; init; } = new GlobalDownloadOptions(); + /// /// Global upload options. /// @@ -415,6 +421,30 @@ namespace slskd [RequiresRestart] [Range(1, int.MaxValue)] public int Slots { get; init; } = 10; + + /// + /// Gets the total upload speed limit. + /// + [Argument(default, "upload-speed-limit")] + [EnvironmentVariable("UPLOAD_SPEED_LIMIT")] + [Description("the total upload speed limit")] + [Range(1, int.MaxValue)] + public int SpeedLimit { get; init; } = int.MaxValue; + } + + /// + /// Gets global download options. + /// + public class GlobalDownloadOptions + { + /// + /// Gets the total download speed limit. + /// + [Argument(default, "download-speed-limit")] + [EnvironmentVariable("DOWNLOAD_SPEED_LIMIT")] + [Description("the total download speed limit")] + [Range(1, int.MaxValue)] + public int SpeedLimit { get; init; } = int.MaxValue; } } -- cgit v1.2.3 From 299dbc204c182ca57ad5f08743db1ec8219b5b74 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 30 Jan 2022 10:24:02 -0600 Subject: add download slot config --- src/slskd/Options.cs | 10 ++++++++++ src/slskd/Startup.cs | 1 + 2 files changed, 11 insertions(+) (limited to 'src/slskd/Options.cs') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 7c9fae0a..5f674eaf 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -437,6 +437,16 @@ namespace slskd /// public class GlobalDownloadOptions { + /// + /// Gets the limit for the total number of download slots. + /// + [Argument(default, "download-slots")] + [EnvironmentVariable("DOWNLOAD_SLOTS")] + [Description("the total number of download slots")] + [RequiresRestart] + [Range(1, int.MaxValue)] + public int Slots { get; init; } = int.MaxValue; + /// /// Gets the total download speed limit. /// diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs index dfe12824..658f62f8 100644 --- a/src/slskd/Startup.cs +++ b/src/slskd/Startup.cs @@ -236,6 +236,7 @@ namespace slskd services.AddSingleton(_ => new SoulseekClient(options: new SoulseekClientOptions( maximumConcurrentUploads: OptionsAtStartup.Global.Upload.Slots, + maximumConcurrentDownloads: OptionsAtStartup.Global.Download.Slots, minimumDiagnosticLevel: OptionsAtStartup.Soulseek.DiagnosticLevel))); // add the core application service to DI as well as a hosted service so that other services can -- cgit v1.2.3 From 24dc05d101691e7c3216eca767d329af795c0036 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 30 Jan 2022 11:09:13 -0600 Subject: temporarily remove leecher built in group --- config/slskd.example.yml | 5 ----- src/slskd/Options.cs | 8 +------- 2 files changed, 1 insertion(+), 12 deletions(-) (limited to 'src/slskd/Options.cs') diff --git a/config/slskd.example.yml b/config/slskd.example.yml index eeb9b677..bff2df5b 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -24,11 +24,6 @@ # priority: 500 # strategy: roundrobin # slots: 10 -# leechers: -# upload: -# priority: 1000 -# queue_strategy: roundrobin -# slots: 1 # user_defined: # my_buddies: # upload: diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 5f674eaf..6b3bafa2 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -469,12 +469,6 @@ namespace slskd [Validate] public BuiltInGroupOptions Default { get; init; } = new BuiltInGroupOptions(); - /// - /// Gets options for the leecher user group. - /// - [Validate] - public BuiltInGroupOptions Leechers { get; init; } = new BuiltInGroupOptions() { Upload = new GroupUploadOptions() { Priority = 99, Slots = 1 } }; - /// /// Built in user group options. /// @@ -519,7 +513,7 @@ namespace slskd /// Gets the queue strategy for the group. /// [Enum(typeof(QueueStrategy))] - public string Strategy { get; init; } = slskd.QueueStrategy.RoundRobin.ToString().ToLowerInvariant(); + public string Strategy { get; init; } = QueueStrategy.RoundRobin.ToString().ToLowerInvariant(); /// /// Gets the limit for the total number of upload slots for the group. -- cgit v1.2.3 From 33d10909007fcaaee16aa455b2bb24488ba17d19 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 30 Jan 2022 13:19:17 -0600 Subject: simplify type names --- src/slskd/Options.cs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src/slskd/Options.cs') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 6b3bafa2..8acd5a11 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -399,18 +399,18 @@ namespace slskd /// Gets global upload options. /// [Validate] - public GlobalUploadOptions Upload { get; init; } = new GlobalUploadOptions(); + public UploadOptions Upload { get; init; } = new UploadOptions(); /// /// Gets global download options. /// [Validate] - public GlobalDownloadOptions Download { get; init; } = new GlobalDownloadOptions(); + public DownloadOptions Download { get; init; } = new DownloadOptions(); /// /// Global upload options. /// - public class GlobalUploadOptions + public class UploadOptions { /// /// Gets the limit for the total number of upload slots. @@ -435,7 +435,7 @@ namespace slskd /// /// Gets global download options. /// - public class GlobalDownloadOptions + public class DownloadOptions { /// /// Gets the limit for the total number of download slots. @@ -467,30 +467,36 @@ namespace slskd /// Gets options for the default user group. /// [Validate] - public BuiltInGroupOptions Default { get; init; } = new BuiltInGroupOptions(); + public BuiltInOptions Default { get; init; } = new BuiltInOptions(); + + /// + /// Gets user defined groups and options. + /// + [Validate] + public Dictionary UserDefined { get; init; } = new Dictionary(); /// /// Built in user group options. /// - public class BuiltInGroupOptions + public class BuiltInOptions { /// /// Gets upload options. /// [Validate] - public GroupUploadOptions Upload { get; init; } = new GroupUploadOptions(); + public UploadOptions Upload { get; init; } = new UploadOptions(); } /// /// User defined user group options. /// - public class UserDefinedGroupOptions + public class UserDefinedOptions { /// /// Gets upload options. /// [Validate] - public GroupUploadOptions Upload { get; init; } = new GroupUploadOptions(); + public UploadOptions Upload { get; init; } = new UploadOptions(); /// /// Gets the list of group member usernames. @@ -501,7 +507,7 @@ namespace slskd /// /// User group upload options. /// - public class GroupUploadOptions + public class UploadOptions { /// /// Gets the priority of the group. -- cgit v1.2.3 From ee21f4514305fb1ff213aae016817b7ff25d628d Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 30 Jan 2022 21:08:24 -0600 Subject: add SpeedLimit to UploadOptions --- src/slskd/Options.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/slskd/Options.cs') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 8acd5a11..302b01d0 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -526,6 +526,12 @@ namespace slskd /// [Range(1, int.MaxValue)] public int Slots { get; init; } = 10; + + /// + /// Gets the total upload speed limit for the group. + /// + [Range(1, int.MaxValue)] + public int SpeedLimit { get; init; } = int.MaxValue; } } -- cgit v1.2.3 From a7d5a64092cd76b632aeac9d8476d912c96adf5b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 1 Feb 2022 09:01:48 -0600 Subject: disambiguate class name for swagger serialization --- src/slskd/Options.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/slskd/Options.cs') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 302b01d0..b97c40d1 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -399,18 +399,18 @@ namespace slskd /// Gets global upload options. /// [Validate] - public UploadOptions Upload { get; init; } = new UploadOptions(); + public GlobalUploadOptions Upload { get; init; } = new GlobalUploadOptions(); /// /// Gets global download options. /// [Validate] - public DownloadOptions Download { get; init; } = new DownloadOptions(); + public GlobalDownloadOptions Download { get; init; } = new GlobalDownloadOptions(); /// /// Global upload options. /// - public class UploadOptions + public class GlobalUploadOptions { /// /// Gets the limit for the total number of upload slots. @@ -435,7 +435,7 @@ namespace slskd /// /// Gets global download options. /// - public class DownloadOptions + public class GlobalDownloadOptions { /// /// Gets the limit for the total number of download slots. -- cgit v1.2.3 From 40b858f4710a3762390cfa0eb9415caeaa6ed39e Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Thu, 3 Feb 2022 09:36:34 -0600 Subject: validate group overlap --- src/slskd/Options.cs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/slskd/Options.cs') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index b97c40d1..f7e1266d 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -461,20 +461,46 @@ namespace slskd /// /// User groups. /// - public class GroupsOptions + public class GroupsOptions : IValidatableObject { /// /// Gets options for the default user group. /// + /// + /// These options apply to users that are not priviledged, 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 BuiltInOptions Leechers { get; init; } = new BuiltInOptions(); + /// /// 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.PriviledgedGroup, 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.")); + } + /// /// Built in user group options. /// -- cgit v1.2.3 From 336934033515650e271fd4d7d517600644693667 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Tue, 15 Feb 2022 21:32:18 -0600 Subject: default group slots to int.MaxValue --- src/slskd/Options.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/slskd/Options.cs') diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index f7e1266d..2313ce69 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -551,7 +551,7 @@ namespace slskd /// Gets the limit for the total number of upload slots for the group. /// [Range(1, int.MaxValue)] - public int Slots { get; init; } = 10; + public int Slots { get; init; } = int.MaxValue; /// /// Gets the total upload speed limit for the group. -- cgit v1.2.3