NetworkConfiguration.cs 8.9 KB

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