From 1fb939b9b28ea67da6eefc88faecb4ecae8b02f7 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 21 Mar 2020 20:21:07 +0100 Subject: [PATCH 01/10] Enable HTTP/2 support --- Jellyfin.Server/Program.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Jellyfin.Server/Program.cs b/Jellyfin.Server/Program.cs index e9e852349c..95c4a48aba 100644 --- a/Jellyfin.Server/Program.cs +++ b/Jellyfin.Server/Program.cs @@ -20,6 +20,7 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Drawing; using MediaBrowser.Model.Globalization; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -253,10 +254,11 @@ namespace Jellyfin.Server if (appHost.EnableHttps && appHost.Certificate != null) { - options.Listen( - address, - appHost.HttpsPort, - listenOptions => listenOptions.UseHttps(appHost.Certificate)); + options.Listen(address, appHost.HttpsPort, listenOptions => + { + listenOptions.UseHttps(appHost.Certificate); + listenOptions.Protocols = HttpProtocols.Http1AndHttp2; + }); } } } @@ -267,9 +269,11 @@ namespace Jellyfin.Server if (appHost.EnableHttps && appHost.Certificate != null) { - options.ListenAnyIP( - appHost.HttpsPort, - listenOptions => listenOptions.UseHttps(appHost.Certificate)); + options.ListenAnyIP(appHost.HttpsPort, listenOptions => + { + listenOptions.UseHttps(appHost.Certificate); + listenOptions.Protocols = HttpProtocols.Http1AndHttp2; + }); } } }) From dc140429fe5d6718d516a02ee3951e191f9db621 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 21 Mar 2020 23:17:30 +0100 Subject: [PATCH 02/10] Do not create unnecessary instances of IService at server startup --- Emby.Server.Implementations/ApplicationHost.cs | 2 +- .../HttpServer/HttpListenerHost.cs | 11 +++++------ MediaBrowser.Controller/Net/IHttpServer.cs | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index aa22ac8b9f..3c9bd207bb 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1046,7 +1046,7 @@ namespace Emby.Server.Implementations .Where(i => i != null) .ToArray(); - HttpServer.Init(GetExports(false), GetExports(), GetUrlPrefixes()); + HttpServer.Init(GetExportTypes(), GetExports(), GetUrlPrefixes()); LibraryManager.AddParts( GetExports(), diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index 655130fcfc..a3b61b98bc 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -594,17 +594,16 @@ namespace Emby.Server.Implementations.HttpServer /// /// Adds the rest handlers. /// - /// The services. - /// - /// - public void Init(IEnumerable services, IEnumerable listeners, IEnumerable urlPrefixes) + /// The service types to register with the . + /// The web socket listeners. + /// The URL prefixes. See . + public void Init(IEnumerable serviceTypes, IEnumerable listeners, IEnumerable urlPrefixes) { _webSocketListeners = listeners.ToArray(); UrlPrefixes = urlPrefixes.ToArray(); ServiceController = new ServiceController(); - var types = services.Select(r => r.GetType()); - ServiceController.Init(this, types); + ServiceController.Init(this, serviceTypes); ResponseFilters = new Action[] { diff --git a/MediaBrowser.Controller/Net/IHttpServer.cs b/MediaBrowser.Controller/Net/IHttpServer.cs index 46933c0465..806478864d 100644 --- a/MediaBrowser.Controller/Net/IHttpServer.cs +++ b/MediaBrowser.Controller/Net/IHttpServer.cs @@ -32,7 +32,7 @@ namespace MediaBrowser.Controller.Net /// /// Inits this instance. /// - void Init(IEnumerable services, IEnumerable listener, IEnumerable urlPrefixes); + void Init(IEnumerable serviceTypes, IEnumerable listener, IEnumerable urlPrefixes); /// /// If set, all requests will respond with this message From 72c822513f746fd30575a6dc2b076d647ffec4f3 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 21 Mar 2020 23:18:41 +0100 Subject: [PATCH 03/10] Create ServiceController via DI instead of manual construction --- .../HttpServer/HttpListenerHost.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs index a3b61b98bc..7a812f3201 100644 --- a/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/Emby.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -60,7 +60,8 @@ namespace Emby.Server.Implementations.HttpServer IJsonSerializer jsonSerializer, IXmlSerializer xmlSerializer, IHttpListener socketListener, - ILocalizationManager localizationManager) + ILocalizationManager localizationManager, + ServiceController serviceController) { _appHost = applicationHost; _logger = logger; @@ -71,6 +72,8 @@ namespace Emby.Server.Implementations.HttpServer _jsonSerializer = jsonSerializer; _xmlSerializer = xmlSerializer; _socketListener = socketListener; + ServiceController = serviceController; + _socketListener.WebSocketConnected = OnWebSocketConnected; _funcParseFn = t => s => JsvReader.GetParseFn(t)(s); @@ -90,7 +93,7 @@ namespace Emby.Server.Implementations.HttpServer public string GlobalResponse { get; set; } - public ServiceController ServiceController { get; private set; } + public ServiceController ServiceController { get; } public object CreateInstance(Type type) { @@ -601,7 +604,6 @@ namespace Emby.Server.Implementations.HttpServer { _webSocketListeners = listeners.ToArray(); UrlPrefixes = urlPrefixes.ToArray(); - ServiceController = new ServiceController(); ServiceController.Init(this, serviceTypes); From dc2b8c464672d7bb69a32cf6f95555872f1f7ddf Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 21 Mar 2020 23:19:24 +0100 Subject: [PATCH 04/10] Log a warning if an attempt is made to register an invalid service type --- .../Services/ServiceController.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index d963f9043c..3f9c8778b5 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Emby.Server.Implementations.HttpServer; using MediaBrowser.Model.Services; +using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Services { @@ -11,6 +12,13 @@ namespace Emby.Server.Implementations.Services public class ServiceController { + private readonly ILogger _log; + + public ServiceController(ILogger log) + { + _log = log; + } + public void Init(HttpListenerHost appHost, IEnumerable serviceTypes) { foreach (var serviceType in serviceTypes) @@ -21,6 +29,13 @@ namespace Emby.Server.Implementations.Services public void RegisterService(HttpListenerHost appHost, Type serviceType) { + // Make sure the provided type implements IService + if (!serviceType.IsAssignableFrom(typeof(IService))) + { + _log.LogWarning("Tried to register a service that does not implement IService: {ServiceType}", serviceType); + return; + } + var processedReqs = new HashSet(); var actions = ServiceExecGeneral.Reset(serviceType); From 6f8c81ff7e8aba4eaa14b715cc180b824c735905 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 21 Mar 2020 23:28:07 +0100 Subject: [PATCH 05/10] Register ServiceController with the DI framework --- Emby.Server.Implementations/ApplicationHost.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 3c9bd207bb..dcd54e651a 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -43,6 +43,7 @@ using Emby.Server.Implementations.Playlists; using Emby.Server.Implementations.ScheduledTasks; using Emby.Server.Implementations.Security; using Emby.Server.Implementations.Serialization; +using Emby.Server.Implementations.Services; using Emby.Server.Implementations.Session; using Emby.Server.Implementations.SocketSharp; using Emby.Server.Implementations.TV; @@ -758,6 +759,7 @@ namespace Emby.Server.Implementations CertificateInfo = GetCertificateInfo(true); Certificate = GetCertificate(CertificateInfo); + serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); From b8580e58aadbbef6f99dfc15ab0fcc38f5210dd8 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Sat, 21 Mar 2020 23:28:27 +0100 Subject: [PATCH 06/10] Check for implementation of IService correctly --- Emby.Server.Implementations/Services/ServiceController.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index 3f9c8778b5..d546317a95 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -8,12 +8,17 @@ using Microsoft.Extensions.Logging; namespace Emby.Server.Implementations.Services { public delegate object ActionInvokerFn(object intance, object request); + public delegate void VoidActionInvokerFn(object intance, object request); public class ServiceController { private readonly ILogger _log; + /// + /// Initializes a new instance of the class. + /// + /// The logger. public ServiceController(ILogger log) { _log = log; @@ -30,7 +35,7 @@ namespace Emby.Server.Implementations.Services public void RegisterService(HttpListenerHost appHost, Type serviceType) { // Make sure the provided type implements IService - if (!serviceType.IsAssignableFrom(typeof(IService))) + if (!typeof(IService).IsAssignableFrom(serviceType)) { _log.LogWarning("Tried to register a service that does not implement IService: {ServiceType}", serviceType); return; From 4419587c2a08bca526b8a9fff7e8feb21084cde8 Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 1 Apr 2020 15:30:53 +0200 Subject: [PATCH 07/10] Minor improvements --- Jellyfin.Drawing.Skia/SkiaEncoder.cs | 3 +-- MediaBrowser.Common/Net/HttpResponseInfo.cs | 1 - MediaBrowser.Common/System/OperatingSystem.cs | 10 +++++----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/Jellyfin.Drawing.Skia/SkiaEncoder.cs index 2ea690650b..a67118f188 100644 --- a/Jellyfin.Drawing.Skia/SkiaEncoder.cs +++ b/Jellyfin.Drawing.Skia/SkiaEncoder.cs @@ -308,8 +308,7 @@ namespace Jellyfin.Drawing.Skia if (requiresTransparencyHack || forceCleanBitmap) { - using (var stream = new SKFileStream(NormalizePath(path))) - using (var codec = SKCodec.Create(stream)) + using (var codec = SKCodec.Create(NormalizePath(path))) { if (codec == null) { diff --git a/MediaBrowser.Common/Net/HttpResponseInfo.cs b/MediaBrowser.Common/Net/HttpResponseInfo.cs index d7f7a56229..56a951ebf1 100644 --- a/MediaBrowser.Common/Net/HttpResponseInfo.cs +++ b/MediaBrowser.Common/Net/HttpResponseInfo.cs @@ -22,7 +22,6 @@ namespace MediaBrowser.Common.Net } #pragma warning restore CS1591 -#pragma warning restore SA1600 /// /// Gets or sets the type of the content. diff --git a/MediaBrowser.Common/System/OperatingSystem.cs b/MediaBrowser.Common/System/OperatingSystem.cs index 7d38ddb6e5..5f673d3208 100644 --- a/MediaBrowser.Common/System/OperatingSystem.cs +++ b/MediaBrowser.Common/System/OperatingSystem.cs @@ -35,7 +35,7 @@ namespace MediaBrowser.Common.System case OperatingSystemId.Linux: return "Linux"; case OperatingSystemId.Darwin: return "macOS"; case OperatingSystemId.Windows: return "Windows"; - default: throw new Exception($"Unknown OS {Id}"); + default: throw new PlatformNotSupportedException($"Unknown OS {Id}"); } } } @@ -53,20 +53,20 @@ namespace MediaBrowser.Common.System default: { string osDescription = RuntimeInformation.OSDescription; - if (osDescription.IndexOf("linux", StringComparison.OrdinalIgnoreCase) != -1) + if (osDescription.Contains("linux", StringComparison.OrdinalIgnoreCase)) { return OperatingSystemId.Linux; } - else if (osDescription.IndexOf("darwin", StringComparison.OrdinalIgnoreCase) != -1) + else if (osDescription.Contains("darwin", StringComparison.OrdinalIgnoreCase)) { return OperatingSystemId.Darwin; } - else if (osDescription.IndexOf("bsd", StringComparison.OrdinalIgnoreCase) != -1) + else if (osDescription.Contains("bsd", StringComparison.OrdinalIgnoreCase)) { return OperatingSystemId.BSD; } - throw new Exception($"Can't resolve OS with description: '{osDescription}'"); + throw new PlatformNotSupportedException($"Can't resolve OS with description: '{osDescription}'"); } } } From bece62fd5c9a2dfe9edbe4fcf944c16b87569f92 Mon Sep 17 00:00:00 2001 From: Vasily Date: Thu, 2 Apr 2020 13:40:48 +0300 Subject: [PATCH 08/10] Fix GetLocalApiUrl for cases with https enabled This should fix LiveTV and tuners --- Emby.Server.Implementations/ApplicationHost.cs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Emby.Server.Implementations/ApplicationHost.cs b/Emby.Server.Implementations/ApplicationHost.cs index 4fbc933a81..7055e21640 100644 --- a/Emby.Server.Implementations/ApplicationHost.cs +++ b/Emby.Server.Implementations/ApplicationHost.cs @@ -1507,18 +1507,10 @@ namespace Emby.Server.Implementations public string GetLocalApiUrl(ReadOnlySpan host) { var url = new StringBuilder(64); - if (EnableHttps) - { - url.Append("https://"); - } - else - { - url.Append("http://"); - } - - url.Append(host) + url.Append(EnableHttps ? "https://" : "http://") + .Append(host) .Append(':') - .Append(HttpPort); + .Append(EnableHttps ? HttpsPort : HttpPort); string baseUrl = ServerConfigurationManager.Configuration.BaseUrl; if (baseUrl.Length != 0) From 2a521b0f68315a765ee1a970fabdd712739c4f31 Mon Sep 17 00:00:00 2001 From: Mark Monteiro Date: Thu, 2 Apr 2020 09:32:43 -0400 Subject: [PATCH 09/10] Rename 'log' to 'logger' --- .../Services/ServiceController.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Emby.Server.Implementations/Services/ServiceController.cs b/Emby.Server.Implementations/Services/ServiceController.cs index d546317a95..e24a95dbb3 100644 --- a/Emby.Server.Implementations/Services/ServiceController.cs +++ b/Emby.Server.Implementations/Services/ServiceController.cs @@ -13,15 +13,15 @@ namespace Emby.Server.Implementations.Services public class ServiceController { - private readonly ILogger _log; + private readonly ILogger _logger; /// /// Initializes a new instance of the class. /// - /// The logger. - public ServiceController(ILogger log) + /// The logger. + public ServiceController(ILogger logger) { - _log = log; + _logger = logger; } public void Init(HttpListenerHost appHost, IEnumerable serviceTypes) @@ -37,7 +37,7 @@ namespace Emby.Server.Implementations.Services // Make sure the provided type implements IService if (!typeof(IService).IsAssignableFrom(serviceType)) { - _log.LogWarning("Tried to register a service that does not implement IService: {ServiceType}", serviceType); + _logger.LogWarning("Tried to register a service that does not implement IService: {ServiceType}", serviceType); return; } From b07b499466ec5e0fe7476a0c7be5b95ba5e7ade7 Mon Sep 17 00:00:00 2001 From: DJSweder Date: Thu, 2 Apr 2020 15:32:03 +0000 Subject: [PATCH 10/10] Translated using Weblate (Czech) Translation: Jellyfin/Jellyfin Translate-URL: https://translate.jellyfin.org/projects/jellyfin/jellyfin-core/cs/ --- .../Localization/Core/cs.json | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Emby.Server.Implementations/Localization/Core/cs.json b/Emby.Server.Implementations/Localization/Core/cs.json index f3136c0322..992bb9df37 100644 --- a/Emby.Server.Implementations/Localization/Core/cs.json +++ b/Emby.Server.Implementations/Localization/Core/cs.json @@ -5,7 +5,7 @@ "Artists": "Umělci", "AuthenticationSucceededWithUserName": "{0} úspěšně ověřen", "Books": "Knihy", - "CameraImageUploadedFrom": "Z {0} byla nahrána nová fotografie", + "CameraImageUploadedFrom": "Z {0} byla nahrána nová fotografie z fotoaparátu", "Channels": "Kanály", "ChapterNameValue": "Kapitola {0}", "Collections": "Kolekce", @@ -92,5 +92,27 @@ "UserStoppedPlayingItemWithValues": "{0} zastavil přehrávání {1}", "ValueHasBeenAddedToLibrary": "{0} byl přidán do vaší knihovny médií", "ValueSpecialEpisodeName": "Speciál - {0}", - "VersionNumber": "Verze {0}" + "VersionNumber": "Verze {0}", + "TaskDownloadMissingSubtitlesDescription": "Vyhledá na internetu chybějící titulky na základě nastavení metadat.", + "TaskDownloadMissingSubtitles": "Stáhnout chybějící titulky", + "TaskRefreshChannelsDescription": "Obnoví informace o internetových kanálech.", + "TaskRefreshChannels": "Obnovit kanály", + "TaskCleanTranscodeDescription": "Odstraní více než 1 den staré transkódované soubory.", + "TaskCleanTranscode": "Vyčistit adresář s transkódovaným obsahem", + "TaskUpdatePluginsDescription": "Stáhne a nainstaluje aktualizace zásuvných modulů, které mají nastavenou automatickou aktualizaci.", + "TaskUpdatePlugins": "Aktualizovat zásuvné moduly", + "TaskRefreshPeopleDescription": "Aktualizuje metadata umělců a režisérů ve Vaší knihovně médií.", + "TaskRefreshPeople": "Obnovit umělce", + "TaskCleanLogsDescription": "Odstraní soubory protokolu, které jsou starší více než {0} dní.", + "TaskCleanLogs": "Vyčistit adresář se souborem protokolu", + "TaskRefreshLibraryDescription": "Prohledá Vaši knihovnu médií zda neobsahuje nové soubory a obnoví metadatada.", + "TaskRefreshLibrary": "Prohledat knihovnu médií", + "TaskRefreshChapterImagesDescription": "Vytvoří náhledy videí, které obsahují kapitoly.", + "TaskRefreshChapterImages": "Extrahovat obrázky kapitol", + "TaskCleanCacheDescription": "Odstraní soubory mezipaměti, které systém již nebude potřebovat.", + "TaskCleanCache": "Vyčistit složku s mezipamětí", + "TasksChannelsCategory": "Internetové kanály", + "TasksApplicationCategory": "Aplikace", + "TasksLibraryCategory": "Knihovna", + "TasksMaintenanceCategory": "Údržba" }