17mon / java Goto Github PK
View Code? Open in Web Editor NEW17mon IP库解析代码
17mon IP库解析代码
用IPCounty解析区县版datx格式地址库报错,ip data not found
Exception in thread "main" java.lang.IndexOutOfBoundsException
at java.nio.Buffer.checkIndex(Unknown Source)
at java.nio.HeapByteBuffer.getInt(Unknown Source)
at org.casper.iptest.IPExt.find(IPExt.java:66)
at org.casper.iptest.IPExt.main(IPExt.java:18)
for (start = start * 9 + 262144; start < max_comp_len; start += 9) {
tmpInt = int2long(indexBuffer.getInt(start));
if (tmpInt >= ip2long_value) {
index_offset = bytesToLong(b, indexBuffer.get(start + 6), indexBuffer.get(start + 5), indexBuffer.get(start + 4));
index_length = ((0xFF & indexBuffer.get(start + 7)) << 8) + (0xFF & indexBuffer.get(start + 8));
break;
}
}
这段代码tmpInt 解析出来在是终止ip,请问起始ip要怎么解析
在进行日志分析处理时,大量的 IP.find 对整体运行时间的影响很大
I just downloaded the source code and data file. The IP.java runs very well, but the IPExt.java met some errors. Do you have any idea?
public static void main(String[] args) {
IPExt.load("data/17monipdb.dat");
System.out.println(Arrays.toString(IPExt.find("8.8.8.8")));
System.out.println(Arrays.toString(IPExt.find("118.28.8.8")));
System.out.println(Arrays.toString(IPExt.find("255.255.255.255")));
}
Exception in thread "main" java.lang.IndexOutOfBoundsException at java.nio.Buffer.checkIndex(Buffer.java:546) at java.nio.HeapByteBuffer.getInt(HeapByteBuffer.java:365) at com.yiming187.jnetpcap_example.ip.IPExt.find(IPExt.java:66) at com.yiming187.jnetpcap_example.ip.IPExt.main(IPExt.java:18)
Line 67 in 3dc7a5e
以下代码前面一半少了一个括号:
(0xFF & indexBuffer.get(start + 7) << 8) + (0xFF & indexBuffer.get(start + 8));
<<的优先级高于&,导致前面这部分算出来总是0,正确的应该是:
((0xFF & indexBuffer.get(start + 7)) << 8) + (0xFF & indexBuffer.get(start + 8));
Exception in thread "main" java.nio.BufferUnderflowException
at java.base/java.nio.HeapByteBuffer.get(HeapByteBuffer.java:191)
at com.ip.IPExt.load(IPExt.java:107)
at com.ip.IPExt.load(IPExt.java:34)
at com.ip.IPExt.main(IPExt.java:15)
in IP.java:
why "import java.util.concurrent.locks.ReentrantLock" ,
why not "java.util.concurrent.locks.ReentrantReadWriteLock"?
在spark中使用,在执行端会报序列化的问题?
find的返回函数应改为
return new String(areaBytes, Charset.forName("UTF-8")).split("\t");
以避免在非utf8编码平台上打印时的乱码。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.