feat: HTTP/SOCKS Proxy-Support für alle HttpClient-Requests

- Program.cs: ProxyUrl aus Config lesen, WebProxy auf allen HttpClients via ConfigureHttpClientDefaults
- ServerSettingsEndpoint: ProxyUrl Setting im Frontend (Text-Feld)
- appsettings.json: ProxyUrl Default (leer = kein Proxy)
- Unterstützt HTTP und SOCKS5 Proxies (z.B. socks5://127.0.0.1:1080)
- Betrifft alle ausgehenden Requests: Anthropic, OpenAI, GitHub, Serper, Telegram, Krea
This commit is contained in:
Meleki committed 2026-03-13 10:09:45 +01:00
1 parent 192f41e91e
commit cc46cf2bbc
3 files changed
+18 -2

No files matched your search

+15 -1
View File
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Runtime.InteropServices;
using Gott.Endpoints;
@@ -15,7 +16,20 @@ var builder = WebApplication.CreateBuilder(args);
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
builder.Services.AddWindowsService();
builder.Services.AddHttpClient();
var proxyUrl = builder.Configuration["ProxyUrl"];
if (!string.IsNullOrWhiteSpace(proxyUrl))
{
builder.Services.AddHttpClient().ConfigureHttpClientDefaults(b =>
b.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
{
Proxy = new WebProxy(proxyUrl),
UseProxy = true
}));
}
else
{
builder.Services.AddHttpClient();
}
var dataDir = Path.Combine(AppContext.BaseDirectory, "data");
Directory.CreateDirectory(dataDir);