MikuSB Proxy

This commit is contained in:
Kei-Luna
2026-04-20 15:09:04 +09:00
parent fbacecb130
commit 0212f7e397
9 changed files with 758 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
using MikuSB.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
namespace MikuSB.Proxy;
public static class ProxyServiceCollectionExtensions
{
public static IServiceCollection AddMikuSbProxy(this IServiceCollection services, ProxyOptions options)
{
services.AddSingleton<IOptions<ProxyOptions>>(Microsoft.Extensions.Options.Options.Create(options));
services.AddSingleton<ProxyCertificateAuthority>();
services.AddSingleton(new HttpClient(new SocketsHttpHandler
{
AllowAutoRedirect = false,
AutomaticDecompression = System.Net.DecompressionMethods.None,
UseCookies = false,
UseProxy = false
}));
services.AddSingleton<ProxyServer>();
services.AddHostedService(sp => sp.GetRequiredService<ProxyServer>());
services.AddHostedService<WindowsSystemProxyService>();
return services;
}
}