From 62c52dd5893589a24f0175e25fffcbe517c2de14 Mon Sep 17 00:00:00 2001 From: dingo Date: Sat, 28 Feb 2026 09:03:30 -0500 Subject: [PATCH] Revert --- Server/src/SOR.Host/Program.cs | 59 +--------------------------------- 1 file changed, 1 insertion(+), 58 deletions(-) diff --git a/Server/src/SOR.Host/Program.cs b/Server/src/SOR.Host/Program.cs index 1374615..8d9c8fa 100644 --- a/Server/src/SOR.Host/Program.cs +++ b/Server/src/SOR.Host/Program.cs @@ -29,10 +29,7 @@ using Serilog; using StackExchange.Redis; using NATS.Client.Core; using NATS.Client.Hosting; -using System.Net; -using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.WebSockets; -using Microsoft.AspNetCore.Server.Kestrel.Core; using SOR.Auth.Handlers; // ── ENABLED_SERVICES ────────────────────────────────────────────────────────── @@ -58,60 +55,6 @@ bool IsEnabled(string name) => var builder = WebApplication.CreateBuilder(args); -// Local cleartext gRPC requires a dedicated HTTP/2 listener. -// When Auth is enabled in this process and Services:Auth points to a loopback http:// URL, -// bind that port explicitly so Gateway can reach the Auth gRPC handler over h2c. -// Kestrel ignores URLS once explicit listeners are configured, so preserve the existing -// URLS binding as an explicit listener too. -if (IsEnabled("auth") && - Uri.TryCreate(builder.Configuration["Services:Auth"], UriKind.Absolute, out var authServiceUri) && - string.Equals(authServiceUri.Scheme, Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) && - authServiceUri.IsLoopback) -{ - var configuredUrls = builder.WebHost.GetSetting(WebHostDefaults.ServerUrlsKey); - - builder.WebHost.ConfigureKestrel(options => - { - foreach (var rawUrl in (configuredUrls ?? string.Empty).Split( - ';', - StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)) - { - if (!Uri.TryCreate(rawUrl, UriKind.Absolute, out var configuredUri)) - continue; - - ListenOnConfiguredUrl(options, configuredUri); - } - - options.ListenLocalhost(authServiceUri.Port, listenOptions => - { - listenOptions.Protocols = HttpProtocols.Http2; - }); - }); -} - -static void ListenOnConfiguredUrl(KestrelServerOptions options, Uri uri) -{ - if (!string.Equals(uri.Scheme, Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase)) - return; - - if (uri.Host == "+" || uri.Host == "*" || uri.Host == "0.0.0.0") - { - options.ListenAnyIP(uri.Port, listenOptions => listenOptions.Protocols = HttpProtocols.Http1); - return; - } - - if (string.Equals(uri.Host, "localhost", StringComparison.OrdinalIgnoreCase)) - { - options.ListenLocalhost(uri.Port, listenOptions => listenOptions.Protocols = HttpProtocols.Http1); - return; - } - - if (IPAddress.TryParse(uri.Host, out var ipAddress)) - { - options.Listen(ipAddress, uri.Port, listenOptions => listenOptions.Protocols = HttpProtocols.Http1); - } -} - // ── Logging ─────────────────────────────────────────────────────────────────── // Replace .NET's default logger with Serilog. // Configuration comes from the "Serilog" section of appsettings.json. @@ -242,4 +185,4 @@ Log.Information("SOR Host starting. Services: {Services}", rawServices); // RunAsync blocks until the process receives a shutdown signal (SIGTERM, Ctrl+C). // On shutdown, ASP.NET Core calls StopAsync on all IHostedService implementations // (including GatewayHostedService) in reverse registration order. -await app.RunAsync(); +await app.RunAsync(); \ No newline at end of file