From c042007803f3e4291a75d29ead84a2230f89b205 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Fri, 18 Nov 2022 14:18:56 -0600 Subject: add Enabled option --- config/slskd.example.yml | 1 + src/slskd/Core/Options.cs | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config/slskd.example.yml b/config/slskd.example.yml index a1a5d825..02ccbe7f 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -12,6 +12,7 @@ # experimental: false # volatile: false # relay: +# enabled: false # mode: controller # controller (default), agent, or debug (for local development) # # controller config is required when running in 'agent' mode # # this specifies the relay controller that will be controlling this agent diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs index 3a61e376..368b5ca0 100644 --- a/src/slskd/Core/Options.cs +++ b/src/slskd/Core/Options.cs @@ -389,14 +389,23 @@ namespace slskd public class RelayOptions : IValidatableObject { /// - /// Gets the application operation mode. + /// Gets a value indicating whether the relay is enabled. + /// + [Argument('r', "relay")] + [EnvironmentVariable("RELAY")] + [Description("enable relay")] + [RequiresRestart] + public bool Enabled { get; init; } = false; + + /// + /// Gets the relay operation mode. /// [Argument('m', "relay-operation-mode")] [EnvironmentVariable("RELAY_OPERATION_MODE")] [Description("relay operation mode; controller, agent")] [RequiresRestart] [Enum(typeof(OperationMode))] - public string Mode { get; init; } = slskd.Relay.OperationMode.Controller.ToString().ToLowerInvariant(); + public string Mode { get; init; } = OperationMode.Controller.ToString().ToLowerInvariant(); /// /// Gets the controller configuration. @@ -414,7 +423,7 @@ namespace slskd var results = new List(); var modeResults = new List(); - if (mode == slskd.Relay.OperationMode.Agent && !Validator.TryValidateObject(Controller, new ValidationContext(Controller), modeResults, validateAllProperties: true)) + if (mode == OperationMode.Agent && !Validator.TryValidateObject(Controller, new ValidationContext(Controller), modeResults, validateAllProperties: true)) { results.Add(new CompositeValidationResult("Controller", modeResults)); } -- cgit v1.2.3