NetworkConfiguration.cs 8.7 KB

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