Fixed: Real IP logging when IPv4 is mapped as IPv6

This commit is contained in:
Robin Dadswell 2021-06-03 10:50:13 +01:00 committed by ta264
parent ee81ad2add
commit 218a82998a

View file

@ -156,6 +156,12 @@ public static string GetRemoteIP(this HttpRequest request)
}
var remoteIP = request.HttpContext.Connection.RemoteIpAddress;
if (remoteIP.IsIPv4MappedToIPv6)
{
remoteIP = remoteIP.MapToIPv4();
}
var remoteAddress = remoteIP.ToString();
// Only check if forwarded by a local network reverse proxy