NetworkConfiguration.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. public bool EnableUPnP { get; set; }
  95. /// <summary>
  96. /// Gets or sets a value indicating whether IPv6 is enabled.
  97. /// </summary>
  98. public bool EnableIPv4 { get; set; } = true;
  99. /// <summary>
  100. /// Gets or sets a value indicating whether IPv6 is enabled.
  101. /// </summary>
  102. public bool EnableIPv6 { get; set; }
  103. /// <summary>
  104. /// Gets or sets a value indicating whether access from outside of the LAN is permitted.
  105. /// </summary>
  106. public bool EnableRemoteAccess { get; set; } = true;
  107. /// <summary>
  108. /// Gets or sets the subnets that are deemed to make up the LAN.
  109. /// </summary>
  110. public string[] LocalNetworkSubnets { get; set; } = Array.Empty<string>();
  111. /// <summary>
  112. /// Gets or sets the interface addresses which Jellyfin will bind to. If empty, all interfaces will be used.
  113. /// </summary>
  114. public string[] LocalNetworkAddresses { get; set; } = Array.Empty<string>();
  115. /// <summary>
  116. /// Gets or sets the known proxies.
  117. /// </summary>
  118. public string[] KnownProxies { get; set; } = Array.Empty<string>();
  119. /// <summary>
  120. /// Gets or sets a value indicating whether address names that match <see cref="VirtualInterfaceNames"/> should be ignored for the purposes of binding.
  121. /// </summary>
  122. public bool IgnoreVirtualInterfaces { get; set; } = true;
  123. /// <summary>
  124. /// 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"/>.
  125. /// </summary>
  126. public string[] VirtualInterfaceNames { get; set; } = new string[] { "veth" };
  127. /// <summary>
  128. /// Gets or sets a value indicating whether the published server uri is based on information in HTTP requests.
  129. /// </summary>
  130. public bool EnablePublishedServerUriByRequest { get; set; } = false;
  131. /// <summary>
  132. /// Gets or sets the PublishedServerUriBySubnet
  133. /// Gets or sets PublishedServerUri to advertise for specific subnets.
  134. /// </summary>
  135. public string[] PublishedServerUriBySubnet { get; set; } = Array.Empty<string>();
  136. /// <summary>
  137. /// Gets or sets the filter for remote IP connectivity. Used in conjunction with <seealso cref="IsRemoteIPFilterBlacklist"/>.
  138. /// </summary>
  139. public string[] RemoteIPFilter { get; set; } = Array.Empty<string>();
  140. /// <summary>
  141. /// Gets or sets a value indicating whether <seealso cref="RemoteIPFilter"/> contains a blacklist or a whitelist. Default is a whitelist.
  142. /// </summary>
  143. public bool IsRemoteIPFilterBlacklist { get; set; }
  144. }