feat: Add IPAddress.ToIPv4String method
This commit is contained in:
parent
484e00f677
commit
ea2fe0f536
|
@ -71,7 +71,7 @@ namespace Bootstrap.Admin.Controllers
|
||||||
{
|
{
|
||||||
loginUser.UserAgent = context.Request.Headers["User-Agent"];
|
loginUser.UserAgent = context.Request.Headers["User-Agent"];
|
||||||
var agent = new UserAgent(loginUser.UserAgent);
|
var agent = new UserAgent(loginUser.UserAgent);
|
||||||
loginUser.Ip = (context.Connection.RemoteIpAddress ?? IPAddress.IPv6Loopback).ToString();
|
loginUser.Ip = context.Connection.RemoteIpAddress.ToIPv4String();
|
||||||
loginUser.City = ipLocator.Locate(loginUser.Ip);
|
loginUser.City = ipLocator.Locate(loginUser.Ip);
|
||||||
loginUser.Browser = $"{agent.Browser?.Name} {agent.Browser?.Version}";
|
loginUser.Browser = $"{agent.Browser?.Name} {agent.Browser?.Version}";
|
||||||
loginUser.OS = $"{agent.OS?.Name} {agent.OS?.Version}";
|
loginUser.OS = $"{agent.OS?.Name} {agent.OS?.Version}";
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
{
|
{
|
||||||
value.UserAgent = Request.Headers["User-Agent"];
|
value.UserAgent = Request.Headers["User-Agent"];
|
||||||
var agent = new UserAgent(value.UserAgent);
|
var agent = new UserAgent(value.UserAgent);
|
||||||
value.Ip = (HttpContext.Connection.RemoteIpAddress ?? IPAddress.IPv6Loopback).ToString();
|
value.Ip = HttpContext.Connection.RemoteIpAddress.ToIPv4String();
|
||||||
value.Browser = $"{agent.Browser?.Name} {agent.Browser?.Version}";
|
value.Browser = $"{agent.Browser?.Name} {agent.Browser?.Version}";
|
||||||
value.OS = $"{agent.OS?.Name} {agent.OS?.Version}";
|
value.OS = $"{agent.OS?.Name} {agent.OS?.Version}";
|
||||||
value.City = ipLocator.Locate(value.Ip);
|
value.City = ipLocator.Locate(value.Ip);
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace Bootstrap.Admin.Controllers.Api
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public bool Put()
|
public bool Put()
|
||||||
{
|
{
|
||||||
var ip = (Request.HttpContext.Connection.RemoteIpAddress ?? IPAddress.IPv6Loopback).ToString();
|
var ip = Request.HttpContext.Connection.RemoteIpAddress.ToIPv4String();
|
||||||
if (_loginUsers.TryGetValue(ip, out var user))
|
if (_loginUsers.TryGetValue(ip, out var user))
|
||||||
{
|
{
|
||||||
user.Reset();
|
user.Reset();
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.5" />
|
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.5" />
|
||||||
<PackageReference Include="Longbow.Cache" Version="2.2.12" />
|
<PackageReference Include="Longbow.Cache" Version="2.2.12" />
|
||||||
<PackageReference Include="Longbow.Data" Version="2.3.2" />
|
<PackageReference Include="Longbow.Data" Version="2.3.2" />
|
||||||
<PackageReference Include="Longbow.Web" Version="2.2.13" />
|
<PackageReference Include="Longbow.Web" Version="2.2.14" />
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.9" />
|
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.9" />
|
||||||
<PackageReference Include="Longbow.Configuration" Version="2.2.3" />
|
<PackageReference Include="Longbow.Configuration" Version="2.2.3" />
|
||||||
<PackageReference Include="Longbow.Logging" Version="2.2.7" />
|
<PackageReference Include="Longbow.Logging" Version="2.2.8" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.5" />
|
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.5" />
|
||||||
<PackageReference Include="Longbow.Data" Version="2.3.2" />
|
<PackageReference Include="Longbow.Data" Version="2.3.2" />
|
||||||
<PackageReference Include="Longbow.Logging" Version="2.2.7" />
|
<PackageReference Include="Longbow.Logging" Version="2.2.8" />
|
||||||
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
|
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
|
||||||
<PackageReference Include="Longbow.Web" Version="2.2.13" />
|
<PackageReference Include="Longbow.Web" Version="2.2.14" />
|
||||||
<PackageReference Include="Longbow.Cache" Version="2.2.12" />
|
<PackageReference Include="Longbow.Cache" Version="2.2.12" />
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
|
||||||
<PackageReference Include="PetaPoco.Extensions" Version="1.0.5" />
|
<PackageReference Include="PetaPoco.Extensions" Version="1.0.5" />
|
||||||
|
|
Loading…
Reference in New Issue