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,

牦牛云(3.5USD/月 )阿里云国际版云服务器 1核1G40G

收到好多消息,让我聊一下阿里云国际版本,作为一个阿里云死忠粉,之前用的服务器都是阿里云国内版的VPS主机,对于现在火热的阿里云国际版,这段时间了解了下,觉得还是有很多部分可以聊的,毕竟,实名制的服务器规则导致国际版无需实名这一特点被无限放大。以前也写过几篇综合性的阿里云国际版vps的分析,其中有一点得到很多人的认同,那句是阿里云不管国内版还是国际版的IO读写速度实在不敢恭维,相对意义上的,如果在这...

GigsGigsCloud($26/年)KVM-1GB/15G SSD/2TB/洛杉矶机房

GigsGigsCloud新上了洛杉矶机房国际版线路VPS,基于KVM架构,采用SSD硬盘,年付最低26美元起。这是一家成立于2015年的马来西亚主机商,提供VPS主机和独立服务器租用,数据中心包括美国洛杉矶、中国香港、新加坡、马来西亚和日本等。商家VPS主机基于KVM架构,所选均为国内直连或者优化线路,比如洛杉矶机房有CN2 GIA、AS9929或者高防线路等。下面列出这款年付VPS主机配置信息...

SugarHosts糖果主机,(67元/年)云服务器/虚拟主机低至半价

SugarHosts 糖果主机商也算是比较老牌的主机商,从2009年开始推出虚拟主机以来,目前当然还是以虚拟主机为主,也有新增云服务器和独立服务器。早年很多网友也比较争议他们家是不是国人商家,其实这些不是特别重要,我们很多国人商家或者国外商家主要还是看重的是品质和服务。一晃十二年过去,有看到SugarHosts糖果主机商12周年的促销活动。如果我们有需要香港、美国、德国虚拟主机的可以选择,他们家的...

ip纯真数据库为你推荐
mdm.mdm是什么扩展名?bloomfilter布隆过滤器既然有错误率,为什么还能应用在key-value系统中?settimermfc里SetTimer和Sleep有什么区别settimerMFC 中,全局SetTimer函数怎么用?weakhashmapJava中isEmpty方法如何使用?md5值md5值什么用deviceidAndroid里DeviceId和AndroidId都是什么意思?拓扑关系什么是空间数据的拓扑关系inode智能客户端iNode 智能客户端windows7上网方法inode智能客户端inode智能客户端怎么使用wifi?
万网域名 花生壳动态域名 备案域名出售 过期域名抢注 budgetvm 国外永久服务器 标准机柜尺寸 魔兽世界台湾服务器 域名接入 129邮箱 1g空间 卡巴斯基免费试用版 视频服务器是什么 阿里云官方网站 韩国代理ip 永久免费空间 网站加速 宿迁服务器 ssl加速 阿里云邮箱申请 更多