add preset rules, configurable time spans, and separate rule shortcut for issue #180

This commit is contained in:
RaidMax
2020-12-31 18:48:58 -06:00
parent 5a288dafc1
commit 5cb2d05f33
3 changed files with 154 additions and 76 deletions

View File

@ -1,6 +1,7 @@
using SharedLibraryCore.Configuration.Attributes;
using SharedLibraryCore.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace SharedLibraryCore.Configuration
@ -8,63 +9,79 @@ namespace SharedLibraryCore.Configuration
public class ApplicationConfiguration : IBaseConfiguration
{
[LocalizedDisplayName("SETUP_ENABLE_WEBFRONT")]
[ConfigurationLinked("WebfrontBindUrl", "ManualWebfrontUrl", "WebfrontPrimaryColor", "WebfrontSecondaryColor", "WebfrontCustomBranding")]
[ConfigurationLinked("WebfrontBindUrl", "ManualWebfrontUrl", "WebfrontPrimaryColor", "WebfrontSecondaryColor",
"WebfrontCustomBranding")]
public bool EnableWebFront { get; set; }
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_BIND_URL")]
public string WebfrontBindUrl { get; set; }
[ConfigurationOptional]
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_MANUAL_URL")]
public string ManualWebfrontUrl { get; set; }
[ConfigurationOptional]
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_PRIMARY_COLOR")]
public string WebfrontPrimaryColor { get; set; }
[ConfigurationOptional]
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_SECONDARY_COLOR")]
public string WebfrontSecondaryColor { get; set; }
[ConfigurationOptional]
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_BRANDING")]
public string WebfrontCustomBranding { get; set; }
[LocalizedDisplayName("SETUP_ENABLE_MULTIOWN")]
public bool EnableMultipleOwners { get; set; }
[LocalizedDisplayName("SETUP_ENABLE_STEPPEDPRIV")]
public bool EnableSteppedHierarchy { get; set; }
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_USE_LOCAL_TRANSLATIONS")]
public bool UseLocalTranslations { get; set; }
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_IGNORE_BOTS")]
public bool IgnoreBots { get; set; }
[ConfigurationLinked("CustomSayName")]
[LocalizedDisplayName("SETUP_ENABLE_CUSTOMSAY")]
public bool EnableCustomSayName { get; set; }
[LocalizedDisplayName("SETUP_SAY_NAME")]
public string CustomSayName { get; set; }
[LocalizedDisplayName("SETUP_DISPLAY_SOCIAL")]
[ConfigurationLinked("SocialLinkAddress", "SocialLinkTitle")]
public bool EnableSocialLink { get; set; }
[LocalizedDisplayName("SETUP_SOCIAL_LINK")]
public string SocialLinkAddress { get; set; }
[LocalizedDisplayName("SETUP_SOCIAL_TITLE")]
public string SocialLinkTitle { get; set; }
[LocalizedDisplayName("SETUP_CONTACT_URI")]
public string ContactUri { get; set; }
[LocalizedDisplayName("SETUP_USE_CUSTOMENCODING")]
[ConfigurationLinked("CustomParserEncoding")]
public bool EnableCustomParserEncoding { get; set; }
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENCODING")]
public string CustomParserEncoding { get; set; }
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENABLE_WHITELIST")]
[ConfigurationLinked("WebfrontConnectionWhitelist")]
public bool EnableWebfrontConnectionWhitelist { get; set; }
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_WHITELIST_LIST")]
public string[] WebfrontConnectionWhitelist { get; set; } = new string[0];
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")]
[ConfigurationLinked("CustomLocale")]
public bool EnableCustomLocale { get; set; }
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")]
public string CustomLocale { get; set; }
@ -76,42 +93,63 @@ namespace SharedLibraryCore.Configuration
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_DB_PROVIDER")]
public string DatabaseProvider { get; set; } = "sqlite";
[ConfigurationOptional]
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_CONNECTION_STRING")]
public string ConnectionString { get; set; }
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_RCON_POLLRATE")]
public int RConPollRate { get; set; } = 5000;
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_MAX_TB")]
public TimeSpan MaximumTempBanTime { get; set; } = new TimeSpan(24 * 30, 0, 0);
[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 string[] AutoMessages { get; set; } = new string[0];
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_GLOBAL_RULES")]
public string[] GlobalRules { get; set; } = new string[0];
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_DISALLOWED_NAMES")]
public string[] DisallowedClientNames { get; set; } = new string[0];
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_MAP_CHANGE_DELAY")]
public int MapChangeDelaySeconds { get; set; } = 5;
[UIHint("ServerConfiguration")]
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_BAN_DURATIONS")]
public TimeSpan[] BanDurations { get; set; } = {
TimeSpan.FromHours(1),
TimeSpan.FromHours(6),
TimeSpan.FromDays(1),
TimeSpan.FromDays(2),
TimeSpan.FromDays(7),
TimeSpan.FromDays(31)
};
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_PRESET_BAN_REASONS")]
public Dictionary<string, string> PresetPenaltyReasons { get; set; } = new Dictionary<string, string>
{{"afk", "Away from keyboard"}, {"ci", "Connection interrupted. Reconnect"}};
[UIHint("ServerConfiguration")]
public ServerConfiguration[] Servers { get; set; }
[ConfigurationIgnore] public string Id { get; set; }
[ConfigurationIgnore] public string SubscriptionId { get; set; }
[ConfigurationIgnore] public MapConfiguration[] Maps { get; set; }
[ConfigurationIgnore] public QuickMessageConfiguration[] QuickMessages { get; set; }
[ConfigurationIgnore]
public string Id { get; set; }
[ConfigurationIgnore]
public string SubscriptionId { get; set; }
[ConfigurationIgnore]
public MapConfiguration[] Maps { get; set; }
[ConfigurationIgnore]
public QuickMessageConfiguration[] QuickMessages { get; set; }
[ConfigurationIgnore]
public string WebfrontUrl => string.IsNullOrEmpty(ManualWebfrontUrl) ? WebfrontBindUrl?.Replace("0.0.0.0", "127.0.0.1") : ManualWebfrontUrl;
[ConfigurationIgnore]
public bool IgnoreServerConnectionLost { get; set; }
[ConfigurationIgnore]
public Uri MasterUrl { get; set; } = new Uri("http://api.raidmax.org:5000");
public string WebfrontUrl => string.IsNullOrEmpty(ManualWebfrontUrl)
? WebfrontBindUrl?.Replace("0.0.0.0", "127.0.0.1")
: ManualWebfrontUrl;
[ConfigurationIgnore] public bool IgnoreServerConnectionLost { get; set; }
[ConfigurationIgnore] public Uri MasterUrl { get; set; } = new Uri("http://api.raidmax.org:5000");
public IBaseConfiguration Generate()
{