|
@@ -110,38 +110,6 @@ namespace MediaBrowser.Server.Startup.Common
|
|
get { return (IServerConfigurationManager)ConfigurationManager; }
|
|
get { return (IServerConfigurationManager)ConfigurationManager; }
|
|
}
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
|
- /// Gets the name of the web application that can be used for url building.
|
|
|
|
- /// All api urls will be of the form {protocol}://{host}:{port}/{appname}/...
|
|
|
|
- /// </summary>
|
|
|
|
- /// <value>The name of the web application.</value>
|
|
|
|
- public string WebApplicationName
|
|
|
|
- {
|
|
|
|
- get { return "mediabrowser"; }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// <summary>
|
|
|
|
- /// Gets the HTTP server URL prefix.
|
|
|
|
- /// </summary>
|
|
|
|
- /// <value>The HTTP server URL prefix.</value>
|
|
|
|
- private IEnumerable<string> HttpServerUrlPrefixes
|
|
|
|
- {
|
|
|
|
- get
|
|
|
|
- {
|
|
|
|
- var list = new List<string>
|
|
|
|
- {
|
|
|
|
- "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/"
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- if (ServerConfigurationManager.Configuration.UseHttps)
|
|
|
|
- {
|
|
|
|
- list.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return list;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the configuration manager.
|
|
/// Gets the configuration manager.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -230,8 +198,6 @@ namespace MediaBrowser.Server.Startup.Common
|
|
private readonly StartupOptions _startupOptions;
|
|
private readonly StartupOptions _startupOptions;
|
|
private readonly string _remotePackageName;
|
|
private readonly string _remotePackageName;
|
|
|
|
|
|
- private bool _supportsNativeWebSocket;
|
|
|
|
-
|
|
|
|
internal INativeApp NativeApp { get; set; }
|
|
internal INativeApp NativeApp { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -242,20 +208,17 @@ namespace MediaBrowser.Server.Startup.Common
|
|
/// <param name="options">The options.</param>
|
|
/// <param name="options">The options.</param>
|
|
/// <param name="fileSystem">The file system.</param>
|
|
/// <param name="fileSystem">The file system.</param>
|
|
/// <param name="remotePackageName">Name of the remote package.</param>
|
|
/// <param name="remotePackageName">Name of the remote package.</param>
|
|
- /// <param name="supportsNativeWebSocket">if set to <c>true</c> [supports native web socket].</param>
|
|
|
|
/// <param name="nativeApp">The native application.</param>
|
|
/// <param name="nativeApp">The native application.</param>
|
|
public ApplicationHost(ServerApplicationPaths applicationPaths,
|
|
public ApplicationHost(ServerApplicationPaths applicationPaths,
|
|
ILogManager logManager,
|
|
ILogManager logManager,
|
|
StartupOptions options,
|
|
StartupOptions options,
|
|
IFileSystem fileSystem,
|
|
IFileSystem fileSystem,
|
|
string remotePackageName,
|
|
string remotePackageName,
|
|
- bool supportsNativeWebSocket,
|
|
|
|
INativeApp nativeApp)
|
|
INativeApp nativeApp)
|
|
: base(applicationPaths, logManager, fileSystem)
|
|
: base(applicationPaths, logManager, fileSystem)
|
|
{
|
|
{
|
|
_startupOptions = options;
|
|
_startupOptions = options;
|
|
_remotePackageName = remotePackageName;
|
|
_remotePackageName = remotePackageName;
|
|
- _supportsNativeWebSocket = supportsNativeWebSocket;
|
|
|
|
NativeApp = nativeApp;
|
|
NativeApp = nativeApp;
|
|
|
|
|
|
SetBaseExceptionMessage();
|
|
SetBaseExceptionMessage();
|
|
@@ -359,6 +322,9 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
|
public override async Task Init(IProgress<double> progress)
|
|
public override async Task Init(IProgress<double> progress)
|
|
{
|
|
{
|
|
|
|
+ HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber;
|
|
|
|
+ HttpsPort = ServerConfigurationManager.Configuration.HttpsPortNumber;
|
|
|
|
+
|
|
PerformPreInitMigrations();
|
|
PerformPreInitMigrations();
|
|
|
|
|
|
await base.Init(progress).ConfigureAwait(false);
|
|
await base.Init(progress).ConfigureAwait(false);
|
|
@@ -586,10 +552,10 @@ namespace MediaBrowser.Server.Startup.Common
|
|
|
|
|
|
new FFmpegValidator(Logger, ApplicationPaths).Validate(info);
|
|
new FFmpegValidator(Logger, ApplicationPaths).Validate(info);
|
|
|
|
|
|
- MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"),
|
|
|
|
- JsonSerializer,
|
|
|
|
- info.EncoderPath,
|
|
|
|
- info.ProbePath,
|
|
|
|
|
|
+ MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"),
|
|
|
|
+ JsonSerializer,
|
|
|
|
+ info.EncoderPath,
|
|
|
|
+ info.ProbePath,
|
|
info.Version,
|
|
info.Version,
|
|
ServerConfigurationManager,
|
|
ServerConfigurationManager,
|
|
FileSystemManager,
|
|
FileSystemManager,
|
|
@@ -791,6 +757,21 @@ namespace MediaBrowser.Server.Startup.Common
|
|
SyncManager.AddParts(GetExports<ISyncProvider>());
|
|
SyncManager.AddParts(GetExports<ISyncProvider>());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private IEnumerable<string> GetUrlPrefixes()
|
|
|
|
+ {
|
|
|
|
+ var prefixes = new List<string>
|
|
|
|
+ {
|
|
|
|
+ "http://+:" + ServerConfigurationManager.Configuration.HttpServerPortNumber + "/"
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrWhiteSpace(ServerConfigurationManager.Configuration.CertificatePath))
|
|
|
|
+ {
|
|
|
|
+ prefixes.Add("https://+:" + ServerConfigurationManager.Configuration.HttpsPortNumber + "/");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return prefixes;
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Starts the server.
|
|
/// Starts the server.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -798,7 +779,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- ServerManager.Start(HttpServerUrlPrefixes, ServerConfigurationManager.Configuration.CertificatePath);
|
|
|
|
|
|
+ ServerManager.Start(GetUrlPrefixes(), ServerConfigurationManager.Configuration.CertificatePath);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
@@ -817,11 +798,29 @@ namespace MediaBrowser.Server.Startup.Common
|
|
{
|
|
{
|
|
base.OnConfigurationUpdated(sender, e);
|
|
base.OnConfigurationUpdated(sender, e);
|
|
|
|
|
|
- if (!HttpServer.UrlPrefixes.SequenceEqual(HttpServerUrlPrefixes, StringComparer.OrdinalIgnoreCase))
|
|
|
|
|
|
+ var requiresRestart = false;
|
|
|
|
+
|
|
|
|
+ // Don't do anything if these haven't been set yet
|
|
|
|
+ if (HttpPort != 0 && HttpsPort != 0)
|
|
|
|
+ {
|
|
|
|
+ // Need to restart if ports have changed
|
|
|
|
+ if (ServerConfigurationManager.Configuration.HttpServerPortNumber != HttpPort ||
|
|
|
|
+ ServerConfigurationManager.Configuration.HttpsPortNumber != HttpsPort)
|
|
|
|
+ {
|
|
|
|
+ ServerConfigurationManager.Configuration.IsPortAuthorized = false;
|
|
|
|
+ ServerConfigurationManager.SaveConfiguration();
|
|
|
|
+
|
|
|
|
+ requiresRestart = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!HttpServer.UrlPrefixes.SequenceEqual(GetUrlPrefixes(), StringComparer.OrdinalIgnoreCase))
|
|
{
|
|
{
|
|
- ServerConfigurationManager.Configuration.IsPortAuthorized = false;
|
|
|
|
- ServerConfigurationManager.SaveConfiguration();
|
|
|
|
|
|
+ requiresRestart = true;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ if (requiresRestart)
|
|
|
|
+ {
|
|
NotifyPendingRestart();
|
|
NotifyPendingRestart();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -953,7 +952,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
HasPendingRestart = HasPendingRestart,
|
|
HasPendingRestart = HasPendingRestart,
|
|
Version = ApplicationVersion.ToString(),
|
|
Version = ApplicationVersion.ToString(),
|
|
IsNetworkDeployed = CanSelfUpdate,
|
|
IsNetworkDeployed = CanSelfUpdate,
|
|
- WebSocketPortNumber = HttpServerPort,
|
|
|
|
|
|
+ WebSocketPortNumber = HttpPort,
|
|
FailedPluginAssemblies = FailedAssemblies.ToList(),
|
|
FailedPluginAssemblies = FailedAssemblies.ToList(),
|
|
InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToList(),
|
|
InProgressInstallations = InstallationManager.CurrentInstallations.Select(i => i.Item1).ToList(),
|
|
CompletedInstallations = InstallationManager.CompletedInstallations.ToList(),
|
|
CompletedInstallations = InstallationManager.CompletedInstallations.ToList(),
|
|
@@ -964,9 +963,9 @@ namespace MediaBrowser.Server.Startup.Common
|
|
InternalMetadataPath = ApplicationPaths.InternalMetadataPath,
|
|
InternalMetadataPath = ApplicationPaths.InternalMetadataPath,
|
|
CachePath = ApplicationPaths.CachePath,
|
|
CachePath = ApplicationPaths.CachePath,
|
|
MacAddress = GetMacAddress(),
|
|
MacAddress = GetMacAddress(),
|
|
- HttpServerPortNumber = HttpServerPort,
|
|
|
|
- UseHttps = this.ServerConfigurationManager.Configuration.UseHttps,
|
|
|
|
- HttpsPortNumber = HttpsServerPort,
|
|
|
|
|
|
+ HttpServerPortNumber = HttpPort,
|
|
|
|
+ EnableHttps = EnableHttps,
|
|
|
|
+ HttpsPortNumber = HttpsPort,
|
|
OperatingSystem = OperatingSystemDisplayName,
|
|
OperatingSystem = OperatingSystemDisplayName,
|
|
CanSelfRestart = CanSelfRestart,
|
|
CanSelfRestart = CanSelfRestart,
|
|
CanSelfUpdate = CanSelfUpdate,
|
|
CanSelfUpdate = CanSelfUpdate,
|
|
@@ -981,6 +980,19 @@ namespace MediaBrowser.Server.Startup.Common
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public bool EnableHttps
|
|
|
|
+ {
|
|
|
|
+ get
|
|
|
|
+ {
|
|
|
|
+ return SupportsHttps && ServerConfigurationManager.Configuration.EnableHttps;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public bool SupportsHttps
|
|
|
|
+ {
|
|
|
|
+ get { return !string.IsNullOrWhiteSpace(HttpServer.CertificatePath); }
|
|
|
|
+ }
|
|
|
|
+
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the local ip address.
|
|
/// Gets the local ip address.
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -994,7 +1006,7 @@ namespace MediaBrowser.Server.Startup.Common
|
|
{
|
|
{
|
|
address = string.Format("http://{0}:{1}",
|
|
address = string.Format("http://{0}:{1}",
|
|
address,
|
|
address,
|
|
- ServerConfigurationManager.Configuration.HttpServerPortNumber.ToString(CultureInfo.InvariantCulture));
|
|
|
|
|
|
+ HttpPort.ToString(CultureInfo.InvariantCulture));
|
|
}
|
|
}
|
|
|
|
|
|
return address;
|
|
return address;
|
|
@@ -1036,15 +1048,9 @@ namespace MediaBrowser.Server.Startup.Common
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public int HttpServerPort
|
|
|
|
- {
|
|
|
|
- get { return ServerConfigurationManager.Configuration.HttpServerPortNumber; }
|
|
|
|
- }
|
|
|
|
|
|
+ public int HttpPort { get; private set; }
|
|
|
|
|
|
- public int HttpsServerPort
|
|
|
|
- {
|
|
|
|
- get { return ServerConfigurationManager.Configuration.HttpsPortNumber; }
|
|
|
|
- }
|
|
|
|
|
|
+ public int HttpsPort { get; private set; }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// Gets the mac address.
|
|
/// Gets the mac address.
|