How to get address information according to IP--java----to be well-organized!!!

Source: Internet
Author: User

How to get address information according to IP--java----to be well-organized!!!

QQWry.dat Data Write Method:

Http://www.cnblogs.com/xumingxiang/archive/2013/02/17/2914524.html

Java read QQwry.dat get the IP address corresponding to the actual location:

Http://outofmemory.cn/code-snippet/541/java-duqu-QQwry-dat-get-ip-address-duiying-shiji-position

The Qqwry format is as follows:

A. File header, total 8 bytes
B. End address of several records + country and region
C. Start address + End address offset from small to large, fixed length, 7 bytes
D. All IPs are recorded in 4-byte integers and follow the Intel order, high in the back, and low in front.
E. All offsets are absolute offsets, which are calculated from the beginning of the file.
F. In addition to the file header with two 4-byte offsets, the remaining offsets are 3 bytes.
G. All offsets are also low in front, high in the rear
H. Some string compression techniques are used

1. File header, total 8 bytes
Firststartipoffset:4 Absolute offset of the first starting IP
Laststartipoffset:4 absolute offset of the last starting IP

2. Start address + End address offset record area
7 bytes per record, arranged from small to large starting address

Startip:4 start Address, IP in integer form
Endipoffset:3 End Address Absolute offset

3. End Address + country + Zone record area

Endip:4
Country + Region record: indefinite length

4. National + Regional Records, available in several forms
4.1.
Country string, ending with 0x0
Zone string, ending in 0x0

4.2.
Flag:1 Identity value: 0x1, no local record behind
0x2, there's a local record back there.
Scountryoffset:3 the actual string to go to this offset position to find
LOCALREC: variable length, optional depending on flag value. This record is similar to country and may be compressed

4.3 LOCALREC structure One
Flag:1 is not quite aware of this flag meaning, value 0x1 or 0x2
Slocaloffset:3

4.4 LOCALREC Structure II
Slocal: variable-length normal C-style string

Note: The location pointed to by Scountryoffset may still be in 4.2 format, and I do not know why this is designed.

When the flag takes 0x1, the scountryoffset point may be flag 0x2, and Localrec is looking for it here.

It is now not clear what it means to have a 0x2 mark when recording local locations.

In Qqwry.dat, there seem to be some errors.
The individual records local will be written as:
0x2,0x0,0x0,0x0
According to the rules, you should go to the beginning of the file to find, but the file at the beginning is obviously not the record of these.

How to get address information according to IP--java----to be well-organized!!!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.