IServerApplicationHost.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Net;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using MediaBrowser.Common;
  7. using MediaBrowser.Model.System;
  8. using Microsoft.AspNetCore.Http;
  9. namespace MediaBrowser.Controller
  10. {
  11. /// <summary>
  12. /// Interface IServerApplicationHost.
  13. /// </summary>
  14. public interface IServerApplicationHost : IApplicationHost
  15. {
  16. event EventHandler HasUpdateAvailableChanged;
  17. /// <summary>
  18. /// Gets the system info.
  19. /// </summary>
  20. /// <returns>SystemInfo.</returns>
  21. Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken);
  22. Task<PublicSystemInfo> GetPublicSystemInfo(CancellationToken cancellationToken);
  23. bool CanLaunchWebBrowser { get; }
  24. /// <summary>
  25. /// Gets the HTTP server port.
  26. /// </summary>
  27. /// <value>The HTTP server port.</value>
  28. int HttpPort { get; }
  29. /// <summary>
  30. /// Gets the HTTPS port.
  31. /// </summary>
  32. /// <value>The HTTPS port.</value>
  33. int HttpsPort { get; }
  34. /// <summary>
  35. /// Gets a value indicating whether the server should listen on an HTTPS port.
  36. /// </summary>
  37. bool ListenWithHttps { get; }
  38. /// <summary>
  39. /// Gets a value indicating whether this instance has update available.
  40. /// </summary>
  41. /// <value><c>true</c> if this instance has update available; otherwise, <c>false</c>.</value>
  42. bool HasUpdateAvailable { get; }
  43. /// <summary>
  44. /// Gets the name of the friendly.
  45. /// </summary>
  46. /// <value>The name of the friendly.</value>
  47. string FriendlyName { get; }
  48. /// <summary>
  49. /// Gets all the local IP addresses of this API instance. Each address is validated by sending a 'ping' request
  50. /// to the API that should exist at the address.
  51. /// </summary>
  52. /// <param name="cancellationToken">A cancellation token that can be used to cancel the task.</param>
  53. /// <returns>A list containing all the local IP addresses of the server.</returns>
  54. Task<List<IPAddress>> GetLocalIpAddresses(CancellationToken cancellationToken);
  55. /// <summary>
  56. /// Gets a local (LAN) URL that can be used to access the API. The hostname used is the first valid configured
  57. /// IP address that can be found via <see cref="GetLocalIpAddresses"/>. HTTPS will be preferred when available.
  58. /// </summary>
  59. /// <param name="cancellationToken">A cancellation token that can be used to cancel the task.</param>
  60. /// <returns>The server URL.</returns>
  61. Task<string> GetLocalApiUrl(CancellationToken cancellationToken);
  62. /// <summary>
  63. /// Gets a localhost URL that can be used to access the API using the loop-back IP address (127.0.0.1)
  64. /// over HTTP (not HTTPS).
  65. /// </summary>
  66. /// <returns>The API URL.</returns>
  67. string GetLoopbackHttpApiUrl();
  68. /// <summary>
  69. /// Gets a local (LAN) URL that can be used to access the API. HTTPS will be preferred when available.
  70. /// </summary>
  71. /// <param name="address">The IP address to use as the hostname in the URL.</param>
  72. /// <returns>The API URL.</returns>
  73. string GetLocalApiUrl(IPAddress address);
  74. /// <summary>
  75. /// Gets a local (LAN) URL that can be used to access the API.
  76. /// Note: if passing non-null scheme or port it is up to the caller to ensure they form the correct pair.
  77. /// </summary>
  78. /// <param name="hostname">The hostname to use in the URL.</param>
  79. /// <param name="scheme">
  80. /// The scheme to use for the URL. If null, the scheme will be selected automatically,
  81. /// preferring HTTPS, if available.
  82. /// </param>
  83. /// <param name="port">
  84. /// The port to use for the URL. If null, the port will be selected automatically,
  85. /// preferring the HTTPS port, if available.
  86. /// </param>
  87. /// <returns>The API URL.</returns>
  88. string GetLocalApiUrl(ReadOnlySpan<char> hostname, string scheme = null, int? port = null);
  89. /// <summary>
  90. /// Open a URL in an external browser window.
  91. /// </summary>
  92. /// <param name="url">The URL to open.</param>
  93. /// <exception cref="NotSupportedException"><see cref="CanLaunchWebBrowser"/> is false.</exception>
  94. void LaunchUrl(string url);
  95. void EnableLoopback(string appName);
  96. IEnumerable<WakeOnLanInfo> GetWakeOnLanInfo();
  97. string ExpandVirtualPath(string path);
  98. string ReverseVirtualPath(string path);
  99. Task ExecuteHttpHandlerAsync(HttpContext context, Func<Task> next);
  100. }
  101. }