https://github.com/wzhe06/ipdatabase
IP geolocation binary tree search
https://github.com/wzhe06/ipdatabase
binary-search-tree ip-database ip-geolocation ipaddress
Last synced: 3 months ago
JSON representation
IP geolocation binary tree search
- Host: GitHub
- URL: https://github.com/wzhe06/ipdatabase
- Owner: wzhe06
- Created: 2016-03-17T03:27:11.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-06-28T14:48:32.000Z (over 3 years ago)
- Last Synced: 2025-06-08T11:43:41.780Z (4 months ago)
- Topics: binary-search-tree, ip-database, ip-geolocation, ipaddress
- Language: Java
- Homepage: https://github.com/wzhe06/ipdatabase
- Size: 2.84 MB
- Stars: 339
- Watchers: 20
- Forks: 173
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ipdatabase
二叉树快速搜索IP地址数据库# 数据
数据源采用2015年广告协会制定的IP地址标准数据库,中国互联网广告行业统一采用的标准IP库。# 原理
利用二叉树实现IP查询,首先将10进制IPV4地址转化为二进制构建二叉树,利用二叉树搜索进行搜索,查询时间复杂度log2n,比传统IP库n的查询速度高出一个量级。# 接口
根据IP查询城市或地区的接口是IpHelper类中的findRegionByIp接口,说明如下:```
/**
* 静态方法,传入ip地址,返回ip地址所在城市或地区
* @param ip IP地址,例:58.30.15.255
* @return 返回IP地址所在城市或地区,例:北京市
*/
public static String findRegionByIp(String ip)
```# example
```
public void example() throws Exception {
String ip = "58.30.15.255";
String region = IpHelper.findRegionByIp(ip);
System.out.println(region);
}
```