From 907de5cf5f38ec9e442af6032c1f066a02f90cd2 Mon Sep 17 00:00:00 2001 From: Alex Macocian Date: Tue, 13 Aug 2024 15:45:14 +0200 Subject: [PATCH] Adjustments to IP extracting middleware --- GuildWarsPartySearch/Endpoints/LiveFeed.cs | 2 +- GuildWarsPartySearch/Middleware/IPExtractingMiddleware.cs | 2 -- GuildWarsPartySearch/Middleware/PermissioningMiddleware.cs | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/GuildWarsPartySearch/Endpoints/LiveFeed.cs b/GuildWarsPartySearch/Endpoints/LiveFeed.cs index 15e284f..656cf46 100644 --- a/GuildWarsPartySearch/Endpoints/LiveFeed.cs +++ b/GuildWarsPartySearch/Endpoints/LiveFeed.cs @@ -39,7 +39,7 @@ await this.SendMessage(new PartySearchList public override async Task SocketAccepted(CancellationToken cancellationToken) { - var ipAddress = this.Context?.GetClientIP(); + var ipAddress = this.Context?.Request.HttpContext.GetClientIP(); var scopedLogger = this.logger.CreateScopedLogger(nameof(this.SocketAccepted), ipAddress ?? string.Empty); if (!await this.liveFeedService.AddClient(this.WebSocket!, ipAddress, this.Context?.GetPermissionLevel() ?? Models.PermissionLevel.None, cancellationToken)) { diff --git a/GuildWarsPartySearch/Middleware/IPExtractingMiddleware.cs b/GuildWarsPartySearch/Middleware/IPExtractingMiddleware.cs index 6cf6638..90fd01a 100644 --- a/GuildWarsPartySearch/Middleware/IPExtractingMiddleware.cs +++ b/GuildWarsPartySearch/Middleware/IPExtractingMiddleware.cs @@ -21,8 +21,6 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next) { var address = context.Connection.RemoteIpAddress?.ToString(); var scopedLogger = this.logger.CreateScopedLogger(nameof(this.InvokeAsync), address ?? string.Empty); - scopedLogger.LogDebug($"Received request"); - if (context.Request.Headers.TryGetValue(CFConnectingIPHeaderKey, out var cfConnectingIpValues)) { scopedLogger.LogDebug($"CF-Connecting-IP {string.Join(',', cfConnectingIpValues.Select(s => s))}"); diff --git a/GuildWarsPartySearch/Middleware/PermissioningMiddleware.cs b/GuildWarsPartySearch/Middleware/PermissioningMiddleware.cs index c4de733..be871e1 100644 --- a/GuildWarsPartySearch/Middleware/PermissioningMiddleware.cs +++ b/GuildWarsPartySearch/Middleware/PermissioningMiddleware.cs @@ -24,7 +24,6 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next) { var address = context.Connection.RemoteIpAddress?.ToString(); var scopedLogger = this.logger.CreateScopedLogger(nameof(this.InvokeAsync), address ?? string.Empty); - scopedLogger.LogDebug($"Received request"); if (context.Request.Headers.TryGetValue(XApiKeyHeaderKey, out var xApiKeyvalues)) { scopedLogger.LogDebug($"X-Api-Key {string.Join(',', xApiKeyvalues.Select(s => s))}");