mirror of
https://github.com/NicolasConstant/BirdsiteLive
synced 2025-06-05 21:49:16 +02:00
added redirected remote ip detection
This commit is contained in:
@@ -41,6 +41,14 @@ namespace BirdsiteLive.Middlewares
|
|||||||
if (_ipWhitelistingSet)
|
if (_ipWhitelistingSet)
|
||||||
{
|
{
|
||||||
var remoteIp = context.Connection.RemoteIpAddress;
|
var remoteIp = context.Connection.RemoteIpAddress;
|
||||||
|
|
||||||
|
var forwardedIp = context.Request.Headers.FirstOrDefault(x => x.Key == "X-Real-IP").Value.ToString();
|
||||||
|
if (!string.IsNullOrWhiteSpace(forwardedIp))
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Redirected IP address detected");
|
||||||
|
remoteIp = IPAddress.Parse(forwardedIp);
|
||||||
|
}
|
||||||
|
|
||||||
_logger.LogDebug("Request from Remote IP address: {RemoteIp}", remoteIp);
|
_logger.LogDebug("Request from Remote IP address: {RemoteIp}", remoteIp);
|
||||||
|
|
||||||
var bytes = remoteIp.GetAddressBytes();
|
var bytes = remoteIp.GetAddressBytes();
|
||||||
|
Reference in New Issue
Block a user