From 7aac95145c4316ad704e98ce68a985d6183fe7b7 Mon Sep 17 00:00:00 2001 From: Vigers Ray Date: Sat, 17 Jan 2026 23:26:28 +0100 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9=20=D0=BF=D1=80=D0=B8=20=D0=BD=D0=B0=D1=81=D1=82=D1=80?= =?UTF-8?q?=D0=BE=D0=B9=D0=BA=D0=B5=20=D0=BF=D1=80=D0=BE=D0=BA=D1=81=D0=B8?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20Discord=20webhooks:=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=D1=83=D1=81=D0=BC=D0=BE=D1=82=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=BF=D1=80=D0=BE=D0=B4=D0=BE=D0=BB=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D0=B1?= =?UTF-8?q?=D0=B5=D0=B7=20=D0=BF=D1=80=D0=BE=D0=BA=D1=81=D0=B8=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B0=D1=85.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Server/Discord/DiscordWebhook.cs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Content.Server/Discord/DiscordWebhook.cs b/Content.Server/Discord/DiscordWebhook.cs index 77f7c31f11..b32a7aa685 100644 --- a/Content.Server/Discord/DiscordWebhook.cs +++ b/Content.Server/Discord/DiscordWebhook.cs @@ -152,8 +152,17 @@ public sealed class DiscordWebhook : IPostInjectInit, IDisposable } else { - client = CreateClientWithProxies(proxyAddress); - _sawmill.Info("Configured Discord webhooks to use proxies"); + try + { + client = CreateClientWithProxies(proxyAddress); + _sawmill.Info("Configured Discord webhooks to use proxies"); + } + catch (Exception ex) + { + _sawmill.Error($"Failed to configure proxy for Discord webhooks: {ex.Message}. Continuing without proxy."); + client = new HttpClient(); + client.Timeout = Timeout; + } } // Add custom headers if configured @@ -165,18 +174,23 @@ public sealed class DiscordWebhook : IPostInjectInit, IDisposable private HttpClient CreateClientWithProxies(string proxyAddress) { var handler = CreateHandler(proxyAddress); + if (handler == null) + { + throw new InvalidOperationException("Failed to create proxy handler"); + } + var client = new HttpClient(handler); client.Timeout = Timeout; return client; } - public SocketsHttpHandler CreateHandler(string proxyAddress) + public SocketsHttpHandler? CreateHandler(string proxyAddress) { if (!Uri.TryCreate(proxyAddress, UriKind.Absolute, out var proxyUri)) { - _sawmill.Error($"Invalid proxy URI: {proxyAddress}. Discord connections will fail."); - throw new UriFormatException($"Invalid proxy address: {proxyAddress}"); + _sawmill.Error($"Invalid proxy URI: {proxyAddress}. Discord connections will continue without proxy."); + return null; } var proxyUsername = _configuration.GetCVar(SunriseCCVars.DiscordProxyUsername);