From 81a771c24d8957c8a9aca0d75987c4033d6c951d Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 28 Oct 2024 20:19:17 -0500 Subject: stub WebhookService --- src/slskd/Program.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/slskd/Program.cs') diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index f18d9c09..b5af63a9 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -61,6 +61,7 @@ namespace slskd using slskd.Integrations.FTP; using slskd.Integrations.Pushbullet; using slskd.Integrations.Scripts; + using slskd.Integrations.Webhooks; using slskd.Messaging; using slskd.Relay; using slskd.Search; @@ -488,6 +489,7 @@ namespace slskd // hack: services that exist only to subscribe to the event bus are not referenced by anything else // and are thus never instantiated. force a reference here so they are created. _ = app.Services.GetService(); + _ = app.Services.GetService(); app.ConfigureAspDotNetPipeline(); @@ -583,6 +585,7 @@ namespace slskd services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); services.AddSingleton(_ => new RoomTracker(messageLimit: 250)); -- cgit v1.2.3 From d6c7f53c92eb80ae2b491504c36d15e7a54ca297 Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 3 Nov 2024 15:31:45 -0600 Subject: add note about UseExceptionHandler --- src/slskd/Program.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/slskd/Program.cs') diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index b5af63a9..3ded2e6b 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -839,6 +839,7 @@ namespace slskd private static WebApplication ConfigureAspDotNetPipeline(this WebApplication app) { + // stop ASP.NET from sending a full stack trace and ProblemDetails for unhandled exceptions app.UseExceptionHandler(a => a.Run(async context => { await context.Response.WriteAsJsonAsync(context.Features.Get().Error.Message); -- cgit v1.2.3 From 4d5c0e437065e104a784b7080915ca2bfdd2218c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 3 Nov 2024 16:47:29 -0600 Subject: add an IHttpClientFactory with SSL disabled --- src/slskd/Core/Constants.cs | 23 +++++++++++++++++++++++ src/slskd/Program.cs | 10 ++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/slskd/Core/Constants.cs (limited to 'src/slskd/Program.cs') diff --git a/src/slskd/Core/Constants.cs b/src/slskd/Core/Constants.cs new file mode 100644 index 00000000..380a3519 --- /dev/null +++ b/src/slskd/Core/Constants.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// + +namespace slskd; + +public static class Constants +{ + public static readonly string IgnoreCertificateErrors = nameof(IgnoreCertificateErrors); +} \ No newline at end of file diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs index 3ded2e6b..1ac798c1 100644 --- a/src/slskd/Program.cs +++ b/src/slskd/Program.cs @@ -26,6 +26,7 @@ namespace slskd using System.IO; using System.Linq; using System.Net; + using System.Net.Http; using System.Reflection; using System.Security.Cryptography.X509Certificates; using System.Text; @@ -546,6 +547,15 @@ namespace slskd // this is important to prevent memory leaks services.AddHttpClient(); + // add a special HttpClientFactory to DI that disables SSL. access it via: + // 'using var http = HttpClientFactory.CreateClient(Constants.IgnoreCertificateErrors)' + // thanks Microsoft, makes total sense and surely won't be easy to fuck up later! + services.AddHttpClient(Constants.IgnoreCertificateErrors) + .ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler + { + ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator, + }); + // add a partially configured instance of SoulseekClient. the Application instance will // complete configuration at startup. services.AddSingleton(_ => -- cgit v1.2.3