🐛 Fix known proxies
This commit is contained in:
		| @@ -5,6 +5,7 @@ using DysonNetwork.Pass.Credit; | ||||
| using DysonNetwork.Pass.Leveling; | ||||
| using DysonNetwork.Pass.Permission; | ||||
| using DysonNetwork.Pass.Wallet; | ||||
| using DysonNetwork.Shared.Http; | ||||
| using Microsoft.AspNetCore.HttpOverrides; | ||||
| using Microsoft.Extensions.FileProviders; | ||||
| using Prometheus; | ||||
| @@ -23,7 +24,7 @@ public static class ApplicationConfiguration | ||||
|  | ||||
|         app.UseRequestLocalization(); | ||||
|  | ||||
|         ConfigureForwardedHeaders(app, configuration); | ||||
|         app.ConfigureForwardedHeaders(configuration); | ||||
|  | ||||
|         app.UseCors(opts => | ||||
|             opts.SetIsOriginAllowed(_ => true) | ||||
| @@ -51,28 +52,6 @@ public static class ApplicationConfiguration | ||||
|         return app; | ||||
|     } | ||||
|  | ||||
|     private static void ConfigureForwardedHeaders(WebApplication app, IConfiguration configuration) | ||||
|     { | ||||
|         var knownProxiesSection = configuration.GetSection("KnownProxies"); | ||||
|         var forwardedHeadersOptions = new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.All }; | ||||
|  | ||||
|         if (knownProxiesSection.Exists()) | ||||
|         { | ||||
|             var proxyAddresses = knownProxiesSection.Get<string[]>(); | ||||
|             if (proxyAddresses != null) | ||||
|                 foreach (var proxy in proxyAddresses) | ||||
|                     if (IPAddress.TryParse(proxy, out var ipAddress)) | ||||
|                         forwardedHeadersOptions.KnownProxies.Add(ipAddress); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             forwardedHeadersOptions.KnownProxies.Add(IPAddress.Any); | ||||
|             forwardedHeadersOptions.KnownProxies.Add(IPAddress.IPv6Any); | ||||
|         } | ||||
|  | ||||
|         app.UseForwardedHeaders(forwardedHeadersOptions); | ||||
|     } | ||||
|  | ||||
|     public static WebApplication ConfigureGrpcServices(this WebApplication app) | ||||
|     { | ||||
|         app.MapGrpcService<AccountServiceGrpc>(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user