tgstation-server  4.4.0
The /tg/station 13 server suite
GeneralConfiguration.cs
Go to the documentation of this file.
1 using Microsoft.Extensions.Logging;
2 using Newtonsoft.Json;
3 using Newtonsoft.Json.Converters;
4 using System;
6 
7 namespace Tgstation.Server.Host.Configuration
8 {
13  {
17  public const string Section = "General";
18 
22  public const ushort DefaultApiPort = 5000;
23 
27  public static readonly Version CurrentConfigVersion = new Version(2, 0, 0);
28 
32  const uint DefaultMinimumPasswordLength = 15;
33 
37  const uint DefaultInstanceLimit = 10;
38 
42  const uint DefaultUserLimit = 100;
43 
47  const uint DefaultByondTopicTimeout = 5000;
48 
52  const uint DefaultRestartTimeout = 60000;
53 
57  public Version ConfigVersion { get; set; }
58 
62  public ushort ApiPort { get; set; }
63 
67  public string GitHubAccessToken { get; set; }
68 
72  [JsonConverter(typeof(StringEnumConverter))]
73  public SetupWizardMode SetupWizardMode { get; set; }
74 
78  public uint ByondTopicTimeout { get; set; } = DefaultByondTopicTimeout;
79 
83  public uint RestartTimeout { get; set; } = DefaultRestartTimeout;
84 
88  public bool UseBasicWatchdog { get; set; }
89 
94  {
95  MinimumPasswordLength = DefaultMinimumPasswordLength;
96  InstanceLimit = DefaultInstanceLimit;
97  UserLimit = DefaultUserLimit;
98  }
99 
104  public void CheckCompatibility(ILogger logger)
105  {
106  if (logger == null)
107  throw new ArgumentNullException(nameof(logger));
108 
109  if (ConfigVersion == null)
110  logger.LogCritical(
111  "No `ConfigVersion` specified, your configuration may be out of date! The current version is \"{0}\"",
112  CurrentConfigVersion);
113  else if (ConfigVersion != CurrentConfigVersion)
114  if (ConfigVersion.Major != CurrentConfigVersion.Major)
115  logger.LogCritical(
116  "Your `ConfigVersion` is majorly out-of-date and may potentially cause issues running the server. Please follow migration instructions from the TGS release notes.",
117  CurrentConfigVersion);
118  else
119  logger.LogWarning("Your `ConfigVersion` is out-of-date. Please follow migration instructions from the TGS release notes.");
120  }
121  }
122 }
Base class for Models.ServerInformation.
void CheckCompatibility(ILogger logger)
Validates the current ConfigVersion's compatibility and provides migration instructions.
SetupWizardMode
Determines if the Setup.SetupWizard will run
GeneralConfiguration()
Initializes a new instance of the GeneralConfiguration .