From 87cafe00355a7b067d2ee6f2ac3c02120ba371b7 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 2 Oct 2014 08:32:32 -0400 Subject: [PATCH] Don't allow port 0 as a listen port Port 0 is not really a valid port. Using it will most likely dynamically allocate a port to listen on. --- src/NzbDrone.Api/Config/HostConfigModule.cs | 2 +- src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NzbDrone.Api/Config/HostConfigModule.cs b/src/NzbDrone.Api/Config/HostConfigModule.cs index 1c9d37aa7..c5103222c 100644 --- a/src/NzbDrone.Api/Config/HostConfigModule.cs +++ b/src/NzbDrone.Api/Config/HostConfigModule.cs @@ -24,7 +24,7 @@ namespace NzbDrone.Api.Config UpdateResource = SaveHostConfig; SharedValidator.RuleFor(c => c.Branch).NotEmpty().WithMessage("Branch name is required, 'master' is the default"); - SharedValidator.RuleFor(c => c.Port).InclusiveBetween(1, 65535); + SharedValidator.RuleFor(c => c.Port).ValidPort(); SharedValidator.RuleFor(c => c.Username).NotEmpty().When(c => c.AuthenticationEnabled); SharedValidator.RuleFor(c => c.Password).NotEmpty().When(c => c.AuthenticationEnabled); diff --git a/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs b/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs index 39a3826d3..b0fb71377 100644 --- a/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs +++ b/src/NzbDrone.Core/Validation/RuleBuilderExtensions.cs @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Validation public static IRuleBuilderOptions ValidPort(this IRuleBuilder ruleBuilder) { - return ruleBuilder.SetValidator(new InclusiveBetweenValidator(0, 65535)); + return ruleBuilder.SetValidator(new InclusiveBetweenValidator(1, 65535)); } public static IRuleBuilderOptions ValidLanguage(this IRuleBuilder ruleBuilder)