IP_qqwry 纯真IP数据库操作
Packages | Version |
---|---|
QQWry | |
QQWry.DependencyInjection |
var config = new QQWryOptions()
{
DbPath = MapRootPath("~/IP/qqwry.dat")
};
var ipSearch = new QQWryIpSearch(config);
foreach (var ip in preSearchIpArray)
{
var ipLocation = ipSearch.GetIpLocation(ip);
Write(ipLocation);
}
Console.WriteLine("记录总数" + ipSearch.IpCount);
Console.WriteLine("版本" + ipSearch.Version);
var service = new ServiceCollection();
service.AddQQWry(config);
var serviceProvider = service.BuildServiceProvider();
using (var scope = serviceProvider.CreateScope())
{
var ipSearchInterface = scope.ServiceProvider.GetRequiredService<IIpSearch>();
foreach (var ip in preSearchIpArray)
{
var ipLocation = ipSearchInterface.GetIpLocation(ip);
Write(ipLocation);
}
Console.WriteLine("记录总数" + ipSearchInterface.IpCount);
Console.WriteLine("版本" + ipSearchInterface.Version);
}
/// <summary>
/// 数据库IP数量
/// </summary>
int IpCount { get; }
/// <summary>
/// 数据库版本
/// </summary>
string Version { get; }
/// <summary>
/// 检查是否是IP地址
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
bool CheckIp(string ip);
/// <summary>
/// 获取IP信息
/// </summary>
/// <param name="strIp"></param>
/// <returns></returns>
IpLocation GetIpLocation(string strIp);
/// <summary>
/// 检查是否是IP地址
/// </summary>
/// <param name="strIp"></param>
/// <param name="token"></param>
/// <returns></returns>
Task<IpLocation> GetIpLocationAsync(string strIp, CancellationToken token = default);
/// <summary>
/// 初始化
/// </summary>
/// <returns></returns>
bool Init();
/// <summary>
/// 初始化
/// </summary>
/// <param name="token"></param>
/// <returns></returns>
Task<bool> InitAsync(CancellationToken token = default);