From e91c60a7538c9ee36daf5cf5f4ce1058f4927552 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sat, 23 May 2020 13:15:22 -0500 Subject: [PATCH] [issue 137] custom display hostnames for webfront --- SharedLibraryCore/Configuration/ServerConfiguration.cs | 3 +++ .../Validation/ServerConfigurationValidator.cs | 6 +++++- SharedLibraryCore/Server.cs | 3 ++- .../Shared/EditorTemplates/ServerConfiguration.cshtml | 9 ++++++--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/SharedLibraryCore/Configuration/ServerConfiguration.cs b/SharedLibraryCore/Configuration/ServerConfiguration.cs index 18dc73d4b..65c2f4cc1 100644 --- a/SharedLibraryCore/Configuration/ServerConfiguration.cs +++ b/SharedLibraryCore/Configuration/ServerConfiguration.cs @@ -30,6 +30,9 @@ namespace SharedLibraryCore.Configuration [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_GAME_LOG_SERVER")] [ConfigurationOptional] public Uri GameLogServerUrl { get; set; } + [LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_CUSTOM_HOSTNAME")] + [ConfigurationOptional] + public string CustomHostname { get; set; } private readonly IList rconParsers; private readonly IList eventParsers; diff --git a/SharedLibraryCore/Configuration/Validation/ServerConfigurationValidator.cs b/SharedLibraryCore/Configuration/Validation/ServerConfigurationValidator.cs index eb7397e3b..5be315964 100644 --- a/SharedLibraryCore/Configuration/Validation/ServerConfigurationValidator.cs +++ b/SharedLibraryCore/Configuration/Validation/ServerConfigurationValidator.cs @@ -15,7 +15,7 @@ namespace SharedLibraryCore.Configuration.Validation .Must(_address => IPAddress.TryParse(_address, out _)); RuleFor(_server => _server.Port) - .InclusiveBetween(0, ushort.MaxValue); + .InclusiveBetween(1, ushort.MaxValue); RuleFor(_server => _server.Password) .NotEmpty(); @@ -28,6 +28,10 @@ namespace SharedLibraryCore.Configuration.Validation RuleFor(_server => _server.ReservedSlotNumber) .InclusiveBetween(0, 32); + + RuleFor(_server => _server.CustomHostname) + .MinimumLength(3) + .MaximumLength(128); } } } diff --git a/SharedLibraryCore/Server.cs b/SharedLibraryCore/Server.cs index 6e675bd67..1b9f72f15 100644 --- a/SharedLibraryCore/Server.cs +++ b/SharedLibraryCore/Server.cs @@ -289,7 +289,8 @@ namespace SharedLibraryCore public Game GameName { get; set; } // Info - public string Hostname { get; protected set; } + private string hostname; + public string Hostname { get => ServerConfig.CustomHostname ?? hostname; protected set => hostname = value; } public string Website { get; protected set; } public string Gametype { get; set; } public Map CurrentMap { get; set; } diff --git a/WebfrontCore/Views/Shared/EditorTemplates/ServerConfiguration.cshtml b/WebfrontCore/Views/Shared/EditorTemplates/ServerConfiguration.cshtml index 4f3dd008a..56a88e9cc 100644 --- a/WebfrontCore/Views/Shared/EditorTemplates/ServerConfiguration.cshtml +++ b/WebfrontCore/Views/Shared/EditorTemplates/ServerConfiguration.cshtml @@ -37,9 +37,12 @@ + + +
- @for(i = 0; i < Model.Rules.Length; i++) + @for (i = 0; i < Model.Rules.Length; i++) { } @@ -48,11 +51,11 @@
- @for(i = 0; i < Model.AutoMessages.Length; i++) + @for (i = 0; i < Model.AutoMessages.Length; i++) { } - @addText + @addText