pass x-forwarded-for to properly log proxied login/logout

This commit is contained in:
RaidMax 2021-07-05 16:08:13 -05:00
parent 8b06da5783
commit e2116712e7
2 changed files with 13 additions and 4 deletions

View File

@ -125,7 +125,9 @@ namespace WebfrontCore.Controllers.API
Origin = privilegedClient,
Type = GameEvent.EventType.Login,
Owner = Manager.GetServers().First(),
Data = HttpContext.Connection.RemoteIpAddress.ToString()
Data = HttpContext.Request.Headers.ContainsKey("X-Forwarded-For")
? HttpContext.Request.Headers["X-Forwarded-For"].ToString()
: HttpContext.Connection.RemoteIpAddress.ToString()
});
return Ok();
@ -152,7 +154,9 @@ namespace WebfrontCore.Controllers.API
Origin = Client,
Type = GameEvent.EventType.Logout,
Owner = Manager.GetServers().First(),
Data = HttpContext.Connection.RemoteIpAddress.ToString()
Data = HttpContext.Request.Headers.ContainsKey("X-Forwarded-For")
? HttpContext.Request.Headers["X-Forwarded-For"].ToString()
: HttpContext.Connection.RemoteIpAddress.ToString()
});
}

View File

@ -7,6 +7,7 @@ using System;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace WebfrontCore.Controllers
{
@ -57,7 +58,9 @@ namespace WebfrontCore.Controllers
Origin = privilegedClient,
Type = GameEvent.EventType.Login,
Owner = Manager.GetServers().First(),
Data = HttpContext.Connection.RemoteIpAddress.ToString()
Data = HttpContext.Request.Headers.ContainsKey("X-Forwarded-For")
? HttpContext.Request.Headers["X-Forwarded-For"].ToString()
: HttpContext.Connection.RemoteIpAddress.ToString()
});
return Ok();
@ -82,7 +85,9 @@ namespace WebfrontCore.Controllers
Origin = Client,
Type = GameEvent.EventType.Logout,
Owner = Manager.GetServers().First(),
Data = HttpContext.Connection.RemoteIpAddress.ToString()
Data = HttpContext.Request.Headers.ContainsKey("X-Forwarded-For")
? HttpContext.Request.Headers["X-Forwarded-For"].ToString()
: HttpContext.Connection.RemoteIpAddress.ToString()
});
}