From 60443694b55fec225f8f6d50174f625abba4f741 Mon Sep 17 00:00:00 2001 From: BSRevival Date: Thu, 30 May 2024 02:33:12 -0700 Subject: [PATCH] Replace Titanium with updated .net 8 version of unobtanium web proxy. Disable proxy use fiddler for now. --- .../Controllers/FileController.cs | 12 ++++++++ Elisa.GameServer/Elisa.GameServer.csproj | 2 +- Elisa.GameServer/GameServer.cs | 3 +- .../Properties/launchSettings.json | 2 +- Elisa.GameServer/ProxyControl.cs | 28 ++++++++++--------- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/Elisa.GameServer/Controllers/FileController.cs b/Elisa.GameServer/Controllers/FileController.cs index cacc5be..1034c5c 100644 --- a/Elisa.GameServer/Controllers/FileController.cs +++ b/Elisa.GameServer/Controllers/FileController.cs @@ -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 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 homepage(string rvalue) + { + return Results.Text(@"1|2|4|5|6|7|9|10|11|13"); + } } \ No newline at end of file diff --git a/Elisa.GameServer/Elisa.GameServer.csproj b/Elisa.GameServer/Elisa.GameServer.csproj index 9883449..1ba34c1 100644 --- a/Elisa.GameServer/Elisa.GameServer.csproj +++ b/Elisa.GameServer/Elisa.GameServer.csproj @@ -45,7 +45,7 @@ - + diff --git a/Elisa.GameServer/GameServer.cs b/Elisa.GameServer/GameServer.cs index c1da81a..70cb81b 100644 --- a/Elisa.GameServer/GameServer.cs +++ b/Elisa.GameServer/GameServer.cs @@ -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(); diff --git a/Elisa.GameServer/Properties/launchSettings.json b/Elisa.GameServer/Properties/launchSettings.json index 195205d..e53ac92 100644 --- a/Elisa.GameServer/Properties/launchSettings.json +++ b/Elisa.GameServer/Properties/launchSettings.json @@ -22,7 +22,7 @@ "https": { "commandName": "Project", "dotnetRunMessages": true, - "launchBrowser": true, + "launchBrowser": false, "launchUrl": "swagger", "applicationUrl": "https://localhost:443;http://localhost:80", "environmentVariables": { diff --git a/Elisa.GameServer/ProxyControl.cs b/Elisa.GameServer/ProxyControl.cs index 806702a..5f4d5a3 100644 --- a/Elisa.GameServer/ProxyControl.cs +++ b/Elisa.GameServer/ProxyControl.cs @@ -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