📦 titanium-web-proxy/ justcoding121
A cross-platform asynchronous HTTP(S) proxy server in C#.
Открыть на GitHub ↗обновлён 7ч назад
Звёзды
★ 2.0k
Форки
656
За неделю
—
За месяц
—
Рост %
—
Язык
C#
Установка и запуск
Installation
Install the stable package from NuGet:
dotnet add package Titanium.Web.Proxy
To use the latest prerelease:
dotnet add package Titanium.Web.Proxy --prerelease
Quick start
The following example starts an explicit HTTP(S) proxy on 127.0.0.1:8000 and logs each requested URL:
using System;
using System.Net;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Titanium.Web.Proxy;
using Titanium.Web.Proxy.EventArguments;
using Titanium.Web.Proxy.Models;
using var proxyServer = new ProxyServer();
// Built-in console sink is a bounded channel + background writer, so LogInformation
// never blocks a session thread on Console I/O.
proxyServer.Logging.MinimumLevel = LogLevel.Information;
proxyServer.BeforeRequest += OnRequest;
var endPoint = new ExplicitProxyEndPoint(IPAddress.Loopback, 8000, decryptSsl: true);
proxyServer.AddEndPoint(endPoint);
// Create and trust the root certificate used to decrypt HTTPS traffic.
proxyServer.CertificateManager.EnsureRootCertificate(
userTrustRootCertificate: true,
machineTrustRootCertificate: false);
proxyServer.Start();
proxyServer.Logger.LogInformation("Proxy listening on 127.0.0.1:8000. Press Enter to stop.");
await Console.In.ReadLineAsync();
proxyServer.Stop();
Task OnRequest(object sender, SessionEventArgs e)
{
proxyServer.Logger.LogInformation("{Url}", e.HttpClient.Request.Url);
return Task.CompletedTask;
}
Configure your client to use 127.0.0.1:8000 as its HTTP and HTTPS proxy. Trusting a generated root certificate changes the current user's certificate store; only do this on a machine you control.
Из README репозитория · полный README на GitHub
Категории
Теги
c-sharphttphttp-serverhttpsproxy-server