NetworkConfiguration.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. #pragma warning disable CA1819 // Properties should not return arrays
  2. using System;
  3. using MediaBrowser.Model.Configuration;
  4. namespace Jellyfin.Networking.Configuration
  5. {
  6. /// <summary>
  7. /// Defines the <see cref="NetworkConfiguration" />.
  8. /// </summary>
  9. public class NetworkConfiguration
  10. {
  11. /// <summary>
  12. /// The default value for <see cref="HttpServerPortNumber"/>.
  13. /// </summary>
  14. public const int DefaultHttpPort = 8096;
  15. /// <summary>
  16. /// The default value for <see cref="PublicHttpsPort"/> and <see cref="HttpsPortNumber"/>.
  17. /// </summary>
  18. public const int DefaultHttpsPort = 8920;
  19. private string _baseUrl = string.Empty;
  20. /// <summary>
  21. /// Gets or sets a value indicating whether the server should force connections over HTTPS.
  22. /// </summary>
  23. public bool RequireHttps { get; set; }
  24. /// <summary>
  25. /// Gets or sets a value used to specify the URL prefix that your Jellyfin instance can be accessed at.
  26. /// </summary>
  27. public string BaseUrl
  28. {
  29. get => _baseUrl;
  30. set
  31. {
  32. // Normalize the start of the string
  33. if (string.IsNullOrWhiteSpace(value))
  34. {
  35. // If baseUrl is empty, set an empty prefix string
  36. _baseUrl = string.Empty;
  37. return;
  38. }
  39. if (value[0] != '/')
  40. {
  41. // If baseUrl was not configured with a leading slash, append one for consistency
  42. value = "/" + value;
  43. }
  44. // Normalize the end of the string
  45. if (value[^1] == '/')
  46. {
  47. // If baseUrl was configured with a trailing slash, remove it for consistency
  48. value = value.Remove(value.Length - 1);
  49. }
  50. _baseUrl = value;
  51. }
  52. }
  53. /// <summary>
  54. /// Gets or sets the public HTTPS port.
  55. /// </summary>
  56. /// <value>The public HTTPS port.</value>
  57. public int PublicHttpsPort { get; set; } = DefaultHttpsPort;
  58. /// <summary>
  59. /// Gets or sets the HTTP server port number.
  60. /// </summary>
  61. /// <value>The HTTP server port number.</value>
  62. public int HttpServerPortNumber { get; set; } = DefaultHttpPort;
  63. /// <summary>
  64. /// Gets or sets the HTTPS server port number.
  65. /// </summary>
  66. /// <value>The HTTPS server port number.</value>
  67. public int HttpsPortNumber { get; set; } = DefaultHttpsPort;
  68. /// <summary>
  69. /// Gets or sets a value indicating whether to use HTTPS.
  70. /// </summary>
  71. /// <remarks>
  72. /// In order for HTTPS to be used, in addition to setting this to true, valid values must also be
  73. /// provided for <see cref="ServerConfiguration.CertificatePath"/> and <see cref="ServerConfiguration.CertificatePassword"/>.
  74. /// </remarks>
  75. public bool EnableHttps { get; set; }
  76. /// <summary>
  77. /// Gets or sets the public mapped port.
  78. /// </summary>
  79. /// <value>The public mapped port.</value>
  80. public int PublicPort { get; set; } = DefaultHttpPort;
  81. /// <summary>
  82. /// Gets or sets a value indicating whether the http port should be mapped as part of UPnP automatic port forwarding.
  83. /// </summary>
  84. public bool UPnPCreateHttpPortMap { get; set; }
  85. /// <summary>
  86. /// Gets or sets the UDPPortRange.
  87. /// </summary>
  88. public string UDPPortRange { get; set; } = string.Empty;
  89. /// <summary>
  90. /// Gets or sets a value indicating whether gets or sets IPV6 capability.
  91. /// </summary>
  92. public bool EnableIPV6 { get; set; }
  93. /// <summary>
  94. /// Gets or sets a value indicating whether gets or sets IPV4 capability.
  95. /// </summary>
  96. public bool EnableIPV4 { get; set; } = true;
  97. /// <summary>
  98. /// Gets or sets a value indicating whether detailed SSDP logs are sent to the console/log.
  99. /// "Emby.Dlna": "Debug" must be set in logging.default.json for this property to have any effect.
  100. /// </summary>
  101. public bool EnableSSDPTracing { get; set; }
  102. /// <summary>
  103. /// Gets or sets the SSDPTracingFilter
  104. /// Gets or sets a value indicating whether an IP address is to be used to filter the detailed ssdp logs that are being sent to the console/log.
  105. /// If the setting "Emby.Dlna": "Debug" msut be set in logging.default.json for this property to work.
  106. /// </summary>
  107. public string SSDPTracingFilter { get; set; } = string.Empty;
  108. /// <summary>
  109. /// Gets or sets the number of times SSDP UDP messages are sent.
  110. /// </summary>
  111. public int UDPSendCount { get; set; } = 2;
  112. /// <summary>
  113. /// Gets or sets the delay between each groups of SSDP messages (in ms).
  114. /// </summary>
  115. public int UDPSendDelay { get; set; } = 100;
  116. /// <summary>
  117. /// Gets or sets a value indicating whether address names that match <see cref="VirtualInterfaceNames"/> should be Ignore for the purposes of binding.
  118. /// </summary>
  119. public bool IgnoreVirtualInterfaces { get; set; } = true;
  120. /// <summary>
  121. /// Gets or sets a value indicating the interfaces that should be ignored. The list can be comma separated. <seealso cref="IgnoreVirtualInterfaces"/>.
  122. /// </summary>
  123. public string VirtualInterfaceNames { get; set; } = "vEthernet*";
  124. /// <summary>
  125. /// Gets or sets the time (in seconds) between the pings of SSDP gateway monitor.
  126. /// </summary>
  127. public int GatewayMonitorPeriod { get; set; } = 60;
  128. /// <summary>
  129. /// Gets a value indicating whether multi-socket binding is available.
  130. /// </summary>
  131. public bool EnableMultiSocketBinding { get; } = true;
  132. /// <summary>
  133. /// Gets or sets a value indicating whether all IPv6 interfaces should be treated as on the internal network.
  134. /// Depending on the address range implemented ULA ranges might not be used.
  135. /// </summary>
  136. public bool TrustAllIP6Interfaces { get; set; }
  137. /// <summary>
  138. /// Gets or sets the ports that HDHomerun uses.
  139. /// </summary>
  140. public string HDHomerunPortRange { get; set; } = string.Empty;
  141. /// <summary>
  142. /// Gets or sets the PublishedServerUriBySubnet
  143. /// Gets or sets PublishedServerUri to advertise for specific subnets.
  144. /// </summary>
  145. public string[] PublishedServerUriBySubnet { get; set; } = Array.Empty<string>();
  146. /// <summary>
  147. /// Gets or sets a value indicating whether Autodiscovery tracing is enabled.
  148. /// </summary>
  149. public bool AutoDiscoveryTracing { get; set; }
  150. /// <summary>
  151. /// Gets or sets a value indicating whether Autodiscovery is enabled.
  152. /// </summary>
  153. public bool AutoDiscovery { get; set; } = true;
  154. /// <summary>
  155. /// Gets or sets the filter for remote IP connectivity. Used in conjuntion with <seealso cref="IsRemoteIPFilterBlacklist"/>.
  156. /// </summary>
  157. public string[] RemoteIPFilter { get; set; } = Array.Empty<string>();
  158. /// <summary>
  159. /// Gets or sets a value indicating whether <seealso cref="RemoteIPFilter"/> contains a blacklist or a whitelist. Default is a whitelist.
  160. /// </summary>
  161. public bool IsRemoteIPFilterBlacklist { get; set; }
  162. /// <summary>
  163. /// Gets or sets a value indicating whether to enable automatic port forwarding.
  164. /// </summary>
  165. public bool EnableUPnP { get; set; }
  166. /// <summary>
  167. /// Gets or sets a value indicating whether access outside of the LAN is permitted.
  168. /// </summary>
  169. public bool EnableRemoteAccess { get; set; } = true;
  170. /// <summary>
  171. /// Gets or sets the subnets that are deemed to make up the LAN.
  172. /// </summary>
  173. public string[] LocalNetworkSubnets { get; set; } = Array.Empty<string>();
  174. /// <summary>
  175. /// Gets or sets the interface addresses which Jellyfin will bind to. If empty, all interfaces will be used.
  176. /// </summary>
  177. public string[] LocalNetworkAddresses { get; set; } = Array.Empty<string>();
  178. /// <summary>
  179. /// Gets or sets the known proxies.
  180. /// </summary>
  181. public string[] KnownProxies { get; set; } = Array.Empty<string>();
  182. }
  183. }