make the version name match the actual name for FTP deployment
fix rare issue with summing session scores copy font to expected wwwroot dir in debug mode so we get pretty icons when developing upgrade some packages pretty much reworked the entire server web config to support better validation and stuff.. not really a small fix finish web configuration changes (I think) finish up configuration changes and update shared library nuget
This commit is contained in:
@ -1,14 +1,12 @@
|
||||
using SharedLibraryCore.Configuration.Attributes;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace SharedLibraryCore.Configuration
|
||||
{
|
||||
public class ApplicationConfiguration : IBaseConfiguration
|
||||
{
|
||||
|
||||
[LocalizedDisplayName("SETUP_ENABLE_WEBFRONT")]
|
||||
[ConfigurationLinked("WebfrontBindUrl", "ManualWebfrontUrl", "WebfrontPrimaryColor", "WebfrontSecondaryColor", "WebfrontCustomBranding")]
|
||||
public bool EnableWebFront { get; set; }
|
||||
@ -60,7 +58,7 @@ namespace SharedLibraryCore.Configuration
|
||||
[ConfigurationLinked("WebfrontConnectionWhitelist")]
|
||||
public bool EnableWebfrontConnectionWhitelist { get; set; }
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_WHITELIST_LIST")]
|
||||
public List<string> WebfrontConnectionWhitelist { get; set; }
|
||||
public string[] WebfrontConnectionWhitelist { get; set; } = new string[0];
|
||||
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")]
|
||||
[ConfigurationLinked("CustomLocale")]
|
||||
@ -68,7 +66,6 @@ namespace SharedLibraryCore.Configuration
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")]
|
||||
public string CustomLocale { get; set; }
|
||||
|
||||
[ConfigurationOptional]
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_DB_PROVIDER")]
|
||||
public string DatabaseProvider { get; set; } = "sqlite";
|
||||
[ConfigurationOptional]
|
||||
@ -78,26 +75,25 @@ namespace SharedLibraryCore.Configuration
|
||||
public int RConPollRate { get; set; } = 5000;
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_MAX_TB")]
|
||||
public TimeSpan MaximumTempBanTime { get; set; } = new TimeSpan(24 * 30, 0, 0);
|
||||
[LocalizedDisplayName("SETUP_ENABLE_COLOR_CODES")]
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENABLE_COLOR_CODES")]
|
||||
public bool EnableColorCodes { get; set; }
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_AUTOMESSAGE_PERIOD")]
|
||||
public int AutoMessagePeriod { get; set; }
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_AUTOMESSAGES")]
|
||||
public List<string> AutoMessages { get; set; }
|
||||
public string[] AutoMessages { get; set; } = new string[0];
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_GLOBAL_RULES")]
|
||||
public List<string> GlobalRules { get; set; }
|
||||
public string[] GlobalRules { get; set; } = new string[0];
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_DISALLOWED_NAMES")]
|
||||
public List<string> DisallowedClientNames { get; set; }
|
||||
public string[] DisallowedClientNames { get; set; } = new string[0];
|
||||
[UIHint("ServerConfiguration")]
|
||||
public List<ServerConfiguration> Servers { get; set; }
|
||||
|
||||
public ServerConfiguration[] Servers { get; set; }
|
||||
|
||||
[ConfigurationIgnore]
|
||||
public string Id { get; set; }
|
||||
[ConfigurationIgnore]
|
||||
public List<MapConfiguration> Maps { get; set; }
|
||||
public MapConfiguration[] Maps { get; set; }
|
||||
[ConfigurationIgnore]
|
||||
public List<QuickMessageConfiguration> QuickMessages { get; set; }
|
||||
public QuickMessageConfiguration[] QuickMessages { get; set; }
|
||||
[ConfigurationIgnore]
|
||||
public string WebfrontUrl => string.IsNullOrEmpty(ManualWebfrontUrl) ? WebfrontBindUrl?.Replace("0.0.0.0", "127.0.0.1") : ManualWebfrontUrl;
|
||||
|
||||
|
@ -1,17 +1,14 @@
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace SharedLibraryCore.Configuration
|
||||
{
|
||||
public class DefaultConfiguration : IBaseConfiguration
|
||||
{
|
||||
public List<string> AutoMessages { get; set; }
|
||||
public List<string> GlobalRules { get; set; }
|
||||
public List<MapConfiguration> Maps { get; set; }
|
||||
public List<QuickMessageConfiguration> QuickMessages {get; set;}
|
||||
public List<string> DisallowedClientNames { get; set; }
|
||||
public string[] AutoMessages { get; set; }
|
||||
public string[] GlobalRules { get; set; }
|
||||
public MapConfiguration[] Maps { get; set; }
|
||||
public QuickMessageConfiguration[] QuickMessages {get; set;}
|
||||
public string[] DisallowedClientNames { get; set; }
|
||||
|
||||
public IBaseConfiguration Generate() => this;
|
||||
|
||||
|
@ -15,9 +15,9 @@ namespace SharedLibraryCore.Configuration
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_PASSWORD")]
|
||||
public string Password { get; set; }
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_RULES")]
|
||||
public List<string> Rules { get; set; }
|
||||
public string[] Rules { get; set; } = new string[0];
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_AUTO_MESSAGES")]
|
||||
public List<string> AutoMessages { get; set; }
|
||||
public string[] AutoMessages { get; set; } = new string[0];
|
||||
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_SERVER_PATH")]
|
||||
[ConfigurationOptional]
|
||||
public string ManualLogPath { get; set; }
|
||||
@ -31,6 +31,9 @@ namespace SharedLibraryCore.Configuration
|
||||
[ConfigurationOptional]
|
||||
public Uri GameLogServerUrl { get; set; }
|
||||
|
||||
[ConfigurationIgnore]
|
||||
public int Index { get; set; }
|
||||
|
||||
private readonly IList<IRConParser> rconParsers;
|
||||
private readonly IList<IEventParser> eventParsers;
|
||||
|
||||
@ -38,8 +41,8 @@ namespace SharedLibraryCore.Configuration
|
||||
{
|
||||
rconParsers = new List<IRConParser>();
|
||||
eventParsers = new List<IEventParser>();
|
||||
Rules = new List<string>();
|
||||
AutoMessages = new List<string>();
|
||||
Rules = new string[0];
|
||||
AutoMessages = new string[0];
|
||||
}
|
||||
|
||||
public void AddRConParser(IRConParser parser)
|
||||
@ -94,8 +97,8 @@ namespace SharedLibraryCore.Configuration
|
||||
|
||||
Port = Utilities.PromptInt(loc["SETUP_SERVER_PORT"], null, 1, ushort.MaxValue);
|
||||
Password = Utilities.PromptString(loc["SETUP_SERVER_RCON"]);
|
||||
AutoMessages = new List<string>();
|
||||
Rules = new List<string>();
|
||||
AutoMessages = new string[0];
|
||||
Rules = new string[0];
|
||||
ReservedSlotNumber = loc["SETUP_SERVER_RESERVEDSLOT"].PromptInt(null, 0, 32);
|
||||
ManualLogPath = null;
|
||||
|
||||
|
@ -0,0 +1,72 @@
|
||||
using FluentValidation;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace SharedLibraryCore.Configuration.Validation
|
||||
{
|
||||
/// <summary>
|
||||
/// Validation class for main application configuration
|
||||
/// </summary>
|
||||
public class ApplicationConfigurationValidator : AbstractValidator<ApplicationConfiguration>
|
||||
{
|
||||
public ApplicationConfigurationValidator()
|
||||
{
|
||||
RuleFor(_app => _app.WebfrontBindUrl)
|
||||
.NotEmpty();
|
||||
|
||||
RuleFor(_app => _app.CustomSayName)
|
||||
.NotEmpty()
|
||||
.When(_app => _app.EnableCustomSayName);
|
||||
|
||||
RuleFor(_app => _app.SocialLinkAddress)
|
||||
.NotEmpty()
|
||||
.When(_app => _app.EnableSocialLink);
|
||||
|
||||
RuleFor(_app => _app.SocialLinkTitle)
|
||||
.NotEmpty()
|
||||
.When(_app => _app.EnableSocialLink);
|
||||
|
||||
RuleFor(_app => _app.CustomParserEncoding)
|
||||
.NotEmpty()
|
||||
.When(_app => _app.EnableCustomParserEncoding);
|
||||
|
||||
RuleFor(_app => _app.WebfrontConnectionWhitelist)
|
||||
.NotEmpty()
|
||||
.When(_app => _app.EnableWebfrontConnectionWhitelist);
|
||||
|
||||
RuleForEach(_app => _app.WebfrontConnectionWhitelist)
|
||||
.Must(_address => System.Net.IPAddress.TryParse(_address, out _));
|
||||
|
||||
RuleFor(_app => _app.CustomLocale)
|
||||
.NotEmpty()
|
||||
.When(_app => _app.EnableCustomLocale);
|
||||
|
||||
RuleFor(_app => _app.DatabaseProvider)
|
||||
.NotEmpty()
|
||||
.Must(_provider => new[] { "sqlite", "mysql", "postgresql" }.Contains(_provider));
|
||||
|
||||
RuleFor(_app => _app.ConnectionString)
|
||||
.NotEmpty()
|
||||
.When(_app => _app.DatabaseProvider != "sqlite");
|
||||
|
||||
RuleFor(_app => _app.RConPollRate)
|
||||
.GreaterThanOrEqualTo(1000);
|
||||
|
||||
RuleFor(_app => _app.AutoMessagePeriod)
|
||||
.GreaterThanOrEqualTo(60);
|
||||
|
||||
RuleFor(_app => _app.Servers)
|
||||
.NotEmpty();
|
||||
|
||||
RuleFor(_app => _app.AutoMessages)
|
||||
.NotNull();
|
||||
|
||||
RuleFor(_app => _app.GlobalRules)
|
||||
.NotNull();
|
||||
|
||||
RuleForEach(_app => _app.Servers)
|
||||
.NotEmpty()
|
||||
.SetValidator(new ServerConfigurationValidator());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
using FluentValidation;
|
||||
using System.Net;
|
||||
|
||||
namespace SharedLibraryCore.Configuration.Validation
|
||||
{
|
||||
/// <summary>
|
||||
/// Validation class for server configuration
|
||||
/// </summary>
|
||||
public class ServerConfigurationValidator : AbstractValidator<ServerConfiguration>
|
||||
{
|
||||
public ServerConfigurationValidator()
|
||||
{
|
||||
RuleFor(_server => _server.IPAddress)
|
||||
.NotEmpty()
|
||||
.Must(_address => IPAddress.TryParse(_address, out _));
|
||||
|
||||
RuleFor(_server => _server.Port)
|
||||
.InclusiveBetween(0, ushort.MaxValue);
|
||||
|
||||
RuleFor(_server => _server.Password)
|
||||
.NotEmpty();
|
||||
|
||||
RuleForEach(_server => _server.Rules)
|
||||
.NotEmpty();
|
||||
|
||||
RuleForEach(_server => _server.AutoMessages)
|
||||
.NotEmpty();
|
||||
|
||||
RuleFor(_server => _server.RConParserVersion)
|
||||
.NotEmpty();
|
||||
|
||||
RuleFor(_server => _server.EventParserVersion)
|
||||
.NotEmpty();
|
||||
|
||||
RuleFor(_server => _server.ReservedSlotNumber)
|
||||
.InclusiveBetween(0, 32);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user