NetworkConfiguration.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. #pragma warning disable CA1819 // Properties should not return arrays
  2. using System;
  3. namespace MediaBrowser.Common.Net;
  4. /// <summary>
  5. /// Defines the <see cref="NetworkConfiguration" />.
  6. /// </summary>
  7. public class NetworkConfiguration
  8. {
  9. /// <summary>
  10. /// The default value for <see cref="InternalHttpPort"/>.
  11. /// </summary>
  12. public const int DefaultHttpPort = 8096;
  13. /// <summary>
  14. /// The default value for <see cref="PublicHttpsPort"/> and <see cref="InternalHttpsPort"/>.
  15. /// </summary>
  16. public const int DefaultHttpsPort = 8920;
  17. private string _baseUrl = string.Empty;
  18. /// <summary>
  19. /// Gets or sets a value used to specify the URL prefix that your Jellyfin instance can be accessed at.
  20. /// </summary>
  21. public string BaseUrl
  22. {
  23. get => _baseUrl;
  24. set
  25. {
  26. // Normalize the start of the string
  27. if (string.IsNullOrWhiteSpace(value))
  28. {
  29. // If baseUrl is empty, set an empty prefix string
  30. _baseUrl = string.Empty;
  31. return;
  32. }
  33. if (value[0] != '/')
  34. {
  35. // If baseUrl was not configured with a leading slash, append one for consistency
  36. value = "/" + value;
  37. }
  38. // Normalize the end of the string
  39. if (value[^1] == '/')
  40. {
  41. // If baseUrl was configured with a trailing slash, remove it for consistency
  42. value = value.Remove(value.Length - 1);
  43. }
  44. _baseUrl = value;
  45. }
  46. }
  47. /// <summary>
  48. /// Gets or sets a value indicating whether to use HTTPS.
  49. /// </summary>
  50. /// <remarks>
  51. /// In order for HTTPS to be used, in addition to setting this to true, valid values must also be
  52. /// provided for <see cref="CertificatePath"/> and <see cref="CertificatePassword"/>.
  53. /// </remarks>
  54. public bool EnableHttps { get; set; }
  55. /// <summary>
  56. /// Gets or sets a value indicating whether the server should force connections over HTTPS.
  57. /// </summary>
  58. public bool RequireHttps { get; set; }
  59. /// <summary>
  60. /// Gets or sets the filesystem path of an X.509 certificate to use for SSL.
  61. /// </summary>
  62. public string CertificatePath { get; set; } = string.Empty;
  63. /// <summary>
  64. /// Gets or sets the password required to access the X.509 certificate data in the file specified by <see cref="CertificatePath"/>.
  65. /// </summary>
  66. public string CertificatePassword { get; set; } = string.Empty;
  67. /// <summary>
  68. /// Gets or sets the internal HTTP server port.
  69. /// </summary>
  70. /// <value>The HTTP server port.</value>
  71. public int InternalHttpPort { get; set; } = DefaultHttpPort;
  72. /// <summary>
  73. /// Gets or sets the internal HTTPS server port.
  74. /// </summary>
  75. /// <value>The HTTPS server port.</value>
  76. public int InternalHttpsPort { get; set; } = DefaultHttpsPort;
  77. /// <summary>
  78. /// Gets or sets the public HTTP port.
  79. /// </summary>
  80. /// <value>The public HTTP port.</value>
  81. public int PublicHttpPort { get; set; } = DefaultHttpPort;
  82. /// <summary>
  83. /// Gets or sets the public HTTPS port.
  84. /// </summary>
  85. /// <value>The public HTTPS port.</value>
  86. public int PublicHttpsPort { get; set; } = DefaultHttpsPort;
  87. /// <summary>
  88. /// Gets or sets a value indicating whether Autodiscovery is enabled.
  89. /// </summary>
  90. public bool AutoDiscovery { get; set; } = true;
  91. /// <summary>
  92. /// Gets or sets a value indicating whether to enable automatic port forwarding.
  93. /// </summary>
  94. [Obsolete("No longer supported")]
  95. public bool EnableUPnP { get; set; }
  96. /// <summary>
  97. /// Gets or sets a value indicating whether IPv6 is enabled.
  98. /// </summary>
  99. public bool EnableIPv4 { get; set; } = true;
  100. /// <summary>
  101. /// Gets or sets a value indicating whether IPv6 is enabled.
  102. /// </summary>
  103. public bool EnableIPv6 { get; set; }
  104. /// <summary>
  105. /// Gets or sets a value indicating whether access from outside of the LAN is permitted.
  106. /// </summary>
  107. public bool EnableRemoteAccess { get; set; } = true;
  108. /// <summary>
  109. /// Gets or sets the subnets that are deemed to make up the LAN.
  110. /// </summary>
  111. public string[] LocalNetworkSubnets { get; set; } = Array.Empty<string>();
  112. /// <summary>
  113. /// Gets or sets the interface addresses which Jellyfin will bind to. If empty, all interfaces will be used.
  114. /// </summary>
  115. public string[] LocalNetworkAddresses { get; set; } = Array.Empty<string>();
  116. /// <summary>
  117. /// Gets or sets the known proxies.
  118. /// </summary>
  119. public string[] KnownProxies { get; set; } = Array.Empty<string>();
  120. /// <summary>
  121. /// Gets or sets a value indicating whether address names that match <see cref="VirtualInterfaceNames"/> should be ignored for the purposes of binding.
  122. /// </summary>
  123. public bool IgnoreVirtualInterfaces { get; set; } = true;
  124. /// <summary>
  125. /// Gets or sets a value indicating the interface name prefixes that should be ignored. The list can be comma separated and values are case-insensitive. <seealso cref="IgnoreVirtualInterfaces"/>.
  126. /// </summary>
  127. public string[] VirtualInterfaceNames { get; set; } = new string[] { "veth" };
  128. /// <summary>
  129. /// Gets or sets a value indicating whether the published server uri is based on information in HTTP requests.
  130. /// </summary>
  131. public bool EnablePublishedServerUriByRequest { get; set; } = false;
  132. /// <summary>
  133. /// Gets or sets the PublishedServerUriBySubnet
  134. /// Gets or sets PublishedServerUri to advertise for specific subnets.
  135. /// </summary>
  136. public string[] PublishedServerUriBySubnet { get; set; } = Array.Empty<string>();
  137. /// <summary>
  138. /// Gets or sets the filter for remote IP connectivity. Used in conjunction with <seealso cref="IsRemoteIPFilterBlacklist"/>.
  139. /// </summary>
  140. public string[] RemoteIPFilter { get; set; } = Array.Empty<string>();
  141. /// <summary>
  142. /// Gets or sets a value indicating whether <seealso cref="RemoteIPFilter"/> contains a blacklist or a whitelist. Default is a whitelist.
  143. /// </summary>
  144. public bool IsRemoteIPFilterBlacklist { get; set; }
  145. }