mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-20 20:21:28 +00:00
24 lines
No EOL
622 B
C#
24 lines
No EOL
622 B
C#
using System.Net;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace LBPUnion.ProjectLighthouse
|
|
{
|
|
public class FakeRemoteIPAddressMiddleware
|
|
{
|
|
private readonly RequestDelegate next;
|
|
private readonly IPAddress fakeIpAddress = IPAddress.Parse("127.0.0.1");
|
|
|
|
public FakeRemoteIPAddressMiddleware(RequestDelegate next)
|
|
{
|
|
this.next = next;
|
|
}
|
|
|
|
public async Task Invoke(HttpContext httpContext)
|
|
{
|
|
httpContext.Connection.RemoteIpAddress = this.fakeIpAddress;
|
|
|
|
await this.next(httpContext);
|
|
}
|
|
}
|
|
} |