没有合适的资源?快使用搜索试试~ 我知道了~
c#语言读取解析ipv6纯真数据库ipv6wry.db 数据库更新下载地址http://ip.zxinc.org/
资源推荐
资源详情
资源评论
/// <summary>
/// IpV6纯真IP库(使用时请自行准备IP库,默认路径:/App_Data/ipv6wry.db)
/// </summary>
public class Ipdbv6
{
FileStream ipFile;
long ip;
string ipfilePath = HttpContext.Current != null ? HttpContext.Current.Server.MapPath($@"/App_Data/ipv6wry.db") : "";
//偏移地址长度
int ipOff;
//IP地址长度
int iplen;
//记录数
long indexCount;
//索引第一条记录偏移
long firstIndex;
//读取数据库数据
byte[] by;
///<summary>
/// 构造函数
///</summary>
public Ipdbv6()
{
}
/// <summary>
/// 根据IP获取位置
/// </summary>
/// IpV6纯真IP库(使用时请自行准备IP库,默认路径:/App_Data/ipv6wry.db)
/// </summary>
public class Ipdbv6
{
FileStream ipFile;
long ip;
string ipfilePath = HttpContext.Current != null ? HttpContext.Current.Server.MapPath($@"/App_Data/ipv6wry.db") : "";
//偏移地址长度
int ipOff;
//IP地址长度
int iplen;
//记录数
long indexCount;
//索引第一条记录偏移
long firstIndex;
//读取数据库数据
byte[] by;
///<summary>
/// 构造函数
///</summary>
public Ipdbv6()
{
}
/// <summary>
/// 根据IP获取位置
/// </summary>
/// <param name="ipAddr">ip地址</param>
/// <param name="spacer">分隔符</param>
/// <returns></returns>
public string IpLocation(IPAddress ipAddr, string spacer = " ")
{
ipFile = new FileStream(ipfilePath, FileMode.Open, FileAccess.Read);
by = new byte[ipFile.Length];
ipFile.Read(by, 0, by.Length);
ipFile.Close();
ipFile = null;
if (Encoding.UTF8.GetString(by, 0, 4) != "IPDB" || BitConverter.ToInt16(by, 4) > 1)//数据库格式错误
{
return "数据库格式错误";
}
ipOff = Convert.ToInt32(by[6]);
iplen = by[7];
indexCount = BitConverter.ToInt64(by, 8);
firstIndex = BitConverter.ToInt64(by, 16);
ip = GetIpLong4(ipAddr);
IPLocationStruct loc = GetIPLocation();
/// <param name="spacer">分隔符</param>
/// <returns></returns>
public string IpLocation(IPAddress ipAddr, string spacer = " ")
{
ipFile = new FileStream(ipfilePath, FileMode.Open, FileAccess.Read);
by = new byte[ipFile.Length];
ipFile.Read(by, 0, by.Length);
ipFile.Close();
ipFile = null;
if (Encoding.UTF8.GetString(by, 0, 4) != "IPDB" || BitConverter.ToInt16(by, 4) > 1)//数据库格式错误
{
return "数据库格式错误";
}
ipOff = Convert.ToInt32(by[6]);
iplen = by[7];
indexCount = BitConverter.ToInt64(by, 8);
firstIndex = BitConverter.ToInt64(by, 16);
ip = GetIpLong4(ipAddr);
IPLocationStruct loc = GetIPLocation();
剩余7页未读,继续阅读
资源评论
- 冰山之海2023-03-23啥垃圾资源,浪费我的积分,我以为可以下到ip库的txt
梦誉晨
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功