Replace Titanium with updated .net 8 version of unobtanium web proxy.

Disable proxy use fiddler for now.
This commit is contained in:
BSRevival 2024-05-30 02:33:12 -07:00
parent b258ec6a17
commit 60443694b5
5 changed files with 31 additions and 16 deletions

View File

@ -15,4 +15,16 @@ public class FileController : Controller
{
return Results.Text(System.IO.File.ReadAllText(@"Resources\userProtocol_en_v005.txt"));
}
[HttpGet("iedsafe/Client/Android/24027/config2.xml", Name = "dl.listdl Config2")]
public async Task<IResult> config2()
{
return Results.Text(System.IO.File.ReadAllText(@"Resources\config2.xml"));
}
[HttpGet("sunborn-p1-us/HomePage.txt/r={rvalue}", Name = "HomePage.txt")]
public async Task<IResult> homepage(string rvalue)
{
return Results.Text(@"1|2|4|5|6|7|9|10|11|13");
}
}

View File

@ -45,7 +45,7 @@
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
<PackageReference Include="Titanium.Web.Proxy" Version="3.2.0" />
<PackageReference Include="Unobtanium.Web.Proxy" Version="0.1.0" />
</ItemGroup>
<ItemGroup>

View File

@ -23,7 +23,8 @@ public static class GameServer
.AddJsonOptions(options => options.JsonSerializerOptions.Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHostedService(provider => new ProxyBackgroundService("127.0.0.1"));
//builder.Services.AddHostedService(provider => new ProxyBackgroundService("127.0.0.1"));
WebApplication app = builder.Build();
app.UseSerilogRequestLogging();

View File

@ -22,7 +22,7 @@
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchBrowser": false,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:443;http://localhost:80",
"environmentVariables": {

View File

@ -15,20 +15,19 @@ public class ProxyControl
readonly ProxyServer proxyServer;
readonly ExplicitProxyEndPoint explicitEndPoint;
public ProxyControl(string forwardIpAddress, int port = 8888)
public ProxyControl(string forwardIpAddress, int port = 9000)
{
this.forwardIpAddress = forwardIpAddress;
proxyServer = new ProxyServer();
explicitEndPoint = new ExplicitProxyEndPoint(System.Net.IPAddress.Any, port, true);
proxyServer.BeforeRequest += OnRequest;
//Ssl handling
explicitEndPoint.BeforeTunnelConnectRequest += OnBeforeTunnelConnectRequest;
/*
proxyServer.ServerCertificateValidationCallback += OnCertificateValidation;
proxyServer.ClientCertificateSelectionCallback += OnCertificateSelection;
*/
}
@ -37,37 +36,40 @@ public class ProxyControl
proxyServer.AddEndPoint(explicitEndPoint);
proxyServer.Start();
// proxyServer.SetAsSystemHttpProxy(explicitEndPoint);
// proxyServer.SetAsSystemHttpsProxy(explicitEndPoint);
//proxyServer.SetAsSystemHttpProxy(explicitEndPoint);
//proxyServer.SetAsSystemHttpsProxy(explicitEndPoint);
}
public void Stop()
{
proxyServer.BeforeRequest -= OnRequest;
//Ssl Handling
/*proxyServer.ServerCertificateValidationCallback -= OnCertificateValidation;
proxyServer.ServerCertificateValidationCallback -= OnCertificateValidation;
proxyServer.ClientCertificateSelectionCallback -= OnCertificateSelection;
*/
explicitEndPoint.BeforeTunnelConnectRequest -= OnBeforeTunnelConnectRequest;
//proxyServer.DisableAllSystemProxies();
proxyServer.Stop();
}
private async Task OnBeforeTunnelConnectRequest(object sender, TunnelConnectSessionEventArgs e)
{
string hostname = e.HttpClient.Request.RequestUri.Host;
//show the hostname
Log.Information($"Tunnel Connect Request for {hostname}");
//Forward to our domain --this doesn't work
/*
if (HostFilter.IsMatch(hostname) || AWSFilter.IsMatch(hostname) || DLlistFilter.IsMatch(hostname))
{
Log.Information($"Forwarding tunnel connect request for {hostname} to {forwardIpAddress}");
e.DecryptSsl = true;
e.HttpClient.Request.RequestUri = new Uri("https://" + forwardIpAddress);
e.HttpClient.Request.RequestUri = new Uri("https://" + forwardIpAddress + e.HttpClient.Request.RequestUri.PathAndQuery, UriKind.Absolute);
}*/
if (hostname.Contains("gf-passport.sunborngame.com"))
return;
}
if (hostname.Contains("gf-passport.sunborngame.com"))
{
// Exclude Https addresses you don't want to proxy
// Useful for clients that use certificate pinning