From d825e0bc1aefce8816d103385f14e0122aff6d98 Mon Sep 17 00:00:00 2001 From: "hexx.one" <5312542+hexxone@users.noreply.github.com> Date: Sat, 5 Oct 2024 17:45:23 +0200 Subject: [PATCH] fix: target abi version 10.9 #2 --- HttpsReverseProxy/HttpsReverseProxy.csproj | 2 +- HttpsReverseProxy/Program.cs | 6 ++- .../Properties/launchSettings.json | 7 --- .../JellyfinPluginHelper.csproj | 2 +- JellyfinPluginHelper/Program.cs | 7 +-- README.md | 40 +++++++++++++---- TeleJelly/Assets/Config/config.html | 2 +- TeleJelly/Classes/ControllerExtensions.cs | 45 +++++++++---------- TeleJelly/Controller/TelegramController.cs | 2 +- TeleJelly/TeleJelly.csproj | 21 +++++---- TeleJelly/TeleJellyPlugin.cs | 20 +++++++-- TeleJelly/Telegram/TelegramHelper.cs | 8 ++-- meta.json | 12 ++--- 13 files changed, 104 insertions(+), 70 deletions(-) diff --git a/HttpsReverseProxy/HttpsReverseProxy.csproj b/HttpsReverseProxy/HttpsReverseProxy.csproj index 38036e6..2f2a057 100644 --- a/HttpsReverseProxy/HttpsReverseProxy.csproj +++ b/HttpsReverseProxy/HttpsReverseProxy.csproj @@ -7,7 +7,7 @@ - + diff --git a/HttpsReverseProxy/Program.cs b/HttpsReverseProxy/Program.cs index e8ccb72..62ce04b 100644 --- a/HttpsReverseProxy/Program.cs +++ b/HttpsReverseProxy/Program.cs @@ -7,7 +7,11 @@ public static void Main(string[] args) var builder = WebApplication.CreateBuilder(args); builder.Services.AddReverseProxy() - .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")); + .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")) + .ConfigureHttpClient((context, handler) => + { + handler.AllowAutoRedirect = true; + }); var app = builder.Build(); diff --git a/HttpsReverseProxy/Properties/launchSettings.json b/HttpsReverseProxy/Properties/launchSettings.json index 75010fd..a132c1a 100644 --- a/HttpsReverseProxy/Properties/launchSettings.json +++ b/HttpsReverseProxy/Properties/launchSettings.json @@ -16,13 +16,6 @@ "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } } } } diff --git a/JellyfinPluginHelper/JellyfinPluginHelper.csproj b/JellyfinPluginHelper/JellyfinPluginHelper.csproj index 21a3639..f179cd5 100644 --- a/JellyfinPluginHelper/JellyfinPluginHelper.csproj +++ b/JellyfinPluginHelper/JellyfinPluginHelper.csproj @@ -8,7 +8,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/JellyfinPluginHelper/Program.cs b/JellyfinPluginHelper/Program.cs index fb29614..08563b0 100644 --- a/JellyfinPluginHelper/Program.cs +++ b/JellyfinPluginHelper/Program.cs @@ -38,7 +38,7 @@ const string GitManifestBranch = "dist"; const string GitManifestPath = "manifest.json"; -const string TargetAbi = "10.8.0.0"; +const string TargetAbi = "10.9.0.0"; const string ChangeMessage = "Automatic Release by Github Actions: "; if (args.Length != 3) @@ -145,7 +145,7 @@ static void UpdateMeta(string metaPath, string version, string timestamp) Console.WriteLine("JPH - Updating meta.json."); // Read the existing meta.json - string metaJson = File.ReadAllText(metaPath); + var metaJson = File.ReadAllText(metaPath); var meta = JsonSerializer.Deserialize>(metaJson); if (meta == null) @@ -155,12 +155,13 @@ static void UpdateMeta(string metaPath, string version, string timestamp) } // Update the fields + meta["targetAbi"] = TargetAbi; meta["timestamp"] = timestamp; meta["version"] = FixVersionString(version); meta["changelog"] = $"{ChangeMessage} https://github.com/{GitUser}/{GitProject}/releases/tag/{version}"; // Serialize and write back to meta.json - string updatedMetaJson = JsonSerializer.Serialize(meta, new JsonSerializerOptions { WriteIndented = true }); + var updatedMetaJson = JsonSerializer.Serialize(meta, new JsonSerializerOptions { WriteIndented = true }); File.WriteAllText(metaPath, updatedMetaJson); Console.WriteLine("JPH - Successfully updated meta.json."); diff --git a/README.md b/README.md index 70cbc48..bf7c0c1 100644 --- a/README.md +++ b/README.md @@ -136,21 +136,43 @@ _Note: Video & Screenshots are taken with [my custom css theme](https://gist.git ![Config Page 1](./screenshots/02.png) -## Development - -1. Clone Repo -2. Make sure to install "[JellyFin Server](https://repo.jellyfin.org/releases/server/windows/stable/)" for debugging on Windows. Keep the default path. -3. Open Solution file, restore packages -4. Build the Plugin in Release mode -5. Select to run "HttpsReverseProxy" AND "jellyfin" (server) at the same time. -6. The plugin gets copied to the server and the browser opens automatically. - ## Dependencies - [Telegram.Bot](https://github.com/TelegramBots/telegram.bot) library for validating bot token & determining bot username - [ILRepack](https://github.com/gluck/il-repack) for packing all dependency dlls into one single plugin dll - [MinVer](https://github.com/adamralph/minver) for automated Release-versioning via git tags +## Development / Contributing + +### Tools + +- [git](https://git-scm.com/downloads) +- [Visual Studio](https://visualstudio.microsoft.com/de/downloads/) or Rider IDE +- [.NET6](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) for Jellyfin <= 10.8 +- [.NET8](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) for Jellyfin >= 10.9 +- [JellyFin Server](https://repo.jellyfin.org/?path=/server/windows) for debugging on Windows. Keep the default path. + +### Getting Started + +1. Run `git clone https://github.com/hexxone/TeleJelly.git` +2. Open `TeleJelly.sln` file with VS or Rider, restore Nuget packages +3. Build `TeleJelly` Plugin in Release mode +4. First run `HttpsReverseProxy` AND then `jellyfin` (server) at the same time. +5. The plugin gets copied to the server and the browser opens automatically. + +### Making changes + +When implementing a new feature, please name your commit messages in a meaningful way and refer to git best practices. + +The plugin uses "MinVer" and git-tags for semantic versioning. + +Most of the Versions (meta.json and manifest.json) get incremented automatically on release build, +**but** there are some places which have to be done manually - for example in the `config.html`. + +When targeting an updated version of Jellyfin, remember to set the correct `TargetAbi` version in `JellyfinPluginHelper`! + +Feel free to open Pull-Requests for useful additions and fixes you made, but if you disregard these guidelines, I will disregard your PR. + ## Licensing Licensing is a complex topic. This repository features a GPLv3 license template that can be used to provide a good default license for your plugin. diff --git a/TeleJelly/Assets/Config/config.html b/TeleJelly/Assets/Config/config.html index d83753d..e0f69af 100644 --- a/TeleJelly/Assets/Config/config.html +++ b/TeleJelly/Assets/Config/config.html @@ -15,7 +15,7 @@

