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,

racknerd新上架“洛杉矶”VPS$29/年,3.8G内存/3核/58gSSD/5T流量

racknerd发表了2021年美国独立日的促销费用便宜的vps,两种便宜的美国vps位于洛杉矶multacom室,访问了1Gbps的带宽,采用了solusvm管理,硬盘是SSDraid10...近两年来,racknerd的声誉不断积累,服务器的稳定性和售后服务。官方网站:https://www.racknerd.com多种加密数字货币、信用卡、PayPal、支付宝、银联、webmoney,可以付...

iON Cloud七月促销适合稳定不折腾的用户,云服务器新购半年付8.5折,洛杉矶/圣何塞CN2 GT线路,可选Windows系统

iON Cloud怎么样?iON Cloud今天发布了7月份优惠,使用优惠码:VC4VF8RHFL,新购指定型号VPS半年付或以上可享八五折!iON的云服务器包括美国洛杉矶、美国圣何塞(包含了优化线路、CN2 GIA线路)、新加坡(CN2 GIA线路、PCCW线路、移动CMI线路)这几个机房或者线路可供选择,有Linux和Windows系统之分,整体来说针对中国的优化是非常明显的,机器稳定可靠,比...

WHloud Date鲸云数据($9.00/月), 韩国,日本,香港

WHloud Date(鲸云数据),原做大数据和软件开发的团队,现在转变成云计算服务,面对海内外用户提供中国大陆,韩国,日本,香港等多个地方节点服务。24*7小时的在线支持,较为全面的虚拟化构架以及全方面的技术支持!官方网站:https://www.whloud.com/WHloud Date 韩国BGP云主机少量补货随时可以开通,随时可以用,两小时内提交退款,可在工作日期间全额原路返回!支持pa...

ip纯真数据库为你推荐
在线课堂钉钉群直播和在线课堂的区别?联想网盘联想网盘登陆gravatarWordPress头像无法显示怎么办rbf神经网络RBF神经网络和BP神经网络有什么区别拓扑关系拓扑关系在GIS中的作用arc是什么意思arcsin中arc是什么的缩写? 怎么读? ?inode智能客户端我的电脑上inode智能客户端连接网络时,提示~服务器没有响应,请确认当前认证网卡已连接到合适的网flowplayerswfobject.js这能不能播放音频啊(amr)spawning为什么编译和运行vc++ 时会出现Error spawning c1.exe 的错误smartuploadjspsmartupload如何使用?
西安服务器 国外服务器网站 私人服务器 20g硬盘 小米数据库 服务器维护方案 河南m值兑换 isp服务商 支付宝扫码领红包 如何注册阿里云邮箱 新睿云 我的世界服务器ip 重庆服务器 闪讯网 架设代理服务器 winserver2008r2 linuxvi neicun 留言板 隐士ddos 更多