测试新的解析IP的库
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
bf5f56f5f2
commit
9bcaa07c1a
|
@ -113,6 +113,12 @@
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="Resources\GeoLite2-City.mmdb">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<VisualStudio>
|
<VisualStudio>
|
||||||
<UserProperties properties_4launchsettings_1json__JsonSchema="" />
|
<UserProperties properties_4launchsettings_1json__JsonSchema="" />
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 73 MiB |
|
@ -50,6 +50,7 @@
|
||||||
<PackageReference Include="IP2Region.Net" Version="2.0.2" />
|
<PackageReference Include="IP2Region.Net" Version="2.0.2" />
|
||||||
<PackageReference Include="MailKit" Version="4.7.1.1" />
|
<PackageReference Include="MailKit" Version="4.7.1.1" />
|
||||||
<PackageReference Include="Masa.Contrib.Service.MinimalAPIs" Version="1.0.0" />
|
<PackageReference Include="Masa.Contrib.Service.MinimalAPIs" Version="1.0.0" />
|
||||||
|
<PackageReference Include="MaxMind.GeoIP2" Version="5.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" />
|
||||||
<PackageReference Include="MimeKit" Version="4.7.1" />
|
<PackageReference Include="MimeKit" Version="4.7.1" />
|
||||||
<PackageReference Include="MiniExcel" Version="1.34.2" />
|
<PackageReference Include="MiniExcel" Version="1.34.2" />
|
||||||
|
|
|
@ -16,6 +16,7 @@ using IRaCIS.Core.Infrastructure.Encryption;
|
||||||
using IRaCIS.Core.Infrastructure.NewtonsoftJson;
|
using IRaCIS.Core.Infrastructure.NewtonsoftJson;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
using MassTransit.Mediator;
|
using MassTransit.Mediator;
|
||||||
|
using MaxMind.GeoIP2;
|
||||||
using Medallion.Threading;
|
using Medallion.Threading;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
@ -95,6 +96,46 @@ namespace IRaCIS.Core.Application.Service
|
||||||
return ResponseOutput.Ok();
|
return ResponseOutput.Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[AllowAnonymous]
|
||||||
|
public async Task<IResponseOutput> NewIP([FromServices] IRepository<UserLog> _userLogRepository)
|
||||||
|
{
|
||||||
|
var path = Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources, "GeoLite2-City.mmdb");
|
||||||
|
|
||||||
|
|
||||||
|
var ipList = _userLogRepository.Select(t => t.IP).Distinct().ToList();
|
||||||
|
|
||||||
|
foreach (var ip in ipList)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var reader = new DatabaseReader(path))
|
||||||
|
{
|
||||||
|
|
||||||
|
var city = reader.City(ip);
|
||||||
|
|
||||||
|
Console.WriteLine(city.Country.IsoCode); // 'US' 'CN'
|
||||||
|
Console.WriteLine(city.Country.Name); // 'United States' 'China'
|
||||||
|
//Console.WriteLine(city.Country.Names["zh-CN"]); // '美国'
|
||||||
|
Console.WriteLine(city.MostSpecificSubdivision.Name); // 'Minnesota' 'Hubei'
|
||||||
|
Console.WriteLine(city.City.Name); // 'Minneapolis' 'WUHan'
|
||||||
|
|
||||||
|
|
||||||
|
Console.WriteLine("----------------");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine($"{ip}在数据库无法解析 {ex.Message}"); // 44.9733
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return ResponseOutput.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IQC 回退到影像上传
|
/// IQC 回退到影像上传
|
||||||
|
|
Loading…
Reference in New Issue