2023-06-16 15:00:11 +10:00
|
|
|
|
using PARR.API.Services.Interfaces;
|
|
|
|
|
|
using System.Net;
|
|
|
|
|
|
|
|
|
|
|
|
namespace PARR.API.Services.Implementations
|
|
|
|
|
|
{
|
|
|
|
|
|
public class ClientService : IClientService
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IHttpContextAccessor httpContextAccessor;
|
|
|
|
|
|
|
|
|
|
|
|
public ClientService(IHttpContextAccessor httpContextAccessor)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.httpContextAccessor = httpContextAccessor;
|
|
|
|
|
|
}
|
|
|
|
|
|
public IPAddress? GetClientIp()
|
|
|
|
|
|
{
|
2023-08-01 16:30:16 +10:00
|
|
|
|
return httpContextAccessor.HttpContext?.Connection.RemoteIpAddress?.MapToIPv4();
|
2023-06-16 15:00:11 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|