2019-04-14 11:55:05 -04:00
|
|
|
|
using SharedLibraryCore.Configuration.Attributes;
|
2019-04-11 21:43:05 -04:00
|
|
|
|
using SharedLibraryCore.Interfaces;
|
2018-03-18 22:25:11 -04:00
|
|
|
|
using System;
|
2020-12-31 19:48:58 -05:00
|
|
|
|
using System.Collections.Generic;
|
2019-04-11 21:43:05 -04:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2021-01-24 12:47:19 -05:00
|
|
|
|
using System.Linq;
|
2021-07-09 17:50:33 -04:00
|
|
|
|
using Newtonsoft.Json;
|
2021-03-22 12:09:25 -04:00
|
|
|
|
using static Data.Models.Client.EFClient;
|
2018-03-14 01:36:25 -04:00
|
|
|
|
|
2018-04-08 02:44:42 -04:00
|
|
|
|
namespace SharedLibraryCore.Configuration
|
2018-03-14 01:36:25 -04:00
|
|
|
|
{
|
2018-03-18 22:25:11 -04:00
|
|
|
|
public class ApplicationConfiguration : IBaseConfiguration
|
2018-03-14 01:36:25 -04:00
|
|
|
|
{
|
2021-10-09 22:11:47 -04:00
|
|
|
|
[ConfigurationIgnore]
|
|
|
|
|
public CommunityInformationConfiguration CommunityInformation { get; set; } = new CommunityInformationConfiguration();
|
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("SETUP_ENABLE_WEBFRONT")]
|
2020-12-31 19:48:58 -05:00
|
|
|
|
[ConfigurationLinked("WebfrontBindUrl", "ManualWebfrontUrl", "WebfrontPrimaryColor", "WebfrontSecondaryColor",
|
|
|
|
|
"WebfrontCustomBranding")]
|
2018-04-16 16:31:14 -04:00
|
|
|
|
public bool EnableWebFront { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-04-11 21:43:05 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_BIND_URL")]
|
|
|
|
|
public string WebfrontBindUrl { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-04-11 21:43:05 -04:00
|
|
|
|
[ConfigurationOptional]
|
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_MANUAL_URL")]
|
|
|
|
|
public string ManualWebfrontUrl { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-07-27 09:18:49 -04:00
|
|
|
|
[ConfigurationOptional]
|
2019-07-27 16:23:45 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_PRIMARY_COLOR")]
|
2019-07-27 09:18:49 -04:00
|
|
|
|
public string WebfrontPrimaryColor { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-07-27 09:18:49 -04:00
|
|
|
|
[ConfigurationOptional]
|
2019-07-27 16:23:45 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_SECONDARY_COLOR")]
|
2019-07-27 09:18:49 -04:00
|
|
|
|
public string WebfrontSecondaryColor { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-07-27 16:23:45 -04:00
|
|
|
|
[ConfigurationOptional]
|
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_BRANDING")]
|
|
|
|
|
public string WebfrontCustomBranding { get; set; }
|
2019-04-11 21:43:05 -04:00
|
|
|
|
|
2021-10-19 21:17:10 -04:00
|
|
|
|
[ConfigurationIgnore]
|
|
|
|
|
public WebfrontConfiguration Webfront { get; set; } = new WebfrontConfiguration();
|
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("SETUP_ENABLE_MULTIOWN")]
|
2018-03-14 01:36:25 -04:00
|
|
|
|
public bool EnableMultipleOwners { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("SETUP_ENABLE_STEPPEDPRIV")]
|
2018-03-24 17:35:54 -04:00
|
|
|
|
public bool EnableSteppedHierarchy { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-04-11 21:43:05 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_USE_LOCAL_TRANSLATIONS")]
|
|
|
|
|
public bool UseLocalTranslations { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-04-11 21:43:05 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_IGNORE_BOTS")]
|
|
|
|
|
public bool IgnoreBots { get; set; }
|
|
|
|
|
|
2019-07-17 13:29:51 -04:00
|
|
|
|
[ConfigurationLinked("CustomSayName")]
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("SETUP_ENABLE_CUSTOMSAY")]
|
2018-03-30 00:13:40 -04:00
|
|
|
|
public bool EnableCustomSayName { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("SETUP_SAY_NAME")]
|
2018-03-30 00:13:40 -04:00
|
|
|
|
public string CustomSayName { get; set; }
|
2019-04-11 21:43:05 -04:00
|
|
|
|
|
|
|
|
|
[LocalizedDisplayName("SETUP_DISPLAY_SOCIAL")]
|
2019-07-17 13:29:51 -04:00
|
|
|
|
[ConfigurationLinked("SocialLinkAddress", "SocialLinkTitle")]
|
2019-04-11 21:43:05 -04:00
|
|
|
|
public bool EnableSocialLink { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("SETUP_SOCIAL_LINK")]
|
2018-05-08 00:58:46 -04:00
|
|
|
|
public string SocialLinkAddress { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("SETUP_SOCIAL_TITLE")]
|
2018-05-05 18:52:04 -04:00
|
|
|
|
public string SocialLinkTitle { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2020-11-17 19:24:54 -05:00
|
|
|
|
[LocalizedDisplayName("SETUP_CONTACT_URI")]
|
|
|
|
|
public string ContactUri { get; set; }
|
2019-04-11 21:43:05 -04:00
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("SETUP_USE_CUSTOMENCODING")]
|
2019-07-17 13:29:51 -04:00
|
|
|
|
[ConfigurationLinked("CustomParserEncoding")]
|
2019-03-30 23:04:15 -04:00
|
|
|
|
public bool EnableCustomParserEncoding { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENCODING")]
|
2018-04-21 18:18:20 -04:00
|
|
|
|
public string CustomParserEncoding { get; set; }
|
2019-04-11 21:43:05 -04:00
|
|
|
|
|
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENABLE_WHITELIST")]
|
2019-07-17 13:29:51 -04:00
|
|
|
|
[ConfigurationLinked("WebfrontConnectionWhitelist")]
|
2019-04-11 21:43:05 -04:00
|
|
|
|
public bool EnableWebfrontConnectionWhitelist { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-04-14 11:55:05 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_WHITELIST_LIST")]
|
2020-01-17 18:31:53 -05:00
|
|
|
|
public string[] WebfrontConnectionWhitelist { get; set; } = new string[0];
|
2019-04-11 21:43:05 -04:00
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")]
|
2019-07-17 13:29:51 -04:00
|
|
|
|
[ConfigurationLinked("CustomLocale")]
|
2019-03-30 23:04:15 -04:00
|
|
|
|
public bool EnableCustomLocale { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_CUSTOM_LOCALE")]
|
2018-04-24 18:01:27 -04:00
|
|
|
|
public string CustomLocale { get; set; }
|
2019-04-11 21:43:05 -04:00
|
|
|
|
|
2020-07-31 21:40:03 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_COMMAND_PREFIX")]
|
|
|
|
|
public string CommandPrefix { get; set; } = "!";
|
|
|
|
|
|
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_BROADCAST_COMMAND_PREFIX")]
|
|
|
|
|
public string BroadcastCommandPrefix { get; set; } = "@";
|
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_DB_PROVIDER")]
|
2018-09-23 20:45:54 -04:00
|
|
|
|
public string DatabaseProvider { get; set; } = "sqlite";
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-04-11 21:43:05 -04:00
|
|
|
|
[ConfigurationOptional]
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_CONNECTION_STRING")]
|
2018-04-25 02:38:59 -04:00
|
|
|
|
public string ConnectionString { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_RCON_POLLRATE")]
|
2021-11-23 18:26:33 -05:00
|
|
|
|
public int RConPollRate { get; set; } = 8000;
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_MAX_TB")]
|
2018-10-15 20:51:04 -04:00
|
|
|
|
public TimeSpan MaximumTempBanTime { get; set; } = new TimeSpan(24 * 30, 0, 0);
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2020-01-17 18:31:53 -05:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_ENABLE_COLOR_CODES")]
|
2019-08-02 19:04:34 -04:00
|
|
|
|
public bool EnableColorCodes { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2021-11-23 18:26:33 -05:00
|
|
|
|
[ConfigurationIgnore]
|
|
|
|
|
public string IngameAccentColorKey { get; set; } = "Cyan";
|
|
|
|
|
|
2019-03-30 23:04:15 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_AUTOMESSAGE_PERIOD")]
|
2018-03-14 14:22:04 -04:00
|
|
|
|
public int AutoMessagePeriod { get; set; }
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-04-11 21:43:05 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_AUTOMESSAGES")]
|
2020-01-17 18:31:53 -05:00
|
|
|
|
public string[] AutoMessages { get; set; } = new string[0];
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-04-11 21:43:05 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_GLOBAL_RULES")]
|
2020-01-17 18:31:53 -05:00
|
|
|
|
public string[] GlobalRules { get; set; } = new string[0];
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2019-04-11 21:43:05 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_DISALLOWED_NAMES")]
|
2020-01-17 18:31:53 -05:00
|
|
|
|
public string[] DisallowedClientNames { get; set; } = new string[0];
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
2020-10-17 11:47:56 -04:00
|
|
|
|
[LocalizedDisplayName("WEBFRONT_CONFIGURATION_MAP_CHANGE_DELAY")]
|
|
|
|
|
public int MapChangeDelaySeconds { get; set; } = 5;
|
2020-12-31 19:48:58 -05:00
|
|
|
|
|
|
|
|
|
[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),
|
2021-01-08 20:21:23 -05:00
|
|
|
|
TimeSpan.FromDays(30)
|
2020-12-31 19:48:58 -05:00
|
|
|
|
};
|
|
|
|
|
|
2021-09-16 17:27:40 -04:00
|
|
|
|
[ConfigurationIgnore]
|
2020-12-31 19:48:58 -05:00
|
|
|
|
[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"}};
|
2021-01-09 13:37:20 -05:00
|
|
|
|
[LocalizedDisplayName(("WEBFRONT_CONFIGURATION_ENABLE_PRIVILEGED_USER_PRIVACY"))]
|
|
|
|
|
public bool EnablePrivilegedUserPrivacy { get; set; }
|
2021-08-14 18:55:28 -04:00
|
|
|
|
|
2021-08-29 14:10:10 -04:00
|
|
|
|
[ConfigurationIgnore]
|
2021-08-14 18:55:28 -04:00
|
|
|
|
public bool EnableImplicitAccountLinking { get; set; } = false;
|
2021-08-29 14:10:10 -04:00
|
|
|
|
|
|
|
|
|
[ConfigurationIgnore]
|
|
|
|
|
public TimeSpan MaxClientHistoryTime { get; set; } = TimeSpan.FromHours(12);
|
|
|
|
|
|
|
|
|
|
[ConfigurationIgnore]
|
|
|
|
|
public TimeSpan ServerDataCollectionInterval { get; set; } = TimeSpan.FromMinutes(5);
|
2021-09-18 19:25:02 -04:00
|
|
|
|
|
|
|
|
|
public int ServerConnectionAttempts { get; set; } = 6;
|
2021-08-29 14:10:10 -04:00
|
|
|
|
|
2021-09-16 17:27:40 -04:00
|
|
|
|
[ConfigurationIgnore]
|
2021-01-24 12:47:19 -05:00
|
|
|
|
public Dictionary<Permission, string> OverridePermissionLevelNames { get; set; } = Enum
|
|
|
|
|
.GetValues(typeof(Permission))
|
|
|
|
|
.Cast<Permission>()
|
|
|
|
|
.ToDictionary(perm => perm, perm => perm.ToString());
|
2020-12-31 19:48:58 -05:00
|
|
|
|
[UIHint("ServerConfiguration")]
|
2020-01-17 18:31:53 -05:00
|
|
|
|
public ServerConfiguration[] Servers { get; set; }
|
2019-04-11 21:43:05 -04:00
|
|
|
|
|
2021-06-27 21:31:39 -04:00
|
|
|
|
[ConfigurationIgnore] public int MinimumNameLength { get; set; } = 3;
|
2020-12-31 19:48:58 -05:00
|
|
|
|
[ConfigurationIgnore] public string Id { get; set; }
|
|
|
|
|
[ConfigurationIgnore] public string SubscriptionId { get; set; }
|
2021-07-09 17:50:33 -04:00
|
|
|
|
[Obsolete("Moved to DefaultSettings")]
|
2020-12-31 19:48:58 -05:00
|
|
|
|
[ConfigurationIgnore] public MapConfiguration[] Maps { get; set; }
|
2021-07-09 17:50:33 -04:00
|
|
|
|
[Obsolete("Moved to DefaultSettings")]
|
2020-12-31 19:48:58 -05:00
|
|
|
|
[ConfigurationIgnore] public QuickMessageConfiguration[] QuickMessages { get; set; }
|
|
|
|
|
|
2019-04-11 21:43:05 -04:00
|
|
|
|
[ConfigurationIgnore]
|
2021-07-09 17:50:33 -04:00
|
|
|
|
[JsonIgnore]
|
2020-12-31 19:48:58 -05:00
|
|
|
|
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");
|
2018-03-18 22:25:11 -04:00
|
|
|
|
|
|
|
|
|
public IBaseConfiguration Generate()
|
|
|
|
|
{
|
2018-05-05 16:36:26 -04:00
|
|
|
|
var loc = Utilities.CurrentLocalization.LocalizationIndex;
|
2018-04-18 16:46:53 -04:00
|
|
|
|
Id = Guid.NewGuid().ToString();
|
2018-08-22 21:25:34 -04:00
|
|
|
|
|
2018-04-22 16:04:18 -04:00
|
|
|
|
EnableWebFront = Utilities.PromptBool(loc["SETUP_ENABLE_WEBFRONT"]);
|
|
|
|
|
EnableMultipleOwners = Utilities.PromptBool(loc["SETUP_ENABLE_MULTIOWN"]);
|
|
|
|
|
EnableSteppedHierarchy = Utilities.PromptBool(loc["SETUP_ENABLE_STEPPEDPRIV"]);
|
|
|
|
|
EnableCustomSayName = Utilities.PromptBool(loc["SETUP_ENABLE_CUSTOMSAY"]);
|
2018-03-18 22:25:11 -04:00
|
|
|
|
|
2018-04-22 16:04:18 -04:00
|
|
|
|
bool useCustomParserEncoding = Utilities.PromptBool(loc["SETUP_USE_CUSTOMENCODING"]);
|
2019-04-21 17:28:13 -04:00
|
|
|
|
if (useCustomParserEncoding)
|
|
|
|
|
{
|
|
|
|
|
CustomParserEncoding = Utilities.PromptString(loc["SETUP_ENCODING_STRING"]);
|
|
|
|
|
}
|
2018-04-21 18:18:20 -04:00
|
|
|
|
|
2018-09-04 13:40:29 -04:00
|
|
|
|
WebfrontBindUrl = "http://0.0.0.0:1624";
|
2018-04-19 01:48:14 -04:00
|
|
|
|
|
2018-03-30 00:13:40 -04:00
|
|
|
|
if (EnableCustomSayName)
|
2019-04-09 16:02:49 -04:00
|
|
|
|
{
|
2018-04-22 16:04:18 -04:00
|
|
|
|
CustomSayName = Utilities.PromptString(loc["SETUP_SAY_NAME"]);
|
2019-04-09 16:02:49 -04:00
|
|
|
|
}
|
2018-03-18 22:25:11 -04:00
|
|
|
|
|
2018-05-08 00:58:46 -04:00
|
|
|
|
EnableSocialLink = Utilities.PromptBool(loc["SETUP_DISPLAY_SOCIAL"]);
|
2018-03-18 22:25:11 -04:00
|
|
|
|
|
2018-05-08 00:58:46 -04:00
|
|
|
|
if (EnableSocialLink)
|
2018-05-05 18:52:04 -04:00
|
|
|
|
{
|
|
|
|
|
SocialLinkTitle = Utilities.PromptString(loc["SETUP_SOCIAL_TITLE"]);
|
2018-05-08 00:58:46 -04:00
|
|
|
|
SocialLinkAddress = Utilities.PromptString(loc["SETUP_SOCIAL_LINK"]);
|
2018-05-05 18:52:04 -04:00
|
|
|
|
}
|
2018-09-04 13:40:29 -04:00
|
|
|
|
|
2018-06-07 22:19:12 -04:00
|
|
|
|
RConPollRate = 5000;
|
2019-04-14 11:55:05 -04:00
|
|
|
|
AutoMessagePeriod = 60;
|
2018-03-18 22:25:11 -04:00
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-09 16:02:49 -04:00
|
|
|
|
public string Name()
|
|
|
|
|
{
|
|
|
|
|
return "ApplicationConfiguration";
|
|
|
|
|
}
|
2018-03-14 01:36:25 -04:00
|
|
|
|
}
|
2018-03-18 22:25:11 -04:00
|
|
|
|
}
|