NetworkConfiguration.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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="InternalHttpPort"/>.
  12. /// </summary>
  13. public const int DefaultHttpPort = 8096;
  14. /// <summary>
  15. /// The default value for <see cref="PublicHttpsPort"/> and <see cref="InternalHttpsPort"/>.
  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 internal HTTP server port.
  70. /// </summary>
  71. /// <value>The HTTP server port.</value>
  72. public int InternalHttpPort { get; set; } = DefaultHttpPort;
  73. /// <summary>
  74. /// Gets or sets the internal HTTPS server port.
  75. /// </summary>
  76. /// <value>The HTTPS server port.</value>
  77. public int InternalHttpsPort { get; set; } = DefaultHttpsPort;
  78. /// <summary>
  79. /// Gets or sets the public HTTP port.
  80. /// </summary>
  81. /// <value>The public HTTP port.</value>
  82. public int PublicHttpPort { get; set; } = DefaultHttpPort;
  83. /// <summary>
  84. /// Gets or sets the public HTTPS port.
  85. /// </summary>
  86. /// <value>The public HTTPS port.</value>
  87. public int PublicHttpsPort { get; set; } = DefaultHttpsPort;
  88. /// <summary>
  89. /// Gets or sets a value indicating whether Autodiscovery is enabled.
  90. /// </summary>
  91. public bool AutoDiscovery { get; set; } = true;
  92. /// <summary>
  93. /// Gets or sets a value indicating whether to enable automatic port forwarding.
  94. /// </summary>
  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. }
  146. }