ServerConfiguration.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. #nullable disable
  2. #pragma warning disable CS1591
  3. using System;
  4. using System.Collections.Generic;
  5. using MediaBrowser.Model.Dto;
  6. using MediaBrowser.Model.Updates;
  7. namespace MediaBrowser.Model.Configuration
  8. {
  9. /// <summary>
  10. /// Represents the server configuration.
  11. /// </summary>
  12. public class ServerConfiguration : BaseApplicationConfiguration
  13. {
  14. public const int DefaultHttpPort = 8096;
  15. public const int DefaultHttpsPort = 8920;
  16. private string _baseUrl;
  17. /// <summary>
  18. /// Gets or sets a value indicating whether to enable automatic port forwarding.
  19. /// </summary>
  20. public bool EnableUPnP { get; set; }
  21. /// <summary>
  22. /// Gets or sets a value indicating whether to enable prometheus metrics exporting.
  23. /// </summary>
  24. public bool EnableMetrics { get; set; }
  25. /// <summary>
  26. /// Gets or sets the public mapped port.
  27. /// </summary>
  28. /// <value>The public mapped port.</value>
  29. public int PublicPort { get; set; }
  30. /// <summary>
  31. /// Gets or sets the public HTTPS port.
  32. /// </summary>
  33. /// <value>The public HTTPS port.</value>
  34. public int PublicHttpsPort { get; set; }
  35. /// <summary>
  36. /// Gets or sets the HTTP server port number.
  37. /// </summary>
  38. /// <value>The HTTP server port number.</value>
  39. public int HttpServerPortNumber { get; set; }
  40. /// <summary>
  41. /// Gets or sets the HTTPS server port number.
  42. /// </summary>
  43. /// <value>The HTTPS server port number.</value>
  44. public int HttpsPortNumber { get; set; }
  45. /// <summary>
  46. /// Gets or sets a value indicating whether to use HTTPS.
  47. /// </summary>
  48. /// <remarks>
  49. /// In order for HTTPS to be used, in addition to setting this to true, valid values must also be
  50. /// provided for <see cref="CertificatePath"/> and <see cref="CertificatePassword"/>.
  51. /// </remarks>
  52. public bool EnableHttps { get; set; }
  53. public bool EnableNormalizedItemByNameIds { get; set; }
  54. /// <summary>
  55. /// Gets or sets the filesystem path of an X.509 certificate to use for SSL.
  56. /// </summary>
  57. public string CertificatePath { get; set; }
  58. /// <summary>
  59. /// Gets or sets the password required to access the X.509 certificate data in the file specified by <see cref="CertificatePath"/>.
  60. /// </summary>
  61. public string CertificatePassword { get; set; }
  62. /// <summary>
  63. /// Gets or sets a value indicating whether this instance is port authorized.
  64. /// </summary>
  65. /// <value><c>true</c> if this instance is port authorized; otherwise, <c>false</c>.</value>
  66. public bool IsPortAuthorized { get; set; }
  67. /// <summary>
  68. /// Gets or sets if quick connect is available for use on this server.
  69. /// </summary>
  70. public bool QuickConnectAvailable { get; set; }
  71. public bool AutoRunWebApp { get; set; }
  72. public bool EnableRemoteAccess { get; set; }
  73. /// <summary>
  74. /// Gets or sets a value indicating whether [enable case sensitive item ids].
  75. /// </summary>
  76. /// <value><c>true</c> if [enable case sensitive item ids]; otherwise, <c>false</c>.</value>
  77. public bool EnableCaseSensitiveItemIds { get; set; }
  78. public bool DisableLiveTvChannelUserDataName { get; set; }
  79. /// <summary>
  80. /// Gets or sets the metadata path.
  81. /// </summary>
  82. /// <value>The metadata path.</value>
  83. public string MetadataPath { get; set; }
  84. public string MetadataNetworkPath { get; set; }
  85. /// <summary>
  86. /// Gets or sets the preferred metadata language.
  87. /// </summary>
  88. /// <value>The preferred metadata language.</value>
  89. public string PreferredMetadataLanguage { get; set; }
  90. /// <summary>
  91. /// Gets or sets the metadata country code.
  92. /// </summary>
  93. /// <value>The metadata country code.</value>
  94. public string MetadataCountryCode { get; set; }
  95. /// <summary>
  96. /// Characters to be replaced with a ' ' in strings to create a sort name.
  97. /// </summary>
  98. /// <value>The sort replace characters.</value>
  99. public string[] SortReplaceCharacters { get; set; }
  100. /// <summary>
  101. /// Characters to be removed from strings to create a sort name.
  102. /// </summary>
  103. /// <value>The sort remove characters.</value>
  104. public string[] SortRemoveCharacters { get; set; }
  105. /// <summary>
  106. /// Words to be removed from strings to create a sort name.
  107. /// </summary>
  108. /// <value>The sort remove words.</value>
  109. public string[] SortRemoveWords { get; set; }
  110. /// <summary>
  111. /// Gets or sets the minimum percentage of an item that must be played in order for playstate to be updated.
  112. /// </summary>
  113. /// <value>The min resume PCT.</value>
  114. public int MinResumePct { get; set; }
  115. /// <summary>
  116. /// Gets or sets the maximum percentage of an item that can be played while still saving playstate. If this percentage is crossed playstate will be reset to the beginning and the item will be marked watched.
  117. /// </summary>
  118. /// <value>The max resume PCT.</value>
  119. public int MaxResumePct { get; set; }
  120. /// <summary>
  121. /// Gets or sets the minimum duration that an item must have in order to be eligible for playstate updates..
  122. /// </summary>
  123. /// <value>The min resume duration seconds.</value>
  124. public int MinResumeDurationSeconds { get; set; }
  125. /// <summary>
  126. /// The delay in seconds that we will wait after a file system change to try and discover what has been added/removed
  127. /// Some delay is necessary with some items because their creation is not atomic. It involves the creation of several
  128. /// different directories and files.
  129. /// </summary>
  130. /// <value>The file watcher delay.</value>
  131. public int LibraryMonitorDelay { get; set; }
  132. /// <summary>
  133. /// Gets or sets a value indicating whether [enable dashboard response caching].
  134. /// Allows potential contributors without visual studio to modify production dashboard code and test changes.
  135. /// </summary>
  136. /// <value><c>true</c> if [enable dashboard response caching]; otherwise, <c>false</c>.</value>
  137. public bool EnableDashboardResponseCaching { get; set; }
  138. /// <summary>
  139. /// Gets or sets the image saving convention.
  140. /// </summary>
  141. /// <value>The image saving convention.</value>
  142. public ImageSavingConvention ImageSavingConvention { get; set; }
  143. public MetadataOptions[] MetadataOptions { get; set; }
  144. public bool SkipDeserializationForBasicTypes { get; set; }
  145. public string ServerName { get; set; }
  146. public string BaseUrl
  147. {
  148. get => _baseUrl;
  149. set
  150. {
  151. // Normalize the start of the string
  152. if (string.IsNullOrWhiteSpace(value))
  153. {
  154. // If baseUrl is empty, set an empty prefix string
  155. _baseUrl = string.Empty;
  156. return;
  157. }
  158. if (value[0] != '/')
  159. {
  160. // If baseUrl was not configured with a leading slash, append one for consistency
  161. value = "/" + value;
  162. }
  163. // Normalize the end of the string
  164. if (value[value.Length - 1] == '/')
  165. {
  166. // If baseUrl was configured with a trailing slash, remove it for consistency
  167. value = value.Remove(value.Length - 1);
  168. }
  169. _baseUrl = value;
  170. }
  171. }
  172. public string UICulture { get; set; }
  173. public bool SaveMetadataHidden { get; set; }
  174. public NameValuePair[] ContentTypes { get; set; }
  175. public int RemoteClientBitrateLimit { get; set; }
  176. public bool EnableFolderView { get; set; }
  177. public bool EnableGroupingIntoCollections { get; set; }
  178. public bool DisplaySpecialsWithinSeasons { get; set; }
  179. public string[] LocalNetworkSubnets { get; set; }
  180. public string[] LocalNetworkAddresses { get; set; }
  181. public string[] CodecsUsed { get; set; }
  182. public List<RepositoryInfo> PluginRepositories { get; set; }
  183. public bool IgnoreVirtualInterfaces { get; set; }
  184. public bool EnableExternalContentInSuggestions { get; set; }
  185. /// <summary>
  186. /// Gets or sets a value indicating whether the server should force connections over HTTPS.
  187. /// </summary>
  188. public bool RequireHttps { get; set; }
  189. public bool EnableNewOmdbSupport { get; set; }
  190. public string[] RemoteIPFilter { get; set; }
  191. public bool IsRemoteIPFilterBlacklist { get; set; }
  192. public int ImageExtractionTimeoutMs { get; set; }
  193. public PathSubstitution[] PathSubstitutions { get; set; }
  194. public bool EnableSimpleArtistDetection { get; set; }
  195. public string[] UninstalledPlugins { get; set; }
  196. /// <summary>
  197. /// Gets or sets a value indicating whether slow server responses should be logged as a warning.
  198. /// </summary>
  199. public bool EnableSlowResponseWarning { get; set; }
  200. /// <summary>
  201. /// Gets or sets the threshold for the slow response time warning in ms.
  202. /// </summary>
  203. public long SlowResponseThresholdMs { get; set; }
  204. /// <summary>
  205. /// Gets or sets the cors hosts.
  206. /// </summary>
  207. public string[] CorsHosts { get; set; }
  208. /// <summary>
  209. /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
  210. /// </summary>
  211. public ServerConfiguration()
  212. {
  213. UninstalledPlugins = Array.Empty<string>();
  214. RemoteIPFilter = Array.Empty<string>();
  215. LocalNetworkSubnets = Array.Empty<string>();
  216. LocalNetworkAddresses = Array.Empty<string>();
  217. CodecsUsed = Array.Empty<string>();
  218. PathSubstitutions = Array.Empty<PathSubstitution>();
  219. IgnoreVirtualInterfaces = false;
  220. EnableSimpleArtistDetection = false;
  221. SkipDeserializationForBasicTypes = true;
  222. PluginRepositories = new List<RepositoryInfo>();
  223. DisplaySpecialsWithinSeasons = true;
  224. EnableExternalContentInSuggestions = true;
  225. ImageSavingConvention = ImageSavingConvention.Compatible;
  226. PublicPort = DefaultHttpPort;
  227. PublicHttpsPort = DefaultHttpsPort;
  228. HttpServerPortNumber = DefaultHttpPort;
  229. HttpsPortNumber = DefaultHttpsPort;
  230. EnableMetrics = false;
  231. EnableHttps = false;
  232. EnableDashboardResponseCaching = true;
  233. EnableCaseSensitiveItemIds = true;
  234. EnableNormalizedItemByNameIds = true;
  235. DisableLiveTvChannelUserDataName = true;
  236. EnableNewOmdbSupport = true;
  237. AutoRunWebApp = true;
  238. EnableRemoteAccess = true;
  239. QuickConnectAvailable = false;
  240. EnableUPnP = false;
  241. MinResumePct = 5;
  242. MaxResumePct = 90;
  243. // 5 minutes
  244. MinResumeDurationSeconds = 300;
  245. LibraryMonitorDelay = 60;
  246. ContentTypes = Array.Empty<NameValuePair>();
  247. PreferredMetadataLanguage = "en";
  248. MetadataCountryCode = "US";
  249. SortReplaceCharacters = new[] { ".", "+", "%" };
  250. SortRemoveCharacters = new[] { ",", "&", "-", "{", "}", "'" };
  251. SortRemoveWords = new[] { "the", "a", "an" };
  252. BaseUrl = string.Empty;
  253. UICulture = "en-US";
  254. MetadataOptions = new[]
  255. {
  256. new MetadataOptions()
  257. {
  258. ItemType = "Book"
  259. },
  260. new MetadataOptions()
  261. {
  262. ItemType = "Movie"
  263. },
  264. new MetadataOptions
  265. {
  266. ItemType = "MusicVideo",
  267. DisabledMetadataFetchers = new[] { "The Open Movie Database" },
  268. DisabledImageFetchers = new[] { "The Open Movie Database" }
  269. },
  270. new MetadataOptions
  271. {
  272. ItemType = "Series",
  273. DisabledMetadataFetchers = new[] { "TheMovieDb" },
  274. DisabledImageFetchers = new[] { "TheMovieDb" }
  275. },
  276. new MetadataOptions
  277. {
  278. ItemType = "MusicAlbum",
  279. DisabledMetadataFetchers = new[] { "TheAudioDB" }
  280. },
  281. new MetadataOptions
  282. {
  283. ItemType = "MusicArtist",
  284. DisabledMetadataFetchers = new[] { "TheAudioDB" }
  285. },
  286. new MetadataOptions
  287. {
  288. ItemType = "BoxSet"
  289. },
  290. new MetadataOptions
  291. {
  292. ItemType = "Season",
  293. DisabledMetadataFetchers = new[] { "TheMovieDb" },
  294. },
  295. new MetadataOptions
  296. {
  297. ItemType = "Episode",
  298. DisabledMetadataFetchers = new[] { "The Open Movie Database", "TheMovieDb" },
  299. DisabledImageFetchers = new[] { "The Open Movie Database", "TheMovieDb" }
  300. }
  301. };
  302. EnableSlowResponseWarning = true;
  303. SlowResponseThresholdMs = 500;
  304. CorsHosts = new[] { "*" };
  305. }
  306. }
  307. public class PathSubstitution
  308. {
  309. public string From { get; set; }
  310. public string To { get; set; }
  311. }
  312. }