|
@@ -34,10 +34,8 @@ using Emby.Server.Implementations.IO;
|
|
|
using Emby.Server.Implementations.Library;
|
|
|
using Emby.Server.Implementations.LiveTv;
|
|
|
using Emby.Server.Implementations.Localization;
|
|
|
-using Emby.Server.Implementations.Middleware;
|
|
|
using Emby.Server.Implementations.Net;
|
|
|
using Emby.Server.Implementations.Playlists;
|
|
|
-using Emby.Server.Implementations.Reflection;
|
|
|
using Emby.Server.Implementations.ScheduledTasks;
|
|
|
using Emby.Server.Implementations.Security;
|
|
|
using Emby.Server.Implementations.Serialization;
|
|
@@ -45,7 +43,6 @@ using Emby.Server.Implementations.Session;
|
|
|
using Emby.Server.Implementations.SocketSharp;
|
|
|
using Emby.Server.Implementations.TV;
|
|
|
using Emby.Server.Implementations.Updates;
|
|
|
-using Emby.Server.Implementations.Xml;
|
|
|
using MediaBrowser.Api;
|
|
|
using MediaBrowser.Common;
|
|
|
using MediaBrowser.Common.Configuration;
|
|
@@ -93,13 +90,11 @@ using MediaBrowser.Model.Globalization;
|
|
|
using MediaBrowser.Model.IO;
|
|
|
using MediaBrowser.Model.MediaInfo;
|
|
|
using MediaBrowser.Model.Net;
|
|
|
-using MediaBrowser.Model.Reflection;
|
|
|
using MediaBrowser.Model.Serialization;
|
|
|
using MediaBrowser.Model.Services;
|
|
|
using MediaBrowser.Model.System;
|
|
|
using MediaBrowser.Model.Tasks;
|
|
|
using MediaBrowser.Model.Updates;
|
|
|
-using MediaBrowser.Model.Xml;
|
|
|
using MediaBrowser.Providers.Chapters;
|
|
|
using MediaBrowser.Providers.Manager;
|
|
|
using MediaBrowser.Providers.Subtitles;
|
|
@@ -115,6 +110,7 @@ using Microsoft.Extensions.Logging;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
|
using ServiceStack;
|
|
|
+using OperatingSystem = MediaBrowser.Common.System.OperatingSystem;
|
|
|
|
|
|
namespace Emby.Server.Implementations
|
|
|
{
|
|
@@ -143,12 +139,8 @@ namespace Emby.Server.Implementations
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- if (EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.Windows)
|
|
|
- {
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- if (EnvironmentInfo.OperatingSystem == MediaBrowser.Model.System.OperatingSystem.OSX)
|
|
|
+ if (OperatingSystem.Id == OperatingSystemId.Windows
|
|
|
+ || OperatingSystem.Id == OperatingSystemId.Darwin)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
@@ -168,7 +160,7 @@ namespace Emby.Server.Implementations
|
|
|
public event EventHandler<GenericEventArgs<PackageVersionInfo>> ApplicationUpdated;
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Gets or sets a value indicating whether this instance has changes that require the entire application to restart.
|
|
|
+ /// Gets a value indicating whether this instance has changes that require the entire application to restart.
|
|
|
/// </summary>
|
|
|
/// <value><c>true</c> if this instance has pending application restart; otherwise, <c>false</c>.</value>
|
|
|
public bool HasPendingRestart { get; private set; }
|
|
@@ -182,7 +174,7 @@ namespace Emby.Server.Implementations
|
|
|
protected ILogger Logger { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Gets or sets the plugins.
|
|
|
+ /// Gets the plugins.
|
|
|
/// </summary>
|
|
|
/// <value>The plugins.</value>
|
|
|
public IPlugin[] Plugins { get; protected set; }
|
|
@@ -194,13 +186,13 @@ namespace Emby.Server.Implementations
|
|
|
public ILoggerFactory LoggerFactory { get; protected set; }
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Gets the application paths.
|
|
|
+ /// Gets or sets the application paths.
|
|
|
/// </summary>
|
|
|
/// <value>The application paths.</value>
|
|
|
protected ServerApplicationPaths ApplicationPaths { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
|
- /// Gets all concrete types.
|
|
|
+ /// Gets or sets all concrete types.
|
|
|
/// </summary>
|
|
|
/// <value>All concrete types.</value>
|
|
|
public Type[] AllConcreteTypes { get; protected set; }
|
|
@@ -208,7 +200,7 @@ namespace Emby.Server.Implementations
|
|
|
/// <summary>
|
|
|
/// The disposable parts
|
|
|
/// </summary>
|
|
|
- protected readonly List<IDisposable> DisposableParts = new List<IDisposable>();
|
|
|
+ protected readonly List<IDisposable> _disposableParts = new List<IDisposable>();
|
|
|
|
|
|
/// <summary>
|
|
|
/// Gets the configuration manager.
|
|
@@ -218,8 +210,6 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
public IFileSystem FileSystemManager { get; set; }
|
|
|
|
|
|
- protected IEnvironmentInfo EnvironmentInfo { get; set; }
|
|
|
-
|
|
|
public PackageVersionClass SystemUpdateLevel
|
|
|
{
|
|
|
get
|
|
@@ -239,15 +229,6 @@ namespace Emby.Server.Implementations
|
|
|
/// <value>The server configuration manager.</value>
|
|
|
public IServerConfigurationManager ServerConfigurationManager => (IServerConfigurationManager)ConfigurationManager;
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// Gets the configuration manager.
|
|
|
- /// </summary>
|
|
|
- /// <returns>IConfigurationManager.</returns>
|
|
|
- protected IConfigurationManager GetConfigurationManager()
|
|
|
- {
|
|
|
- return new ServerConfigurationManager(ApplicationPaths, LoggerFactory, XmlSerializer, FileSystemManager);
|
|
|
- }
|
|
|
-
|
|
|
protected virtual IResourceFileManager CreateResourceFileManager()
|
|
|
{
|
|
|
return new ResourceFileManager(HttpResultFactory, LoggerFactory, FileSystemManager);
|
|
@@ -258,27 +239,33 @@ namespace Emby.Server.Implementations
|
|
|
/// </summary>
|
|
|
/// <value>The user manager.</value>
|
|
|
public IUserManager UserManager { get; set; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Gets or sets the library manager.
|
|
|
/// </summary>
|
|
|
/// <value>The library manager.</value>
|
|
|
internal ILibraryManager LibraryManager { get; set; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Gets or sets the directory watchers.
|
|
|
/// </summary>
|
|
|
/// <value>The directory watchers.</value>
|
|
|
private ILibraryMonitor LibraryMonitor { get; set; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Gets or sets the provider manager.
|
|
|
/// </summary>
|
|
|
/// <value>The provider manager.</value>
|
|
|
private IProviderManager ProviderManager { get; set; }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Gets or sets the HTTP server.
|
|
|
/// </summary>
|
|
|
/// <value>The HTTP server.</value>
|
|
|
private IHttpServer HttpServer { get; set; }
|
|
|
+
|
|
|
private IDtoService DtoService { get; set; }
|
|
|
+
|
|
|
public IImageProcessor ImageProcessor { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
@@ -286,6 +273,7 @@ namespace Emby.Server.Implementations
|
|
|
/// </summary>
|
|
|
/// <value>The media encoder.</value>
|
|
|
private IMediaEncoder MediaEncoder { get; set; }
|
|
|
+
|
|
|
private ISubtitleEncoder SubtitleEncoder { get; set; }
|
|
|
|
|
|
private ISessionManager SessionManager { get; set; }
|
|
@@ -295,6 +283,7 @@ namespace Emby.Server.Implementations
|
|
|
public LocalizationManager LocalizationManager { get; set; }
|
|
|
|
|
|
private IEncodingManager EncodingManager { get; set; }
|
|
|
+
|
|
|
private IChannelManager ChannelManager { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
@@ -302,20 +291,29 @@ namespace Emby.Server.Implementations
|
|
|
/// </summary>
|
|
|
/// <value>The user data repository.</value>
|
|
|
private IUserDataManager UserDataManager { get; set; }
|
|
|
+
|
|
|
private IUserRepository UserRepository { get; set; }
|
|
|
+
|
|
|
internal SqliteItemRepository ItemRepository { get; set; }
|
|
|
|
|
|
private INotificationManager NotificationManager { get; set; }
|
|
|
+
|
|
|
private ISubtitleManager SubtitleManager { get; set; }
|
|
|
+
|
|
|
private IChapterManager ChapterManager { get; set; }
|
|
|
+
|
|
|
private IDeviceManager DeviceManager { get; set; }
|
|
|
|
|
|
internal IUserViewManager UserViewManager { get; set; }
|
|
|
|
|
|
private IAuthenticationRepository AuthenticationRepository { get; set; }
|
|
|
+
|
|
|
private ITVSeriesManager TVSeriesManager { get; set; }
|
|
|
+
|
|
|
private ICollectionManager CollectionManager { get; set; }
|
|
|
+
|
|
|
private IMediaSourceManager MediaSourceManager { get; set; }
|
|
|
+
|
|
|
private IPlaylistManager PlaylistManager { get; set; }
|
|
|
|
|
|
private readonly IConfiguration _configuration;
|
|
@@ -331,32 +329,40 @@ namespace Emby.Server.Implementations
|
|
|
/// </summary>
|
|
|
/// <value>The zip client.</value>
|
|
|
protected IZipClient ZipClient { get; private set; }
|
|
|
+
|
|
|
protected IHttpResultFactory HttpResultFactory { get; private set; }
|
|
|
+
|
|
|
protected IAuthService AuthService { get; private set; }
|
|
|
|
|
|
- public IStartupOptions StartupOptions { get; private set; }
|
|
|
+ public IStartupOptions StartupOptions { get; }
|
|
|
|
|
|
internal IImageEncoder ImageEncoder { get; private set; }
|
|
|
|
|
|
protected IProcessFactory ProcessFactory { get; private set; }
|
|
|
+
|
|
|
protected ICryptoProvider CryptographyProvider = new CryptographyProvider();
|
|
|
protected readonly IXmlSerializer XmlSerializer;
|
|
|
|
|
|
protected ISocketFactory SocketFactory { get; private set; }
|
|
|
+
|
|
|
protected ITaskManager TaskManager { get; private set; }
|
|
|
+
|
|
|
public IHttpClient HttpClient { get; private set; }
|
|
|
+
|
|
|
protected INetworkManager NetworkManager { get; set; }
|
|
|
+
|
|
|
public IJsonSerializer JsonSerializer { get; private set; }
|
|
|
+
|
|
|
protected IIsoManager IsoManager { get; private set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// Initializes a new instance of the <see cref="ApplicationHost" /> class.
|
|
|
/// </summary>
|
|
|
- public ApplicationHost(ServerApplicationPaths applicationPaths,
|
|
|
+ public ApplicationHost(
|
|
|
+ ServerApplicationPaths applicationPaths,
|
|
|
ILoggerFactory loggerFactory,
|
|
|
IStartupOptions options,
|
|
|
IFileSystem fileSystem,
|
|
|
- IEnvironmentInfo environmentInfo,
|
|
|
IImageEncoder imageEncoder,
|
|
|
INetworkManager networkManager,
|
|
|
IConfiguration configuration)
|
|
@@ -370,13 +376,12 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
NetworkManager = networkManager;
|
|
|
networkManager.LocalSubnetsFn = GetConfiguredLocalSubnets;
|
|
|
- EnvironmentInfo = environmentInfo;
|
|
|
|
|
|
ApplicationPaths = applicationPaths;
|
|
|
LoggerFactory = loggerFactory;
|
|
|
FileSystemManager = fileSystem;
|
|
|
|
|
|
- ConfigurationManager = GetConfigurationManager();
|
|
|
+ ConfigurationManager = new ServerConfigurationManager(ApplicationPaths, LoggerFactory, XmlSerializer, FileSystemManager);
|
|
|
|
|
|
Logger = LoggerFactory.CreateLogger("App");
|
|
|
|
|
@@ -415,7 +420,7 @@ namespace Emby.Server.Implementations
|
|
|
_validAddressResults.Clear();
|
|
|
}
|
|
|
|
|
|
- public string ApplicationVersion => typeof(ApplicationHost).Assembly.GetName().Version.ToString(3);
|
|
|
+ public string ApplicationVersion { get; } = typeof(ApplicationHost).Assembly.GetName().Version.ToString(3);
|
|
|
|
|
|
/// <summary>
|
|
|
/// Gets the current application user agent
|
|
@@ -423,14 +428,23 @@ namespace Emby.Server.Implementations
|
|
|
/// <value>The application user agent.</value>
|
|
|
public string ApplicationUserAgent => Name.Replace(' ','-') + "/" + ApplicationVersion;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Gets the email address for use within a comment section of a user agent field.
|
|
|
+ /// Presently used to provide contact information to MusicBrainz service.
|
|
|
+ /// </summary>
|
|
|
+ public string ApplicationUserAgentAddress { get; } = "team@jellyfin.org";
|
|
|
+
|
|
|
private string _productName;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Gets the current application name
|
|
|
/// </summary>
|
|
|
/// <value>The application name.</value>
|
|
|
- public string ApplicationProductName => _productName ?? (_productName = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductName);
|
|
|
+ public string ApplicationProductName
|
|
|
+ => _productName ?? (_productName = FileVersionInfo.GetVersionInfo(Assembly.GetEntryAssembly().Location).ProductName);
|
|
|
|
|
|
private DeviceId _deviceId;
|
|
|
+
|
|
|
public string SystemId
|
|
|
{
|
|
|
get
|
|
@@ -461,15 +475,15 @@ namespace Emby.Server.Implementations
|
|
|
/// <summary>
|
|
|
/// Creates an instance of type and resolves all constructor dependencies
|
|
|
/// </summary>
|
|
|
- /// <param name="type">The type.</param>
|
|
|
- /// <returns>System.Object.</returns>
|
|
|
+ /// /// <typeparam name="T">The type</typeparam>
|
|
|
+ /// <returns>T</returns>
|
|
|
public T CreateInstance<T>()
|
|
|
=> ActivatorUtilities.CreateInstance<T>(_serviceProvider);
|
|
|
|
|
|
/// <summary>
|
|
|
/// Creates the instance safe.
|
|
|
/// </summary>
|
|
|
- /// <param name="typeInfo">The type information.</param>
|
|
|
+ /// <param name="type">The type.</param>
|
|
|
/// <returns>System.Object.</returns>
|
|
|
protected object CreateInstanceSafe(Type type)
|
|
|
{
|
|
@@ -488,14 +502,14 @@ namespace Emby.Server.Implementations
|
|
|
/// <summary>
|
|
|
/// Resolves this instance.
|
|
|
/// </summary>
|
|
|
- /// <typeparam name="T"></typeparam>
|
|
|
+ /// <typeparam name="T">The type</typeparam>
|
|
|
/// <returns>``0.</returns>
|
|
|
public T Resolve<T>() => _serviceProvider.GetService<T>();
|
|
|
|
|
|
/// <summary>
|
|
|
/// Gets the export types.
|
|
|
/// </summary>
|
|
|
- /// <typeparam name="T"></typeparam>
|
|
|
+ /// <typeparam name="T">The type</typeparam>
|
|
|
/// <returns>IEnumerable{Type}.</returns>
|
|
|
public IEnumerable<Type> GetExportTypes<T>()
|
|
|
{
|
|
@@ -507,22 +521,22 @@ namespace Emby.Server.Implementations
|
|
|
/// <summary>
|
|
|
/// Gets the exports.
|
|
|
/// </summary>
|
|
|
- /// <typeparam name="T"></typeparam>
|
|
|
+ /// <typeparam name="T">The type</typeparam>
|
|
|
/// <param name="manageLifetime">if set to <c>true</c> [manage lifetime].</param>
|
|
|
/// <returns>IEnumerable{``0}.</returns>
|
|
|
public IEnumerable<T> GetExports<T>(bool manageLifetime = true)
|
|
|
{
|
|
|
var parts = GetExportTypes<T>()
|
|
|
- .Select(x => CreateInstanceSafe(x))
|
|
|
+ .Select(CreateInstanceSafe)
|
|
|
.Where(i => i != null)
|
|
|
.Cast<T>()
|
|
|
.ToList(); // Convert to list so this isn't executed for each iteration
|
|
|
|
|
|
if (manageLifetime)
|
|
|
{
|
|
|
- lock (DisposableParts)
|
|
|
+ lock (_disposableParts)
|
|
|
{
|
|
|
- DisposableParts.AddRange(parts.OfType<IDisposable>());
|
|
|
+ _disposableParts.AddRange(parts.OfType<IDisposable>());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -532,7 +546,7 @@ namespace Emby.Server.Implementations
|
|
|
/// <summary>
|
|
|
/// Runs the startup tasks.
|
|
|
/// </summary>
|
|
|
- public async Task RunStartupTasks()
|
|
|
+ public async Task RunStartupTasksAsync()
|
|
|
{
|
|
|
Logger.LogInformation("Running startup tasks");
|
|
|
|
|
@@ -542,29 +556,20 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
MediaEncoder.SetFFmpegPath();
|
|
|
|
|
|
- //if (string.IsNullOrWhiteSpace(MediaEncoder.EncoderPath))
|
|
|
- //{
|
|
|
- // if (ServerConfigurationManager.Configuration.IsStartupWizardCompleted)
|
|
|
- // {
|
|
|
- // ServerConfigurationManager.Configuration.IsStartupWizardCompleted = false;
|
|
|
- // ServerConfigurationManager.SaveConfiguration();
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
Logger.LogInformation("ServerId: {0}", SystemId);
|
|
|
|
|
|
- var entryPoints = GetExports<IServerEntryPoint>();
|
|
|
+ var entryPoints = GetExports<IServerEntryPoint>().ToList();
|
|
|
|
|
|
var stopWatch = new Stopwatch();
|
|
|
stopWatch.Start();
|
|
|
- await Task.WhenAll(StartEntryPoints(entryPoints, true));
|
|
|
+ await Task.WhenAll(StartEntryPoints(entryPoints, true)).ConfigureAwait(false);
|
|
|
Logger.LogInformation("Executed all pre-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
|
|
|
|
|
|
Logger.LogInformation("Core startup complete");
|
|
|
HttpServer.GlobalResponse = null;
|
|
|
|
|
|
stopWatch.Restart();
|
|
|
- await Task.WhenAll(StartEntryPoints(entryPoints, false));
|
|
|
+ await Task.WhenAll(StartEntryPoints(entryPoints, false)).ConfigureAwait(false);
|
|
|
Logger.LogInformation("Executed all post-startup entry points in {Elapsed:g}", stopWatch.Elapsed);
|
|
|
stopWatch.Stop();
|
|
|
}
|
|
@@ -584,7 +589,7 @@ namespace Emby.Server.Implementations
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public async Task Init(IServiceCollection serviceCollection)
|
|
|
+ public async Task InitAsync(IServiceCollection serviceCollection)
|
|
|
{
|
|
|
HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber;
|
|
|
HttpsPort = ServerConfigurationManager.Configuration.HttpsPortNumber;
|
|
@@ -614,14 +619,14 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
SetHttpLimit();
|
|
|
|
|
|
- await RegisterResources(serviceCollection);
|
|
|
+ await RegisterResources(serviceCollection).ConfigureAwait(false);
|
|
|
|
|
|
FindParts();
|
|
|
|
|
|
string contentRoot = ServerConfigurationManager.Configuration.DashboardSourcePath;
|
|
|
if (string.IsNullOrEmpty(contentRoot))
|
|
|
{
|
|
|
- contentRoot = Path.Combine(ServerConfigurationManager.ApplicationPaths.ApplicationResourcesPath, "jellyfin-web", "src");
|
|
|
+ contentRoot = ServerConfigurationManager.ApplicationPaths.WebPath;
|
|
|
}
|
|
|
|
|
|
var host = new WebHostBuilder()
|
|
@@ -629,7 +634,7 @@ namespace Emby.Server.Implementations
|
|
|
{
|
|
|
options.ListenAnyIP(HttpPort);
|
|
|
|
|
|
- if (EnableHttps)
|
|
|
+ if (EnableHttps && Certificate != null)
|
|
|
{
|
|
|
options.ListenAnyIP(HttpsPort, listenOptions => { listenOptions.UseHttps(Certificate); });
|
|
|
}
|
|
@@ -651,7 +656,7 @@ namespace Emby.Server.Implementations
|
|
|
})
|
|
|
.Build();
|
|
|
|
|
|
- await host.StartAsync();
|
|
|
+ await host.StartAsync().ConfigureAwait(false);
|
|
|
}
|
|
|
|
|
|
private async Task ExecuteWebsocketHandlerAsync(HttpContext context, Func<Task> next)
|
|
@@ -700,14 +705,14 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
serviceCollection.AddSingleton<IApplicationPaths>(ApplicationPaths);
|
|
|
|
|
|
+ serviceCollection.AddSingleton<IConfiguration>(_configuration);
|
|
|
+
|
|
|
serviceCollection.AddSingleton(JsonSerializer);
|
|
|
|
|
|
serviceCollection.AddSingleton(LoggerFactory);
|
|
|
serviceCollection.AddLogging();
|
|
|
serviceCollection.AddSingleton(Logger);
|
|
|
|
|
|
- serviceCollection.AddSingleton(EnvironmentInfo);
|
|
|
-
|
|
|
serviceCollection.AddSingleton(FileSystemManager);
|
|
|
serviceCollection.AddSingleton<TvDbClientManager>();
|
|
|
|
|
@@ -749,17 +754,12 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
serviceCollection.AddSingleton(ServerConfigurationManager);
|
|
|
|
|
|
- var assemblyInfo = new AssemblyInfo();
|
|
|
- serviceCollection.AddSingleton<IAssemblyInfo>(assemblyInfo);
|
|
|
-
|
|
|
- LocalizationManager = new LocalizationManager(ServerConfigurationManager, FileSystemManager, JsonSerializer, LoggerFactory);
|
|
|
- await LocalizationManager.LoadAll();
|
|
|
+ LocalizationManager = new LocalizationManager(ServerConfigurationManager, JsonSerializer, LoggerFactory);
|
|
|
+ await LocalizationManager.LoadAll().ConfigureAwait(false);
|
|
|
serviceCollection.AddSingleton<ILocalizationManager>(LocalizationManager);
|
|
|
|
|
|
serviceCollection.AddSingleton<IBlurayExaminer>(new BdInfoExaminer(FileSystemManager));
|
|
|
|
|
|
- serviceCollection.AddSingleton<IXmlReaderSettingsFactory>(new XmlReaderSettingsFactory());
|
|
|
-
|
|
|
UserDataManager = new UserDataManager(LoggerFactory, ServerConfigurationManager, () => UserManager);
|
|
|
serviceCollection.AddSingleton(UserDataManager);
|
|
|
|
|
@@ -770,7 +770,7 @@ namespace Emby.Server.Implementations
|
|
|
var displayPreferencesRepo = new SqliteDisplayPreferencesRepository(LoggerFactory, JsonSerializer, ApplicationPaths, FileSystemManager);
|
|
|
serviceCollection.AddSingleton<IDisplayPreferencesRepository>(displayPreferencesRepo);
|
|
|
|
|
|
- ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory, assemblyInfo);
|
|
|
+ ItemRepository = new SqliteItemRepository(ServerConfigurationManager, this, JsonSerializer, LoggerFactory);
|
|
|
serviceCollection.AddSingleton<IItemRepository>(ItemRepository);
|
|
|
|
|
|
AuthenticationRepository = GetAuthenticationRepository();
|
|
@@ -786,7 +786,7 @@ namespace Emby.Server.Implementations
|
|
|
var musicManager = new MusicManager(LibraryManager);
|
|
|
serviceCollection.AddSingleton<IMusicManager>(new MusicManager(LibraryManager));
|
|
|
|
|
|
- LibraryMonitor = new LibraryMonitor(LoggerFactory, LibraryManager, ServerConfigurationManager, FileSystemManager, EnvironmentInfo);
|
|
|
+ LibraryMonitor = new LibraryMonitor(LoggerFactory, LibraryManager, ServerConfigurationManager, FileSystemManager);
|
|
|
serviceCollection.AddSingleton(LibraryMonitor);
|
|
|
|
|
|
serviceCollection.AddSingleton<ISearchEngine>(new SearchEngine(LoggerFactory, LibraryManager, UserManager));
|
|
@@ -794,16 +794,19 @@ namespace Emby.Server.Implementations
|
|
|
CertificateInfo = GetCertificateInfo(true);
|
|
|
Certificate = GetCertificate(CertificateInfo);
|
|
|
|
|
|
- HttpServer = new HttpListenerHost(this,
|
|
|
+ HttpServer = new HttpListenerHost(
|
|
|
+ this,
|
|
|
LoggerFactory,
|
|
|
ServerConfigurationManager,
|
|
|
_configuration,
|
|
|
NetworkManager,
|
|
|
JsonSerializer,
|
|
|
XmlSerializer,
|
|
|
- CreateHttpListener());
|
|
|
+ CreateHttpListener())
|
|
|
+ {
|
|
|
+ GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading")
|
|
|
+ };
|
|
|
|
|
|
- HttpServer.GlobalResponse = LocalizationManager.GetLocalizedString("StartupEmbyServerIsLoading");
|
|
|
serviceCollection.AddSingleton(HttpServer);
|
|
|
|
|
|
ImageProcessor = GetImageProcessor();
|
|
@@ -862,7 +865,6 @@ namespace Emby.Server.Implementations
|
|
|
LoggerFactory,
|
|
|
JsonSerializer,
|
|
|
StartupOptions.FFmpegPath,
|
|
|
- StartupOptions.FFprobePath,
|
|
|
ServerConfigurationManager,
|
|
|
FileSystemManager,
|
|
|
() => SubtitleEncoder,
|
|
@@ -907,7 +909,7 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
public virtual string PackageRuntime => "netcore";
|
|
|
|
|
|
- public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths, EnvironmentInfo.EnvironmentInfo environmentInfo)
|
|
|
+ public static void LogEnvironmentInfo(ILogger logger, IApplicationPaths appPaths)
|
|
|
{
|
|
|
// Distinct these to prevent users from reporting problems that aren't actually problems
|
|
|
var commandLineArgs = Environment
|
|
@@ -915,12 +917,14 @@ namespace Emby.Server.Implementations
|
|
|
.Distinct();
|
|
|
|
|
|
logger.LogInformation("Arguments: {Args}", commandLineArgs);
|
|
|
- logger.LogInformation("Operating system: {OS} {OSVersion}", environmentInfo.OperatingSystemName, environmentInfo.OperatingSystemVersion);
|
|
|
- logger.LogInformation("Architecture: {Architecture}", environmentInfo.SystemArchitecture);
|
|
|
+ // FIXME: @bond this logs the kernel version, not the OS version
|
|
|
+ logger.LogInformation("Operating system: {OS} {OSVersion}", OperatingSystem.Name, Environment.OSVersion.Version);
|
|
|
+ logger.LogInformation("Architecture: {Architecture}", RuntimeInformation.OSArchitecture);
|
|
|
logger.LogInformation("64-Bit Process: {Is64Bit}", Environment.Is64BitProcess);
|
|
|
logger.LogInformation("User Interactive: {IsUserInteractive}", Environment.UserInteractive);
|
|
|
logger.LogInformation("Processor count: {ProcessorCount}", Environment.ProcessorCount);
|
|
|
logger.LogInformation("Program data path: {ProgramDataPath}", appPaths.ProgramDataPath);
|
|
|
+ logger.LogInformation("Web resources path: {WebPath}", appPaths.WebPath);
|
|
|
logger.LogInformation("Application directory: {ApplicationPath}", appPaths.ProgramSystemPath);
|
|
|
}
|
|
|
|
|
@@ -957,7 +961,7 @@ namespace Emby.Server.Implementations
|
|
|
var password = string.IsNullOrWhiteSpace(info.Password) ? null : info.Password;
|
|
|
|
|
|
var localCert = new X509Certificate2(certificateLocation, password);
|
|
|
- //localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
|
|
|
+ // localCert.PrivateKey = PrivateKey.CreateFromFile(pvk_file).RSA;
|
|
|
if (!localCert.HasPrivateKey)
|
|
|
{
|
|
|
Logger.LogError("No private key included in SSL cert {CertificateLocation}.", certificateLocation);
|
|
@@ -1058,13 +1062,15 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
HttpServer.Init(GetExports<IService>(false), GetExports<IWebSocketListener>(), GetUrlPrefixes());
|
|
|
|
|
|
- LibraryManager.AddParts(GetExports<IResolverIgnoreRule>(),
|
|
|
+ LibraryManager.AddParts(
|
|
|
+ GetExports<IResolverIgnoreRule>(),
|
|
|
GetExports<IItemResolver>(),
|
|
|
GetExports<IIntroProvider>(),
|
|
|
GetExports<IBaseItemComparer>(),
|
|
|
GetExports<ILibraryPostScanTask>());
|
|
|
|
|
|
- ProviderManager.AddParts(GetExports<IImageProvider>(),
|
|
|
+ ProviderManager.AddParts(
|
|
|
+ GetExports<IImageProvider>(),
|
|
|
GetExports<IMetadataService>(),
|
|
|
GetExports<IMetadataProvider>(),
|
|
|
GetExports<IMetadataSaver>(),
|
|
@@ -1145,6 +1151,7 @@ namespace Emby.Server.Implementations
|
|
|
}
|
|
|
|
|
|
private CertificateInfo CertificateInfo { get; set; }
|
|
|
+
|
|
|
protected X509Certificate2 Certificate { get; private set; }
|
|
|
|
|
|
private IEnumerable<string> GetUrlPrefixes()
|
|
@@ -1155,7 +1162,7 @@ namespace Emby.Server.Implementations
|
|
|
{
|
|
|
var prefixes = new List<string>
|
|
|
{
|
|
|
- "http://"+i+":" + HttpPort + "/"
|
|
|
+ "http://" + i + ":" + HttpPort + "/"
|
|
|
};
|
|
|
|
|
|
if (CertificateInfo != null)
|
|
@@ -1184,30 +1191,12 @@ namespace Emby.Server.Implementations
|
|
|
// Generate self-signed cert
|
|
|
var certHost = GetHostnameFromExternalDns(ServerConfigurationManager.Configuration.WanDdns);
|
|
|
var certPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.ProgramDataPath, "ssl", "cert_" + (certHost + "2").GetMD5().ToString("N") + ".pfx");
|
|
|
- var password = "embycert";
|
|
|
-
|
|
|
- //if (generateCertificate)
|
|
|
- //{
|
|
|
- // if (!File.Exists(certPath))
|
|
|
- // {
|
|
|
- // FileSystemManager.CreateDirectory(FileSystemManager.GetDirectoryName(certPath));
|
|
|
-
|
|
|
- // try
|
|
|
- // {
|
|
|
- // CertificateGenerator.CreateSelfSignCertificatePfx(certPath, certHost, password, Logger);
|
|
|
- // }
|
|
|
- // catch (Exception ex)
|
|
|
- // {
|
|
|
- // Logger.LogError(ex, "Error creating ssl cert");
|
|
|
- // return null;
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
+ const string Password = "embycert";
|
|
|
|
|
|
return new CertificateInfo
|
|
|
{
|
|
|
Path = certPath,
|
|
|
- Password = password
|
|
|
+ Password = Password
|
|
|
};
|
|
|
}
|
|
|
|
|
@@ -1242,9 +1231,9 @@ namespace Emby.Server.Implementations
|
|
|
requiresRestart = true;
|
|
|
}
|
|
|
|
|
|
- var currentCertPath = CertificateInfo == null ? null : CertificateInfo.Path;
|
|
|
+ var currentCertPath = CertificateInfo?.Path;
|
|
|
var newCertInfo = GetCertificateInfo(false);
|
|
|
- var newCertPath = newCertInfo == null ? null : newCertInfo.Path;
|
|
|
+ var newCertPath = newCertInfo?.Path;
|
|
|
|
|
|
if (!string.Equals(currentCertPath, newCertPath, StringComparison.OrdinalIgnoreCase))
|
|
|
{
|
|
@@ -1377,6 +1366,7 @@ namespace Emby.Server.Implementations
|
|
|
/// <summary>
|
|
|
/// Gets the system status.
|
|
|
/// </summary>
|
|
|
+ /// <param name="cancellationToken">The cancellation token</param>
|
|
|
/// <returns>SystemInfo.</returns>
|
|
|
public async Task<SystemInfo> GetSystemInfo(CancellationToken cancellationToken)
|
|
|
{
|
|
@@ -1393,6 +1383,7 @@ namespace Emby.Server.Implementations
|
|
|
CompletedInstallations = InstallationManager.CompletedInstallations.ToArray(),
|
|
|
Id = SystemId,
|
|
|
ProgramDataPath = ApplicationPaths.ProgramDataPath,
|
|
|
+ WebPath = ApplicationPaths.WebPath,
|
|
|
LogPath = ApplicationPaths.LogDirectoryPath,
|
|
|
ItemsByNamePath = ApplicationPaths.InternalMetadataPath,
|
|
|
InternalMetadataPath = ApplicationPaths.InternalMetadataPath,
|
|
@@ -1400,8 +1391,8 @@ namespace Emby.Server.Implementations
|
|
|
HttpServerPortNumber = HttpPort,
|
|
|
SupportsHttps = SupportsHttps,
|
|
|
HttpsPortNumber = HttpsPort,
|
|
|
- OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(),
|
|
|
- OperatingSystemDisplayName = EnvironmentInfo.OperatingSystemName,
|
|
|
+ OperatingSystem = OperatingSystem.Id.ToString(),
|
|
|
+ OperatingSystemDisplayName = OperatingSystem.Name,
|
|
|
CanSelfRestart = CanSelfRestart,
|
|
|
CanLaunchWebBrowser = CanLaunchWebBrowser,
|
|
|
WanAddress = wanAddress,
|
|
@@ -1411,7 +1402,7 @@ namespace Emby.Server.Implementations
|
|
|
LocalAddress = localAddress,
|
|
|
SupportsLibraryMonitor = true,
|
|
|
EncoderLocation = MediaEncoder.EncoderLocation,
|
|
|
- SystemArchitecture = EnvironmentInfo.SystemArchitecture,
|
|
|
+ SystemArchitecture = RuntimeInformation.OSArchitecture,
|
|
|
SystemUpdateLevel = SystemUpdateLevel,
|
|
|
PackageName = StartupOptions.PackageName
|
|
|
};
|
|
@@ -1435,7 +1426,7 @@ namespace Emby.Server.Implementations
|
|
|
{
|
|
|
Version = ApplicationVersion,
|
|
|
Id = SystemId,
|
|
|
- OperatingSystem = EnvironmentInfo.OperatingSystem.ToString(),
|
|
|
+ OperatingSystem = OperatingSystem.Id.ToString(),
|
|
|
WanAddress = wanAddress,
|
|
|
ServerName = FriendlyName,
|
|
|
LocalAddress = localAddress
|
|
@@ -1470,19 +1461,19 @@ namespace Emby.Server.Implementations
|
|
|
|
|
|
public async Task<string> GetWanApiUrl(CancellationToken cancellationToken)
|
|
|
{
|
|
|
- const string url = "http://ipv4.icanhazip.com";
|
|
|
+ const string Url = "http://ipv4.icanhazip.com";
|
|
|
try
|
|
|
{
|
|
|
using (var response = await HttpClient.Get(new HttpRequestOptions
|
|
|
{
|
|
|
- Url = url,
|
|
|
+ Url = Url,
|
|
|
LogErrorResponseBody = false,
|
|
|
LogErrors = false,
|
|
|
LogRequest = false,
|
|
|
TimeoutMs = 10000,
|
|
|
BufferContent = false,
|
|
|
CancellationToken = cancellationToken
|
|
|
- }))
|
|
|
+ }).ConfigureAwait(false))
|
|
|
{
|
|
|
return GetLocalApiUrl(response.ReadToEnd().Trim());
|
|
|
}
|
|
@@ -1570,10 +1561,12 @@ namespace Emby.Server.Implementations
|
|
|
{
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private readonly ConcurrentDictionary<string, bool> _validAddressResults = new ConcurrentDictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
|
|
|
+
|
|
|
private async Task<bool> IsIpAddressValidAsync(IpAddressInfo address, CancellationToken cancellationToken)
|
|
|
{
|
|
|
if (address.Equals(IpAddressInfo.Loopback) ||
|
|
@@ -1590,26 +1583,26 @@ namespace Emby.Server.Implementations
|
|
|
return cachedResult;
|
|
|
}
|
|
|
|
|
|
- var logPing = false;
|
|
|
-
|
|
|
#if DEBUG
|
|
|
- logPing = true;
|
|
|
+ const bool LogPing = true;
|
|
|
+#else
|
|
|
+ const bool LogPing = false;
|
|
|
#endif
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- using (var response = await HttpClient.SendAsync(new HttpRequestOptions
|
|
|
- {
|
|
|
- Url = apiUrl,
|
|
|
- LogErrorResponseBody = false,
|
|
|
- LogErrors = logPing,
|
|
|
- LogRequest = logPing,
|
|
|
- TimeoutMs = 5000,
|
|
|
- BufferContent = false,
|
|
|
-
|
|
|
- CancellationToken = cancellationToken
|
|
|
-
|
|
|
- }, "POST").ConfigureAwait(false))
|
|
|
+ using (var response = await HttpClient.SendAsync(
|
|
|
+ new HttpRequestOptions
|
|
|
+ {
|
|
|
+ Url = apiUrl,
|
|
|
+ LogErrorResponseBody = false,
|
|
|
+ LogErrors = LogPing,
|
|
|
+ LogRequest = LogPing,
|
|
|
+ TimeoutMs = 5000,
|
|
|
+ BufferContent = false,
|
|
|
+
|
|
|
+ CancellationToken = cancellationToken
|
|
|
+ }, "POST").ConfigureAwait(false))
|
|
|
{
|
|
|
using (var reader = new StreamReader(response.Content))
|
|
|
{
|
|
@@ -1674,6 +1667,7 @@ namespace Emby.Server.Implementations
|
|
|
public event EventHandler HasUpdateAvailableChanged;
|
|
|
|
|
|
private bool _hasUpdateAvailable;
|
|
|
+
|
|
|
public bool HasUpdateAvailable
|
|
|
{
|
|
|
get => _hasUpdateAvailable;
|
|
@@ -1734,7 +1728,7 @@ namespace Emby.Server.Implementations
|
|
|
var process = ProcessFactory.Create(new ProcessOptions
|
|
|
{
|
|
|
FileName = url,
|
|
|
- //EnableRaisingEvents = true,
|
|
|
+ EnableRaisingEvents = true,
|
|
|
UseShellExecute = true,
|
|
|
ErrorDialog = false
|
|
|
});
|
|
@@ -1769,26 +1763,25 @@ namespace Emby.Server.Implementations
|
|
|
{
|
|
|
Logger.LogInformation("Application has been updated to version {0}", package.versionStr);
|
|
|
|
|
|
- ApplicationUpdated?.Invoke(this, new GenericEventArgs<PackageVersionInfo>
|
|
|
- {
|
|
|
- Argument = package
|
|
|
- });
|
|
|
+ ApplicationUpdated?.Invoke(
|
|
|
+ this,
|
|
|
+ new GenericEventArgs<PackageVersionInfo>()
|
|
|
+ {
|
|
|
+ Argument = package
|
|
|
+ });
|
|
|
|
|
|
NotifyPendingRestart();
|
|
|
}
|
|
|
|
|
|
- private bool _disposed;
|
|
|
+ private bool _disposed = false;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
|
/// </summary>
|
|
|
public void Dispose()
|
|
|
{
|
|
|
- if (!_disposed)
|
|
|
- {
|
|
|
- _disposed = true;
|
|
|
-
|
|
|
- Dispose(true);
|
|
|
- }
|
|
|
+ Dispose(true);
|
|
|
+ GC.SuppressFinalize(this);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -1797,14 +1790,19 @@ namespace Emby.Server.Implementations
|
|
|
/// <param name="dispose"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
|
|
|
protected virtual void Dispose(bool dispose)
|
|
|
{
|
|
|
+ if (_disposed)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (dispose)
|
|
|
{
|
|
|
var type = GetType();
|
|
|
|
|
|
Logger.LogInformation("Disposing {Type}", type.Name);
|
|
|
|
|
|
- var parts = DisposableParts.Distinct().Where(i => i.GetType() != type).ToList();
|
|
|
- DisposableParts.Clear();
|
|
|
+ var parts = _disposableParts.Distinct().Where(i => i.GetType() != type).ToList();
|
|
|
+ _disposableParts.Clear();
|
|
|
|
|
|
foreach (var part in parts)
|
|
|
{
|
|
@@ -1820,6 +1818,8 @@ namespace Emby.Server.Implementations
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ _disposed = true;
|
|
|
}
|
|
|
}
|
|
|
|