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,

DogYun香港BGP月付14.4元主机简单测试

前些天赵容分享过DogYun(狗云)香港BGP线路AMD 5950X经典低价云服务器的信息(点击查看),刚好账户还有点余额够开个最低配,所以手贱尝试下,这些贴上简单测试信息,方便大家参考。官方网站:www.dogyun.com主机配置我搞的是最低款优惠后14.4元/月的,配置单核,512MB内存,10GB硬盘,300GB/50Mbps月流量。基本信息DogYun的VPS主机管理集成在会员中心,包括...

NameSilo域名优惠码活动

NameSilo是通过之前的感恩节优惠活动中认识到这家注册商的,于是今天早上花了点时间专门了解了NameSilo优惠码和商家的详细信息。该商家只销售域名,他们家的域名销售价格还是中规中矩的,没有像godaddy域名标价和使用优惠之后的价格悬殊很大,而且其特色就是该域名平台提供免费的域名停放、免费隐私保护等功能。namesilo新注册域名价格列表,NameSilo官方网站:www.namesilo....

RAKsmart秒杀服务器$30/月,洛杉矶/圣何塞/香港/日本站群特价

RAKsmart发布了9月份优惠促销活动,从9月1日~9月30日期间,爆款美国服务器每日限量抢购最低$30.62-$46/月起,洛杉矶/圣何塞/香港/日本站群大量补货特价销售,美国1-10Gbps大带宽不限流量服务器低价热卖等。RAKsmart是一家华人运营的国外主机商,提供的产品包括独立服务器租用和VPS等,可选数据中心包括美国加州圣何塞、洛杉矶、中国香港、韩国、日本、荷兰等国家和地区数据中心(...

ip纯真数据库为你推荐
wmiprvsewmiprvse.exe能禁用吗qq注册账号用QQ注册有几种方法?webcrack我用WebCrack4 在破解路由器密码的时候为什么在破解密码的中途自动关闭掉bindserviceonserviceconnected什么时候执行tvosTVOS系统是什么?smartupload为什么使用smartupload执行上传保存操作时用这句smart.save("upload")失败用smart.save("/upload")成功社工库网站怎么找社工库?新手怎么制作表格我是初学者、电脑上怎么制作表格12306注册12306网站账户注册基础设施即服务基础设施与市政公用设施以及公共设施之间的区别!
万网域名空间 site5 息壤备案 googleapps cloudstack 谷歌香港 ixwebhosting 好玩的桌面 typecho web服务器架设软件 100x100头像 免费防火墙 可外链相册 鲁诺 独享主机 lick 服务器维护 免费个人主页 主机返佣 工信部icp备案查询 更多