diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Options.cs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index f93e5d4a..b2476364 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -407,9 +407,17 @@ namespace slskd /// <summary> /// Connection proxy options. /// </summary> - public class ProxyOptions + public class ProxyOptions : IValidatableObject { /// <summary> + /// Gets a value indicating whether the proxy is enabled. + /// </summary> + [Argument(default, "slsk-proxy")] + [EnvironmentVariable("SLSK_PROXY_ENABLED")] + [Description("enable connection proxy")] + public bool Enabled { get; private set; } = false; + + /// <summary> /// Gets the proxy address. /// </summary> [Argument(default, "slsk-proxy-address")] @@ -444,6 +452,23 @@ namespace slskd [Description("connection proxy password")] [StringLength(255, MinimumLength = 1)] public string Password { get; private set; } + + public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) + { + var results = new List<ValidationResult>(); + + if (Enabled && string.IsNullOrWhiteSpace(Address)) + { + results.Add(new ValidationResult($"The Enabled field is true, but no Address has been specified.")); + } + + if (Enabled && !Port.HasValue) + { + results.Add(new ValidationResult($"The Enabled field is true, but no Port has been specified.")); + } + + return results; + } } } |
