ip纯真数据库纯真ip数据库怎么导入mysql中

ip纯真数据库  时间:2021-07-03  阅读:()

java解释纯真数据库,通过ip算出对方的址

.ip;

import java.io.ByteArrayOutputStream; import java.io.IOException; import essFile;

public class QQWry { private String DbPath = "D:\QQWry2.Dat"; private String Country, LocalStr; private long IPN; private int RecordCount, CountryFlag; private long RangE, RangB, OffSet, StartIP, EndIP, FirstStartIP, LastStartIP, EndIPOff; private essFile fis; private byte[] buff;

public String getLocal() { return this.LocalStr; }

public String getCountry() { return this.Country; }

public void setPath(String path) { this.DbPath = path; } private long B2L(byte[] b) { long ret = 0; for (int i = 0; i < b.length; i++) { long t = 1L; for (int j = 0; j < i; j++) t = t * 256L; ret += ((b[i] < 0) ? 256 + b[i] : b[i]) * t; } return ret; }

private long ipToInt(String ip) { String[] arr = ip.split("\."); long ret = 0; for (int i = 0; i < arr.length; i++) { long l = 1; for (int j = 0; j < i; j++) l *= 256; try { ret += Long.parseLong(arr[arr.length - i - 1]) * l; } catch (Exception e) { ret += 0; } } return ret; }

public void seek(String ip) throws Exception { this.IPN = ipToInt(ip); fis = new essFile(this.DbPath, "r"); buff = new byte[4]; fis.seek(0); fis.read(buff); FirstStartIP = this.B2L(buff); fis.read(buff); LastStartIP = this.B2L(buff); RecordCount = (int) ((LastStartIP - FirstStartIP) / 7); if (RecordCount <= 1) { LocalStr = Country = "δ?"; throw new Exception(); }

RangB = 0; RangE = RecordCount; long RecNo;

do { RecNo = (RangB + RangE) / 2; getStartIP(RecNo); if (IPN == StartIP) { RangB = RecNo; break; } if (IPN > StartIP) RangB = RecNo; else RangE = RecNo; } while (RangB < RangE - 1);

getStartIP(RangB); getEndIP(); getCountry(IPN);

fis.close(); }

private String getFlagStr(long OffSet) throws IOException { int flag = 0; do { fis.seek(OffSet); buff = new byte[1]; fis.read(buff); flag = (buff[0] < 0) ? 256 + buff[0] : buff[0]; if (flag == 1 || flag == 2) { buff = new byte[3]; fis.read(buff); if (flag == 2) { CountryFlag = 2; EndIPOff = OffSet - 4; } OffSet = this.B2L(buff); } else break; } while (true);

if (OffSet < 12) { return ""; } else { fis.seek(OffSet); return getStr(); } }

private String getStr() throws IOException { long l = fis.length(); ByteArrayOutputStream byteout = new ByteArrayOutputStream(); byte c = fis.readByte(); do { byteout.write(c); c = fis.readByte(); } while (c != 0 && fis.getFilePointer() < l); return byteout.toString(); }

private void getCountry(long ip) throws IOException { if (CountryFlag == 1 || CountryFlag == 2) { Country = getFlagStr(EndIPOff + 4); if (CountryFlag == 1) { LocalStr = getFlagStr(fis.getFilePointer()); if (IPN >= ipToInt("255.255.255.0") && IPN <= ipToInt("255.255.255.255")) { LocalStr = getFlagStr(EndIPOff + 21); Country = getFlagStr(EndIPOff + 12); } } else { LocalStr = getFlagStr(EndIPOff + 8); } } else { Country = getFlagStr(EndIPOff + 4); LocalStr = getFlagStr(fis.getFilePointer()); } }

private long getEndIP() throws IOException { fis.seek(EndIPOff); buff = new byte[4]; fis.read(buff); EndIP = this.B2L(buff); buff = new byte[1]; fis.read(buff); CountryFlag = (buff[0] < 0) ? 256 + buff[0] : buff[0]; return EndIP; }

private long getStartIP(long RecNo) throws IOException { OffSet = FirstStartIP + RecNo * 7; fis.seek(OffSet); buff = new byte[4]; fis.read(buff); StartIP = this.B2L(buff); buff = new byte[3]; fis.read(buff); EndIPOff = this.B2L(buff); return StartIP; }

public String getIpAddr(String ip) throws Exception{ seek(ip); String ctron = new String(getCountry().getBytes(), "GBK"); String area = new String(getLocal().getBytes(), "GBk"); return ctron + area; }

public static void main(String[] args) throws Exception { QQWry w = new QQWry(); // w.setPath(new File("QQWry2.Dat").getAbsolutePath()); w.seek("202.120.40.1"); String ctron = new String(w.getCountry().getBytes(), "GBK"); String area = new String(w.getLocal().getBytes(), "GBk"); System.out.println(ctron + area); } }

纯真ip数据库怎么导入mysql中

打开IPData.txt文件格式是这样的 0.0.0.0 0.255.255.255 IANA保留地址 CZ88.NET 1.0.0.0 1.0.0.255 澳大利亚 CZ88.NET 1.0.1.0 1.0.3.255 福建省 电信 1.0.4.0 1.0.7.255 澳大利亚 CZ88.NET 1.0.8.0 1.0.15.255 广东省 电信 1.0.16.0 1.0.31.255 日本 CZ88.NET 1.0.32.0 1.0.63.255 广东省 电信 1.0.64.0 1.0.127.255 日本 CZ88.NET 1.0.128.0 1.0.255.255 泰国 CZ88.NET 1.1.0.0 1.1.0.255 福建省 电信 1.1.1.0 1.1.1.255 澳大利亚 CZ88.NET 三、使用Navicat for MySQL工具 1.建立ip数据库表 CREATE TABLE `ip` ( `StartIP` varchar(20) default ', `EndIP` varchar(20) default NULL, `Country` varchar(30) default NULL,`Local` varchar(50) default NULL,

Megalayer 香港CN2优化线路VPS主机速度和性能综合评测

对于Megalayer云服务器提供商在之前也有对于他们家的美国服务器和香港服务器进行过评测和介绍,但是对于大部分网友来说需要独立服务器和站群服务器并不是特别的普及,我们很多网友使用较多的还是云服务器或者VPS主机比较多。在前面也有在"Megalayer新增香港VPS主机 1GB内存 50GB SSD 2M带宽 月59元"文章中有介绍到Megalayer商家有新增香港CN2优化VPS主机。那时候看这...

wordpress投资主题模版 白银黄金贵金属金融投资网站主题

wordpress投资主题模版是一套适合白银、黄金、贵金属投资网站主题模板,绿色大气金融投资类网站主题,专业高级自适应多设备企业CMS建站主题 完善的外贸企业建站功能模块 + 高效通用的后台自定义设置,简洁大气的网站风格设计 + 更利于SEO搜索优化和站点收录排名!点击进入:wordpress投资主题模版安装环境:运行环境:PHP 7.0+, MYSQL 5.6 ( 最低主机需求 )最新兼容:完美...

华纳云E5处理器16G内存100Mbps688元/月

近日华纳云商家正式上线了美国服务器产品,这次美国机房上线的产品包括美国云服务器、美国独立服务器、美国高防御服务器以及美国高防云服务器等产品,新产品上线华纳云推出了史上优惠力度最高的特价优惠活动,美国云服务器低至3折,1核心1G内存5Mbps带宽低至24元/月,20G ddos高防御服务器低至688元/月,年付周期再送2个月、两年送4个月、三年送6个月,终身续费同价,有需要的朋友可以关注一下。华纳云...

ip纯真数据库为你推荐
strlenstrlen()函数是什么意思?row函数row函数与column函数的运用rbf神经网络rbf神经网络的输入参数个数有上限么md5值md5值什么用查字网衾字怎么读音是什么bindservice如何启动和停止用servicedeviceid如何查看自己安卓手机的Android Device ID索引超出了数组界限什么是索引超出了数组界限inode智能客户端inode智能客户端怎么使用wifi?waves插件请问下waves9是什么东西,插件吗?
花生壳域名 西安服务器租用 日本动态vps godaddy域名解析教程 建站代码 申请空间 阿里云浏览器 工信部icp备案号 老左来了 世界测速 免费高速空间 yundun 阿里云官方网站 百度云空间 中国域名 购买空间 后门 重庆服务器 杭州电信宽带 闪讯网 更多