Skip to content

Commit e836e0a

Browse files
author
Christian
committed
fixing broken implementation for ips
1 parent 25073c2 commit e836e0a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/ServiceControl.Config/UI/InstanceAdd/ServiceControlAddViewModelValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public ServiceControlAddViewModelValidator()
157157
RuleFor(viewModel => viewModel.AuditHostName)
158158
.NotEmpty()
159159
.ValidHostname()
160-
.When(viewModel => viewModel.InstallAuditInstance);
160+
.When(viewModel => viewModel.InstallAuditInstance && viewModel.SubmitAttempted);
161161

162162
RuleFor(x => x.AuditPortNumber)
163163
.NotEmpty()

src/ServiceControl.Config/Validation/Validations.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,16 @@ public static IRuleBuilderOptions<T, string> MustBeUniqueWindowsServiceName<T>(t
205205
public static IRuleBuilderOptions<T, string> ValidHostname<T>(this IRuleBuilder<T, string> ruleBuilder)
206206
{
207207
return ruleBuilder.Must((t, hostname) =>
208-
!string.IsNullOrWhiteSpace(hostname) &&
209-
Uri.CheckHostName(hostname) == UriHostNameType.Dns)
210-
.WithMessage(MSG_INVALID_HOSTNAME);
208+
{
209+
if (string.IsNullOrWhiteSpace(hostname))
210+
{
211+
return false;
212+
}
213+
214+
var hostNameType = Uri.CheckHostName(hostname);
215+
return hostNameType is UriHostNameType.Dns or UriHostNameType.IPv4 or UriHostNameType.IPv6;
216+
})
217+
.WithMessage(MSG_INVALID_HOSTNAME);
211218
}
212219

213220
public const string MSG_EMAIL_NOT_VALID = "Not Valid.";

0 commit comments

Comments
 (0)