TeleJelly Configuration

-

Version: 1.0.6.0

+

Version: 1.0.8.0

+ /// Gets the "FQDN" of the current web request context (aka. this Jellyfin server's host address). + /// With respect to the configured "ForcedUrlScheme". + /// + /// Incoming Context. + /// of the plugin. + /// string of Format "FQDN.TLD". + public static string GetRequestBase(this HttpRequest request, PluginConfiguration configuration) { - /// - /// Gets the "FQDN" of the current web request context (aka. this Jellyfin server's host address). - /// With respect to the configured "ForcedUrlScheme". - /// - /// Incoming Context. - /// of the plugin. - /// string of Format "FQDN.TLD". - public static string GetRequestBase(this HttpRequest request, PluginConfiguration configuration) + if (request == null) { - if (request == null) - { - throw new ArgumentNullException(nameof(request), "Request is null."); - } - - var requestPort = request.Host.Port ?? -1; - var requestScheme = configuration.ForceUrlScheme ? configuration.ForcedUrlScheme : request.Scheme; + throw new ArgumentNullException(nameof(request), "Request is null."); + } - // strip the default ports of given protocol in the final result (80 = http, 443 = https) - if ((requestPort == 80 && string.Equals(requestScheme, "http", StringComparison.OrdinalIgnoreCase)) || (requestPort == 443 && string.Equals(requestScheme, "https", StringComparison.OrdinalIgnoreCase))) - { - requestPort = -1; - } + var requestPort = request.Host.Port ?? -1; + var requestScheme = configuration.ForceUrlScheme ? configuration.ForcedUrlScheme : request.Scheme; - return new UriBuilder { Scheme = requestScheme, Host = request.Host.Host, Port = requestPort, Path = request.PathBase }.ToString().TrimEnd('/'); + // strip the default ports of given protocol in the final result (80 = http, 443 = https) + if ((requestPort == 80 && string.Equals(requestScheme, "http", StringComparison.OrdinalIgnoreCase)) || (requestPort == 443 && string.Equals(requestScheme, "https", StringComparison.OrdinalIgnoreCase))) + { + requestPort = -1; } + + return new UriBuilder { Scheme = requestScheme, Host = request.Host.Host, Port = requestPort, Path = request.PathBase }.ToString().TrimEnd('/'); } } diff --git a/TeleJelly/Controller/TelegramController.cs b/TeleJelly/Controller/TelegramController.cs index 3bf7aa2..9452e8f 100644 --- a/TeleJelly/Controller/TelegramController.cs +++ b/TeleJelly/Controller/TelegramController.cs @@ -28,7 +28,7 @@ namespace Jellyfin.Plugin.TeleJelly.Controller; [Route("sso/{Controller}")] public class TelegramController : ControllerBase { - private static readonly string[] _entryPoints = { "index.html", "login", "login.html" }; + private static readonly string[] _entryPoints = ["index.html", "login", "login.html"]; // private readonly ILogger _logger; private readonly TeleJellyPlugin _instance; diff --git a/TeleJelly/TeleJelly.csproj b/TeleJelly/TeleJelly.csproj index a8c8a6a..69987dd 100644 --- a/TeleJelly/TeleJelly.csproj +++ b/TeleJelly/TeleJelly.csproj @@ -1,11 +1,11 @@ - net6.0 + net8.0 Jellyfin.Plugin.TeleJelly - 1.0.6.0 - 1.0.6.0 - 1.0.6.0 + 1.0.8.0 + 1.0.8.0 + 1.0.8.0 true false /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary @@ -28,25 +28,28 @@ TeleJelly enable embedded + 12 + true + true - - + + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/TeleJelly/TeleJellyPlugin.cs b/TeleJelly/TeleJellyPlugin.cs index 8f489fe..5075fae 100644 --- a/TeleJelly/TeleJellyPlugin.cs +++ b/TeleJelly/TeleJellyPlugin.cs @@ -23,7 +23,14 @@ public class TeleJellyPlugin : BasePlugin, IPlugin, IHasWeb /// - {{TELEGRAM_BOT_NAME}} = Bot Username. /// /// A list of internal webpages in this application. - public static readonly ExtraPageInfo[] LoginFiles = { new() { Name = "index", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.html", NeedsReplacement = true }, new() { Name = "login.css", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.css", NeedsReplacement = true }, new() { Name = "login.js", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.js", NeedsReplacement = true }, new() { Name = "material_icons.woff2", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.material_icons.woff2" }, new() { Name = Constants.DefaultUserImageExtraFile, EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.TeleJellyLogo.jpg" }, }; + public static readonly ExtraPageInfo[] LoginFiles = + [ + new() { Name = "index", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.html", NeedsReplacement = true }, + new() { Name = "login.css", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.css", NeedsReplacement = true }, + new() { Name = "login.js", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.login.js", NeedsReplacement = true }, + new() { Name = "material_icons.woff2", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.material_icons.woff2" }, + new() { Name = Constants.DefaultUserImageExtraFile, EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Login.TeleJellyLogo.jpg" } + ]; /// /// Initializes a new instance of the class. @@ -66,11 +73,16 @@ public TeleJellyPlugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSer public override Guid Id => Constants.Id; /// - /// Returns the available internal web pages of this plugin. + /// Gets the available internal web pages of this plugin. /// /// A list of internal webpages in this application. - public IEnumerable GetPages() + IEnumerable IHasWebPages.GetPages() { - return new PluginPageInfo[] { new() { Name = Name, EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.html" }, new() { Name = Name + ".js", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.js" }, new() { Name = Name + ".css", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.css" } }; + return + [ + new PluginPageInfo { Name = Name, EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.html" }, + new PluginPageInfo { Name = Name + ".js", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.js" }, + new PluginPageInfo { Name = Name + ".css", EmbeddedResourcePath = $"{typeof(TeleJellyPlugin).Namespace}.Assets.Config.config.css" } + ]; } } diff --git a/TeleJelly/Telegram/TelegramHelper.cs b/TeleJelly/Telegram/TelegramHelper.cs index 8325c87..e22b6de 100644 --- a/TeleJelly/Telegram/TelegramHelper.cs +++ b/TeleJelly/Telegram/TelegramHelper.cs @@ -160,7 +160,7 @@ public async Task GetOrCreateJellyUser(SortedDictionary au AppVersion = GetType().Assembly.GetName().Version?.ToString() ?? "0.0.0.1", DeviceId = request.Headers[HeaderNames.UserAgent].ToString(), DeviceName = "TelegramBrowserSSO", - RemoteEndPoint = request.HttpContext.GetNormalizedRemoteIp().ToString(), + RemoteEndPoint = request.HttpContext.GetNormalizedRemoteIP().ToString(), UserId = user.Id, Username = user.Username }; @@ -181,13 +181,13 @@ public TelegramAuthResult CheckTelegramAuthorizationImpl(SortedDictionary