From e33004f319da6e4b0caabda5cecbc8cc113b427c Mon Sep 17 00:00:00 2001 From: dongyado Date: Thu, 20 Feb 2020 12:58:56 +0800 Subject: [PATCH 01/11] update nodejs client and use node-ip2region for npm package name --- binding/nodejs/README.md | 8 +++++--- binding/nodejs/deploy.sh | 0 binding/nodejs/package.json | 14 +++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) mode change 100644 => 100755 binding/nodejs/deploy.sh diff --git a/binding/nodejs/README.md b/binding/nodejs/README.md index a5d00c7..eeba742 100644 --- a/binding/nodejs/README.md +++ b/binding/nodejs/README.md @@ -1,14 +1,16 @@ # nodejs 客户端 +官方维护的 ip2region, 每次数据更新后会更新到 npm + ## Install ``` -npm install lionsoul-ip2region --save +npm install node-ip2region --save ``` ## Example ``` -const searcher = require('lionsoul-ip2region').create(); +const searcher = require('node-ip2region').create(); searcher.btreeSearchSync('xxx.xxx.xxx.xxx') // => { city: 2163, region: '中国|0|广东省|深圳市|联通' } ``` @@ -83,4 +85,4 @@ Rand Name Time (in milliseconds) 4 BinarySearchSync 1.639 5 BtreeSearch 3.407 6 BinarySearch 6.497 -``` \ No newline at end of file +``` diff --git a/binding/nodejs/deploy.sh b/binding/nodejs/deploy.sh old mode 100644 new mode 100755 diff --git a/binding/nodejs/package.json b/binding/nodejs/package.json index fe8bee7..6730822 100644 --- a/binding/nodejs/package.json +++ b/binding/nodejs/package.json @@ -1,7 +1,7 @@ { - "name": "lionsoul-ip2region", - "version": "0.0.1", - "description": "ip database ", + "name": "node-ip2region", + "version": "1.0.1", + "description": "official nodejs client of ip2region", "main": "ip2region.js", "scripts": { "test": "jest", @@ -10,7 +10,7 @@ "files": ["data/"], "repository": { "type": "git", - "url": "https://github.com/lionsoul2016/ip2region" + "url": "https://github.com/lionsoul2014/ip2region" }, "keywords": [ "ip2region", @@ -20,11 +20,11 @@ "author": "dongyado", "license": "ISC", "bugs": { - "url": "https://github.com/lionsoul2016/ip2region/issues" + "url": "https://github.com/lionsoul2014/ip2region/issues" }, - "homepage": "https://github.com/lionsoul2016/ip2region", + "homepage": "https://github.com/lionsoul2014/ip2region", "devDependencies": { "jest": "^19.0.2", "benchmark": "^2.1.4" } -} \ No newline at end of file +} From ff535a79f4f41448a7d192e175a793889af04bdc Mon Sep 17 00:00:00 2001 From: dongyado Date: Thu, 20 Feb 2020 16:57:50 +0800 Subject: [PATCH 02/11] update readme add tested node version --- binding/nodejs/README.md | 15 +++++++++++++++ binding/nodejs/package.json | 5 ++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/binding/nodejs/README.md b/binding/nodejs/README.md index eeba742..7a45b22 100644 --- a/binding/nodejs/README.md +++ b/binding/nodejs/README.md @@ -2,11 +2,26 @@ 官方维护的 ip2region, 每次数据更新后会更新到 npm + ## Install + +**node 版本 : >= 6.0.0** + ``` npm install node-ip2region --save ``` +## 已测试通过的 node 版本列表 + +``` +6.0.0 +6.11.2 +8.0.0 +10.0.0 +12.0.0 +``` + + ## Example ``` diff --git a/binding/nodejs/package.json b/binding/nodejs/package.json index 6730822..160befe 100644 --- a/binding/nodejs/package.json +++ b/binding/nodejs/package.json @@ -1,6 +1,6 @@ { "name": "node-ip2region", - "version": "1.0.1", + "version": "1.0.2", "description": "official nodejs client of ip2region", "main": "ip2region.js", "scripts": { @@ -26,5 +26,8 @@ "devDependencies": { "jest": "^19.0.2", "benchmark": "^2.1.4" + }, + "engines": { + "node" : ">=6.0.0" } } From ac86979872e963f6da61aebbdce2120b785fb9f4 Mon Sep 17 00:00:00 2001 From: lionsoul Date: Fri, 21 Feb 2020 13:36:21 +0800 Subject: [PATCH 03/11] Optimize the README DOC --- README.md | 181 +++++++++++------- .../php5/ip2region/.gitignore | 0 .../php5/ip2region/CREDITS | 0 .../php5/ip2region/README.md | 0 .../php5/ip2region/config.m4 | 0 .../php5/ip2region/config.w32 | 0 .../php5/ip2region/ip2region.c | 0 .../php5/ip2region/ip2region.php | 0 .../php5/ip2region/lib/README.md | 0 .../php5/ip2region/php_ip2region.h | 0 .../php5/ip2region/tests/001.phpt | 0 .../php7/ip2region/.gitignore | 0 .../php7/ip2region/CREDITS | 0 .../php7/ip2region/README.md | 0 .../php7/ip2region/config.m4 | 0 .../php7/ip2region/config.w32 | 0 .../php7/ip2region/ip2region.c | 0 .../php7/ip2region/ip2region.php | 0 .../php7/ip2region/lib/README.md | 0 .../php7/ip2region/php_ip2region.h | 0 .../php7/ip2region/tests/001.phpt | 0 binding/rust/readme.md | 2 +- 22 files changed, 110 insertions(+), 73 deletions(-) rename binding/{php_extension => php_ext}/php5/ip2region/.gitignore (100%) rename binding/{php_extension => php_ext}/php5/ip2region/CREDITS (100%) rename binding/{php_extension => php_ext}/php5/ip2region/README.md (100%) rename binding/{php_extension => php_ext}/php5/ip2region/config.m4 (100%) rename binding/{php_extension => php_ext}/php5/ip2region/config.w32 (100%) rename binding/{php_extension => php_ext}/php5/ip2region/ip2region.c (100%) rename binding/{php_extension => php_ext}/php5/ip2region/ip2region.php (100%) rename binding/{php_extension => php_ext}/php5/ip2region/lib/README.md (100%) rename binding/{php_extension => php_ext}/php5/ip2region/php_ip2region.h (100%) rename binding/{php_extension => php_ext}/php5/ip2region/tests/001.phpt (100%) rename binding/{php_extension => php_ext}/php7/ip2region/.gitignore (100%) rename binding/{php_extension => php_ext}/php7/ip2region/CREDITS (100%) rename binding/{php_extension => php_ext}/php7/ip2region/README.md (100%) rename binding/{php_extension => php_ext}/php7/ip2region/config.m4 (100%) rename binding/{php_extension => php_ext}/php7/ip2region/config.w32 (100%) rename binding/{php_extension => php_ext}/php7/ip2region/ip2region.c (100%) rename binding/{php_extension => php_ext}/php7/ip2region/ip2region.php (100%) rename binding/{php_extension => php_ext}/php7/ip2region/lib/README.md (100%) rename binding/{php_extension => php_ext}/php7/ip2region/php_ip2region.h (100%) rename binding/{php_extension => php_ext}/php7/ip2region/tests/001.phpt (100%) diff --git a/README.md b/README.md index 97adec6..561af19 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,15 @@ -ip2region - 最自由的ip地址查询库,ip到地区的映射库,提供Binary,B树和纯内存三种查询算法,妈妈再也不用担心我的ip地址定位。 +# Ip2region是什么? -### 1. 前言: -ip2region重点在于研究ip数据的存储设计和各种语言的查询实现,并没有原始ip数据的支撑,数据来源请参考下面的描述,升级数据需要很多IP的支撑并且会对原始平台造成一定量的请求压力,本项目不保证及时的数据更新,没有也不会有商用版本,你可以使用自定义的数据导入ip2region进行自定义查询的实现。 +ip2region - 准确率99.9%的离线IP地址定位库,0.0x毫秒级查询,ip2region.db数据库只有数MB,提供了java,php,c,python,nodejs,golang,c#等查询绑定和Binary,B树,内存三种查询算法。 -### 2. 99.9%准确率,定时更新: -数据聚合了一些知名ip到地名查询提供商的数据,这些是他们官方的的准确率,经测试着实比纯真啥的准确一些。
+ + +# Ip2region核心特性 + +### 99.9%准确率 + +数据聚合了一些知名ip到地名查询提供商的数据,这些是他们官方的的准确率,经测试着实比经典的纯真IP定位准确一些。
ip2region的数据聚合自以下服务商的开放API或者数据(升级程序每秒请求次数2到4次):
01, >80%, 淘宝IP地址库, [http://ip.taobao.com/](http://ip.taobao.com/)
02, ≈10%, GeoIP, [https://geoip.com/](https://geoip.com/)
@@ -13,80 +17,67 @@ ip2region的数据聚合自以下服务商的开放API或者数据(升级程序 备注:如果上述开放API或者数据都不给开放数据时ip2region将停止数据的更新服务。 -### 3. 标准化的数据格式: +### 标准化的数据格式 -每条ip数据段都固定了格式:_城市Id|国家|区域|省份|城市|ISP_ +每条ip数据段都固定了格式:] +``` +_城市Id|国家|区域|省份|城市|ISP_ +``` -只有中国的数据精确到了城市,其他国家只能定位到国家,后前的选项全部是0,已经包含了全部你能查到的大大小小的国家。 -(请忽略前面的城市Id,个人项目需求) +只有中国的数据精确到了城市,其他国家有部分数据只能定位到国家,后前的选项全部是0,已经包含了全部你能查到的大大小小的国家(请忽略前面的城市Id,个人项目需求)。 -### 4. 体积小: -生成的数据库文件ip2region.db只有1.5M(1.2版本前是3.5M) +### 体积小 -### 5. 多查询客户端的支持,0.0x毫秒级别的查询 +包含了全部的IP,生成的数据库文件ip2region.db只有几MB,最小的版本只有1.5MB,随着数据的详细度增加数据库的大小也慢慢增大,目前还没超过8MB。 + + +### 查询速度快 + +全部的查询客户端单次查询都在0.x毫秒级别,内置了三种查询算法 + +1. memory算法:整个数据库全部载入内存,单次查询都在0.1x毫秒内,C语言的客户端单次查询在0.00x毫秒级别。 +2. binary算法:基于二分查找,基于ip2region.db文件,不需要载入内存,单次查询在0.x毫秒级别。 +3. b-tree算法:基于btree算法,基于ip2region.db文件,不需要载入内存,单词查询在0.x毫秒级别,比binary算法更快。 + +任何客户端b-tree都比binary算法快,当然memory算法固然是最快的! + + +### 多查询客户端的支持 已经集成的客户端有:java、C#、php、c、python、nodejs、php扩展(php5和php7)、golang、rust、lua、lua_c。 - 提供了两种查询算法,响应时间如下: - 客户端/binary算法/b-tree算法/Memory算法: - c#/0.x毫秒/0.x毫秒/0.x毫秒 - java/0.x毫秒/0.x毫秒/0.1x毫秒 (使用RandomAccessFile) - php/0.x毫秒/0.1x毫秒/0.1x毫秒 - c/0.0x毫秒/0.0x毫秒/0.00x毫秒(b-tree算法基本稳定在0.02x毫秒级别) - python/0.x毫秒/0.1x毫秒/未知 - lua/0.x毫秒/0.x毫秒/0.x毫秒 - lua_c/0.0x毫秒/0.0x毫秒/0.00x毫秒 -任何客户端b-tree都比binary算法快,当然Memory算法固然是最快的! +##### 已有的binding +适用语言 | 开发语言 | 开发状态 | binary查询耗时 | b-tree查询耗时 | memory查询耗时 + :-: | :-: | :-: | :-: | :-: | :-: + [c](binding/c) | c | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 + [c#](binding/c#) | c# | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 + [golang](binding/golang) | golang | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 + [java](binding/java) | java | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 + [lua](binding/lua) | lua | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 + [lua](binding/lua_c) | c | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 + [nginx](binding/nginx) | c | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 + [nodejs](binding/nodejs) | nodejs | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 + [php](binding/php) | php | 已完成 | 0.x毫秒 | 0.1x毫秒 | 0.1x毫秒 + [php](binding/c) | c | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 + [php](binding/c) | c | 已完成 | 0.0毫秒 | 0.0x毫秒 | 0.00x毫秒 + [python](binding/c) | python | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 + [rust](binding/c) | rust | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 -maven仓库地址: -```xml - - org.lionsoul - ip2region - 1.7.2 - -``` -nuget安装命令 -```shell -Install-Package IP2Region -``` -### 6. 测试程序: -C#、Node.js、lua_c的测试请具体参考文件夹中README.md 说明。 -java: -```shell -cd binding/java -ant all -java -jar ip2region-{version}.jar ./data/ip2region.db -``` -php: -```shell -php binding/php/testSearcher.php ./data/ip2region.db -``` +# ip2region快速测试 -c: +请参考每个binding下的README说明去运行cli测试程序,例如C语言的demo运行如下: ```shell cd binding/c/ gcc -g -O2 testSearcher.c ip2region.c ./a.out ../../data/ip2region.db ``` -python: -```shell -python binding/python/testSearcher.py ./data/ip2region.db -``` - -lua: -```shell -cd binding/lua/ -lua testSearcher.lua ../../data/ip2region.db -``` - -均会看到如下界面: +会看到如下cli界面: ```shell initializing B-tree ... +----------------------------------+ @@ -98,19 +89,60 @@ p2region>> 101.105.35.57 2163|中国|华南|广东省|深圳市|鹏博士 in 0.02295 millseconds ``` -输入ip地址开始测试,第一次会稍微有点慢,在运行命令后面接入binary,memory来尝试其他算法,建议使用b-tree算法,速度和并发需求的可以使用memory算法。 - -具体集成请参考不同客户端的测试源码。 +输入IP地址开始测试,第一次会稍微有点慢,在运行命令后面接入binary,memory来尝试其他算法,建议使用b-tree算法,速度和并发需求的可以使用memory算法,具体集成请参考不同binding下的测试源码。 -### 7. 如何生成ip2region.db文件 + + +# ip2region安装 + +具体请参考每个binding下的README文档,以下是一些可用的快捷安装方式: + +### maven仓库地址 +```xml + + org.lionsoul + ip2region + 1.7.2 + +``` + +### nodejs +``` +npm install node-ip2region --save +``` + +### nuget安装 +```shell +Install-Package IP2Region +``` + +### php composer +```shell +# 插件来自:https://github.com/zoujingli/ip2region +composer require zoujingli/ip2region +``` + + + +# ip2region 并发使用 + +1. 全部binding的各个search接口都不是线程安全的实现,不同线程可以通过创建不同的查询对象来使用,并发量很大的情况下,binary和b-tree算法可能会打开文件数过多的错误,请修改内核的最大允许打开文件数(fs.file-max=一个更高的值),或者使用持久化的memory算法。 + +2. memorySearch接口,在发布对象前进行一次预查询(本质上是把ip2region.db文件加载到内存),可以安全用于多线程环境。 + + + + +# ip2region.db的生成 从1.8版本开始,ip2region开源了ip2region.db生成程序的java实现,提供了ant编译支持,编译后会得到以下提到的dbMaker-{version}.jar,对于需要研究生成程序的或者更改自定义生成配置的请参考${ip2region_root}/maker/java内的java源码。 从ip2region 1.2.2版本开始里面提交了一个dbMaker-{version}.jar的可以执行jar文件,用它来完成这个工作: -* 1, 确保你安装好了java环境(不玩Java的童鞋就自己谷歌找找拉,临时用一用,几分钟的事情) -* 2, cd到${ip2region_root}/maker/java,然后运行如下命令: + +1. 确保你安装好了java环境(不玩Java的童鞋就自己谷歌找找拉,临时用一用,几分钟的事情) +2. cd到${ip2region_root}/maker/java,然后运行如下命令: ```shell java -jar dbMaker-{version}.jar -src 文本数据文件 -region 地域csv文件 [-dst 生成的ip2region.db文件的目录] @@ -120,8 +152,8 @@ java -jar dbMaker-{version}.jar -src 文本数据文件 -region 地域csv文件 # ip2region.db文件的目录:是可选参数,没有指定的话会在当前目录生成一份./data/ip2region.db文件 ``` -* 3, 获取生成的ip2region.db文件覆盖原来的ip2region.db文件即可 -* 4, 默认的ip2region.db文件生成命令: +3. 获取生成的ip2region.db文件覆盖原来的ip2region.db文件即可 +4. 默认的ip2region.db文件生成命令: ```shell cd ${ip2region_root}/java/ @@ -130,10 +162,15 @@ java -jar dbMaker-1.2.2.jar -src ./data/ip.merge.txt -region ./data/global_regio # 会看到一大片的输出 ``` -* 5, 数据库文件的结构和原理请阅读 @冬芽 的blog:[“ip2region数据库文件的结构和原理”](http://dongyado.com/tool/2016/08/18/structure-of-ip2region-database-file/) -### 8. 其他备注 -* 1, 全部binding的各个search接口都不是线程安全的实现,不同线程可以通过创建不同的查询对象来使用。 -* 2, memorySearch接口,在发布对象前进行一次预查询,可以安全用于多线程环境。 -* 3, ip2region交流分享,微信:lionsoul2014,QQ:1187582057 + +# 相关备注 + +### 声明 +ip2region重点在于研究IP数据的存储设计和各种语言的查询实现,并没有原始IP数据的支撑,数据来源请参考上面的描述,升级数据需要很多IP的支撑并且会对原始平台造成一定量的请求压力,本项目不保证及时的数据更新,没有也不会有商用版本,你可以使用自定义的数据导入ip2region进行自定义查询的实现。 + +### 技术交流 +1. 数据库文件的结构和原理请阅读 @冬芽 的blog:[“ip2region数据库文件的结构和原理”](http://dongyado.com/tool/2016/08/18/structure-of-ip2region-database-file/) +2. ip2region交流分享,微信:lionsoul2014(请备注ip2region),QQ:1187582057(很少关注) + diff --git a/binding/php_extension/php5/ip2region/.gitignore b/binding/php_ext/php5/ip2region/.gitignore similarity index 100% rename from binding/php_extension/php5/ip2region/.gitignore rename to binding/php_ext/php5/ip2region/.gitignore diff --git a/binding/php_extension/php5/ip2region/CREDITS b/binding/php_ext/php5/ip2region/CREDITS similarity index 100% rename from binding/php_extension/php5/ip2region/CREDITS rename to binding/php_ext/php5/ip2region/CREDITS diff --git a/binding/php_extension/php5/ip2region/README.md b/binding/php_ext/php5/ip2region/README.md similarity index 100% rename from binding/php_extension/php5/ip2region/README.md rename to binding/php_ext/php5/ip2region/README.md diff --git a/binding/php_extension/php5/ip2region/config.m4 b/binding/php_ext/php5/ip2region/config.m4 similarity index 100% rename from binding/php_extension/php5/ip2region/config.m4 rename to binding/php_ext/php5/ip2region/config.m4 diff --git a/binding/php_extension/php5/ip2region/config.w32 b/binding/php_ext/php5/ip2region/config.w32 similarity index 100% rename from binding/php_extension/php5/ip2region/config.w32 rename to binding/php_ext/php5/ip2region/config.w32 diff --git a/binding/php_extension/php5/ip2region/ip2region.c b/binding/php_ext/php5/ip2region/ip2region.c similarity index 100% rename from binding/php_extension/php5/ip2region/ip2region.c rename to binding/php_ext/php5/ip2region/ip2region.c diff --git a/binding/php_extension/php5/ip2region/ip2region.php b/binding/php_ext/php5/ip2region/ip2region.php similarity index 100% rename from binding/php_extension/php5/ip2region/ip2region.php rename to binding/php_ext/php5/ip2region/ip2region.php diff --git a/binding/php_extension/php5/ip2region/lib/README.md b/binding/php_ext/php5/ip2region/lib/README.md similarity index 100% rename from binding/php_extension/php5/ip2region/lib/README.md rename to binding/php_ext/php5/ip2region/lib/README.md diff --git a/binding/php_extension/php5/ip2region/php_ip2region.h b/binding/php_ext/php5/ip2region/php_ip2region.h similarity index 100% rename from binding/php_extension/php5/ip2region/php_ip2region.h rename to binding/php_ext/php5/ip2region/php_ip2region.h diff --git a/binding/php_extension/php5/ip2region/tests/001.phpt b/binding/php_ext/php5/ip2region/tests/001.phpt similarity index 100% rename from binding/php_extension/php5/ip2region/tests/001.phpt rename to binding/php_ext/php5/ip2region/tests/001.phpt diff --git a/binding/php_extension/php7/ip2region/.gitignore b/binding/php_ext/php7/ip2region/.gitignore similarity index 100% rename from binding/php_extension/php7/ip2region/.gitignore rename to binding/php_ext/php7/ip2region/.gitignore diff --git a/binding/php_extension/php7/ip2region/CREDITS b/binding/php_ext/php7/ip2region/CREDITS similarity index 100% rename from binding/php_extension/php7/ip2region/CREDITS rename to binding/php_ext/php7/ip2region/CREDITS diff --git a/binding/php_extension/php7/ip2region/README.md b/binding/php_ext/php7/ip2region/README.md similarity index 100% rename from binding/php_extension/php7/ip2region/README.md rename to binding/php_ext/php7/ip2region/README.md diff --git a/binding/php_extension/php7/ip2region/config.m4 b/binding/php_ext/php7/ip2region/config.m4 similarity index 100% rename from binding/php_extension/php7/ip2region/config.m4 rename to binding/php_ext/php7/ip2region/config.m4 diff --git a/binding/php_extension/php7/ip2region/config.w32 b/binding/php_ext/php7/ip2region/config.w32 similarity index 100% rename from binding/php_extension/php7/ip2region/config.w32 rename to binding/php_ext/php7/ip2region/config.w32 diff --git a/binding/php_extension/php7/ip2region/ip2region.c b/binding/php_ext/php7/ip2region/ip2region.c similarity index 100% rename from binding/php_extension/php7/ip2region/ip2region.c rename to binding/php_ext/php7/ip2region/ip2region.c diff --git a/binding/php_extension/php7/ip2region/ip2region.php b/binding/php_ext/php7/ip2region/ip2region.php similarity index 100% rename from binding/php_extension/php7/ip2region/ip2region.php rename to binding/php_ext/php7/ip2region/ip2region.php diff --git a/binding/php_extension/php7/ip2region/lib/README.md b/binding/php_ext/php7/ip2region/lib/README.md similarity index 100% rename from binding/php_extension/php7/ip2region/lib/README.md rename to binding/php_ext/php7/ip2region/lib/README.md diff --git a/binding/php_extension/php7/ip2region/php_ip2region.h b/binding/php_ext/php7/ip2region/php_ip2region.h similarity index 100% rename from binding/php_extension/php7/ip2region/php_ip2region.h rename to binding/php_ext/php7/ip2region/php_ip2region.h diff --git a/binding/php_extension/php7/ip2region/tests/001.phpt b/binding/php_ext/php7/ip2region/tests/001.phpt similarity index 100% rename from binding/php_extension/php7/ip2region/tests/001.phpt rename to binding/php_ext/php7/ip2region/tests/001.phpt diff --git a/binding/rust/readme.md b/binding/rust/readme.md index 700624c..d7af656 100644 --- a/binding/rust/readme.md +++ b/binding/rust/readme.md @@ -28,7 +28,7 @@ version = "*" 取消上面 toml 的 `# features = ["lazy"]` 行的注释即可使用,其 api 是 `memory_search` 和 `memory_search_ip`。 -只是目前 DB 足有3.2M,还是有些感人的。 +只是目前 DB 只有3.2M,还是有些感人的。 关键的一行是 `features = ["lazy"]` ,不需要则可以注释或者删掉。 From c4f3ebfef8a58ce7332db599a22e97f235ea3c22 Mon Sep 17 00:00:00 2001 From: lionsoul Date: Fri, 21 Feb 2020 13:45:42 +0800 Subject: [PATCH 04/11] Optimize the DOC --- README.md | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 561af19..6427eb3 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ip2region - 准确率99.9%的离线IP地址定位库,0.0x毫秒级查询,ip2 -# Ip2region核心特性 +# Ip2region特性 ### 99.9%准确率 @@ -19,7 +19,7 @@ ip2region的数据聚合自以下服务商的开放API或者数据(升级程序 ### 标准化的数据格式 -每条ip数据段都固定了格式:] +每条ip数据段都固定了格式: ``` _城市Id|国家|区域|省份|城市|ISP_ ``` @@ -45,25 +45,23 @@ _城市Id|国家|区域|省份|城市|ISP_ ### 多查询客户端的支持 -已经集成的客户端有:java、C#、php、c、python、nodejs、php扩展(php5和php7)、golang、rust、lua、lua_c。 +已经集成的客户端有:java、C#、php、c、python、nodejs、php扩展(php5和php7)、golang、rust、lua、lua_c, nginx。 - -##### 已有的binding -适用语言 | 开发语言 | 开发状态 | binary查询耗时 | b-tree查询耗时 | memory查询耗时 - :-: | :-: | :-: | :-: | :-: | :-: - [c](binding/c) | c | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 - [c#](binding/c#) | c# | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 - [golang](binding/golang) | golang | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 - [java](binding/java) | java | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 - [lua](binding/lua) | lua | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 - [lua](binding/lua_c) | c | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 - [nginx](binding/nginx) | c | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 - [nodejs](binding/nodejs) | nodejs | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 - [php](binding/php) | php | 已完成 | 0.x毫秒 | 0.1x毫秒 | 0.1x毫秒 - [php](binding/c) | c | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 - [php](binding/c) | c | 已完成 | 0.0毫秒 | 0.0x毫秒 | 0.00x毫秒 - [python](binding/c) | python | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 - [rust](binding/c) | rust | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 +语言 | 描述 | 开发状态 | binary查询耗时 | b-tree查询耗时 | memory查询耗时 +:-: | :-: | :-: | :-: | :-: | :-: +[c](binding/c) | ANSC c | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 +[c#](binding/c#) | c# | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 +[golang](binding/golang) | golang | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 +[java](binding/java) | java | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 +[lua](binding/lua) | lua | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 +[lua](binding/lua_c) | lua c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 +[nginx](binding/nginx) | nginx c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 +[nodejs](binding/nodejs) | nodejs | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 +[php](binding/php) | php | 已完成 | 0.x毫秒 | 0.1x毫秒 | 0.1x毫秒 +[php](binding/php_ext/php5) | php c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 +[php](binding/php_ext/php7) | php c扩展 | 已完成 | 0.0毫秒 | 0.0x毫秒 | 0.00x毫秒 +[python](binding/c) | python | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 +[rust](binding/c) | rust | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 @@ -173,4 +171,3 @@ ip2region重点在于研究IP数据的存储设计和各种语言的查询实 ### 技术交流 1. 数据库文件的结构和原理请阅读 @冬芽 的blog:[“ip2region数据库文件的结构和原理”](http://dongyado.com/tool/2016/08/18/structure-of-ip2region-database-file/) 2. ip2region交流分享,微信:lionsoul2014(请备注ip2region),QQ:1187582057(很少关注) - From f0d1140bba05437107edf3db8bfc53f80d693e98 Mon Sep 17 00:00:00 2001 From: lionsoul Date: Fri, 21 Feb 2020 13:49:25 +0800 Subject: [PATCH 05/11] Optimize the README DOC --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6427eb3..499950b 100644 --- a/README.md +++ b/README.md @@ -47,21 +47,21 @@ _城市Id|国家|区域|省份|城市|ISP_ 已经集成的客户端有:java、C#、php、c、python、nodejs、php扩展(php5和php7)、golang、rust、lua、lua_c, nginx。 -语言 | 描述 | 开发状态 | binary查询耗时 | b-tree查询耗时 | memory查询耗时 +binding | 描述 | 开发状态 | binary查询耗时 | b-tree查询耗时 | memory查询耗时 :-: | :-: | :-: | :-: | :-: | :-: -[c](binding/c) | ANSC c | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 -[c#](binding/c#) | c# | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 -[golang](binding/golang) | golang | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 -[java](binding/java) | java | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 -[lua](binding/lua) | lua | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 -[lua](binding/lua_c) | lua c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 -[nginx](binding/nginx) | nginx c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 +[c](binding/c) | ANSC c binding | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 +[c#](binding/c#) | c# binding | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 +[golang](binding/golang) | golang binding | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 +[java](binding/java) | java binding | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 +[lua](binding/lua) | lua实现的binding | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 +[lua_c](binding/lua_c) | lua的c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 +[nginx](binding/nginx) | nginx的c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 [nodejs](binding/nodejs) | nodejs | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 -[php](binding/php) | php | 已完成 | 0.x毫秒 | 0.1x毫秒 | 0.1x毫秒 -[php](binding/php_ext/php5) | php c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 -[php](binding/php_ext/php7) | php c扩展 | 已完成 | 0.0毫秒 | 0.0x毫秒 | 0.00x毫秒 -[python](binding/c) | python | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 -[rust](binding/c) | rust | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 +[php](binding/php) | php实现的binding | 已完成 | 0.x毫秒 | 0.1x毫秒 | 0.1x毫秒 +[php5_ext](binding/php_ext/php5) | php5的c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 +[php7_ext](binding/php_ext/php7) | php7的c扩展 | 已完成 | 0.0毫秒 | 0.0x毫秒 | 0.00x毫秒 +[python](binding/c) | python bindng | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 +[rust](binding/c) | rust binding | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 From b546335bd1da9e53abce614e422bdacfb893b0d4 Mon Sep 17 00:00:00 2001 From: lionsoul Date: Fri, 21 Feb 2020 13:50:55 +0800 Subject: [PATCH 06/11] Optimize the installation DOC --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 499950b..b2d1b70 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ p2region>> 101.105.35.57 # ip2region安装 -具体请参考每个binding下的README文档,以下是一些可用的快捷安装方式: +具体请参考每个binding下的README文档和测试demo,以下是一些可用的快捷安装方式: ### maven仓库地址 ```xml From 89b80ef3108aa6bd0daf70a224f689b570d06a20 Mon Sep 17 00:00:00 2001 From: lionsoul Date: Fri, 21 Feb 2020 13:56:26 +0800 Subject: [PATCH 07/11] Optimize the installation DOC and rename the php ext binding name --- README.md | 4 ++-- binding/{php_ext/php5/ip2region => php5_ext}/.gitignore | 0 binding/{php_ext/php5/ip2region => php5_ext}/CREDITS | 0 binding/{php_ext/php5/ip2region => php5_ext}/README.md | 2 +- binding/{php_ext/php5/ip2region => php5_ext}/config.m4 | 0 binding/{php_ext/php5/ip2region => php5_ext}/config.w32 | 0 binding/{php_ext/php5/ip2region => php5_ext}/ip2region.c | 0 binding/{php_ext/php5/ip2region => php5_ext}/ip2region.php | 0 binding/{php_ext/php5/ip2region => php5_ext}/lib/README.md | 0 binding/{php_ext/php5/ip2region => php5_ext}/php_ip2region.h | 0 binding/{php_ext/php5/ip2region => php5_ext}/tests/001.phpt | 0 binding/{php_ext/php7/ip2region => php7_ext}/.gitignore | 0 binding/{php_ext/php7/ip2region => php7_ext}/CREDITS | 0 binding/{php_ext/php7/ip2region => php7_ext}/README.md | 2 +- binding/{php_ext/php7/ip2region => php7_ext}/config.m4 | 0 binding/{php_ext/php7/ip2region => php7_ext}/config.w32 | 0 binding/{php_ext/php7/ip2region => php7_ext}/ip2region.c | 0 binding/{php_ext/php7/ip2region => php7_ext}/ip2region.php | 0 binding/{php_ext/php7/ip2region => php7_ext}/lib/README.md | 0 binding/{php_ext/php7/ip2region => php7_ext}/php_ip2region.h | 0 binding/{php_ext/php7/ip2region => php7_ext}/tests/001.phpt | 0 21 files changed, 4 insertions(+), 4 deletions(-) rename binding/{php_ext/php5/ip2region => php5_ext}/.gitignore (100%) rename binding/{php_ext/php5/ip2region => php5_ext}/CREDITS (100%) rename binding/{php_ext/php5/ip2region => php5_ext}/README.md (86%) rename binding/{php_ext/php5/ip2region => php5_ext}/config.m4 (100%) rename binding/{php_ext/php5/ip2region => php5_ext}/config.w32 (100%) rename binding/{php_ext/php5/ip2region => php5_ext}/ip2region.c (100%) rename binding/{php_ext/php5/ip2region => php5_ext}/ip2region.php (100%) rename binding/{php_ext/php5/ip2region => php5_ext}/lib/README.md (100%) rename binding/{php_ext/php5/ip2region => php5_ext}/php_ip2region.h (100%) rename binding/{php_ext/php5/ip2region => php5_ext}/tests/001.phpt (100%) rename binding/{php_ext/php7/ip2region => php7_ext}/.gitignore (100%) rename binding/{php_ext/php7/ip2region => php7_ext}/CREDITS (100%) rename binding/{php_ext/php7/ip2region => php7_ext}/README.md (86%) rename binding/{php_ext/php7/ip2region => php7_ext}/config.m4 (100%) rename binding/{php_ext/php7/ip2region => php7_ext}/config.w32 (100%) rename binding/{php_ext/php7/ip2region => php7_ext}/ip2region.c (100%) rename binding/{php_ext/php7/ip2region => php7_ext}/ip2region.php (100%) rename binding/{php_ext/php7/ip2region => php7_ext}/lib/README.md (100%) rename binding/{php_ext/php7/ip2region => php7_ext}/php_ip2region.h (100%) rename binding/{php_ext/php7/ip2region => php7_ext}/tests/001.phpt (100%) diff --git a/README.md b/README.md index b2d1b70..14eddfd 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@ binding | 描述 | 开发状态 | binary查询耗时 | b-tree查询耗时 | memo [php](binding/php) | php实现的binding | 已完成 | 0.x毫秒 | 0.1x毫秒 | 0.1x毫秒 [php5_ext](binding/php_ext/php5) | php5的c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 [php7_ext](binding/php_ext/php7) | php7的c扩展 | 已完成 | 0.0毫秒 | 0.0x毫秒 | 0.00x毫秒 -[python](binding/c) | python bindng | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 -[rust](binding/c) | rust binding | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 +[python](binding/python) | python bindng | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 +[rust](binding/rust) | rust binding | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 diff --git a/binding/php_ext/php5/ip2region/.gitignore b/binding/php5_ext/.gitignore similarity index 100% rename from binding/php_ext/php5/ip2region/.gitignore rename to binding/php5_ext/.gitignore diff --git a/binding/php_ext/php5/ip2region/CREDITS b/binding/php5_ext/CREDITS similarity index 100% rename from binding/php_ext/php5/ip2region/CREDITS rename to binding/php5_ext/CREDITS diff --git a/binding/php_ext/php5/ip2region/README.md b/binding/php5_ext/README.md similarity index 86% rename from binding/php_ext/php5/ip2region/README.md rename to binding/php5_ext/README.md index d2380cd..decbcd1 100644 --- a/binding/php_ext/php5/ip2region/README.md +++ b/binding/php5_ext/README.md @@ -3,7 +3,7 @@ ### 安装步骤 * git clone https://github.com/lionsoul2014/ip2region.git * cd ip2region -* cp binding/php_extension/php5/ip2region 到 php source code 的 ext 目录下 +* cp binding/php5_ext 到 php source code 的 ext/ip2region 目录下 * cp binding/c/ 里面所有的文件到 php source code 的 ext/ip2region/lib 目录下 * 在 ext/ip2region 下,运行 diff --git a/binding/php_ext/php5/ip2region/config.m4 b/binding/php5_ext/config.m4 similarity index 100% rename from binding/php_ext/php5/ip2region/config.m4 rename to binding/php5_ext/config.m4 diff --git a/binding/php_ext/php5/ip2region/config.w32 b/binding/php5_ext/config.w32 similarity index 100% rename from binding/php_ext/php5/ip2region/config.w32 rename to binding/php5_ext/config.w32 diff --git a/binding/php_ext/php5/ip2region/ip2region.c b/binding/php5_ext/ip2region.c similarity index 100% rename from binding/php_ext/php5/ip2region/ip2region.c rename to binding/php5_ext/ip2region.c diff --git a/binding/php_ext/php5/ip2region/ip2region.php b/binding/php5_ext/ip2region.php similarity index 100% rename from binding/php_ext/php5/ip2region/ip2region.php rename to binding/php5_ext/ip2region.php diff --git a/binding/php_ext/php5/ip2region/lib/README.md b/binding/php5_ext/lib/README.md similarity index 100% rename from binding/php_ext/php5/ip2region/lib/README.md rename to binding/php5_ext/lib/README.md diff --git a/binding/php_ext/php5/ip2region/php_ip2region.h b/binding/php5_ext/php_ip2region.h similarity index 100% rename from binding/php_ext/php5/ip2region/php_ip2region.h rename to binding/php5_ext/php_ip2region.h diff --git a/binding/php_ext/php5/ip2region/tests/001.phpt b/binding/php5_ext/tests/001.phpt similarity index 100% rename from binding/php_ext/php5/ip2region/tests/001.phpt rename to binding/php5_ext/tests/001.phpt diff --git a/binding/php_ext/php7/ip2region/.gitignore b/binding/php7_ext/.gitignore similarity index 100% rename from binding/php_ext/php7/ip2region/.gitignore rename to binding/php7_ext/.gitignore diff --git a/binding/php_ext/php7/ip2region/CREDITS b/binding/php7_ext/CREDITS similarity index 100% rename from binding/php_ext/php7/ip2region/CREDITS rename to binding/php7_ext/CREDITS diff --git a/binding/php_ext/php7/ip2region/README.md b/binding/php7_ext/README.md similarity index 86% rename from binding/php_ext/php7/ip2region/README.md rename to binding/php7_ext/README.md index 32764e4..4b73ef1 100644 --- a/binding/php_ext/php7/ip2region/README.md +++ b/binding/php7_ext/README.md @@ -3,7 +3,7 @@ ### 安装步骤 * git clone https://github.com/lionsoul2014/ip2region.git * cd ip2region -* cp binding/php_extension/php7/ip2region 到 php source code 的 ext 目录下 +* cp binding/php7_ext 到 php source code 的 ext/ip2region 目录下 * cp binding/c/ 里面所有的文件到 php source code 的 ext/ip2region/lib 目录下 * 在 ext/ip2region 下,运行 diff --git a/binding/php_ext/php7/ip2region/config.m4 b/binding/php7_ext/config.m4 similarity index 100% rename from binding/php_ext/php7/ip2region/config.m4 rename to binding/php7_ext/config.m4 diff --git a/binding/php_ext/php7/ip2region/config.w32 b/binding/php7_ext/config.w32 similarity index 100% rename from binding/php_ext/php7/ip2region/config.w32 rename to binding/php7_ext/config.w32 diff --git a/binding/php_ext/php7/ip2region/ip2region.c b/binding/php7_ext/ip2region.c similarity index 100% rename from binding/php_ext/php7/ip2region/ip2region.c rename to binding/php7_ext/ip2region.c diff --git a/binding/php_ext/php7/ip2region/ip2region.php b/binding/php7_ext/ip2region.php similarity index 100% rename from binding/php_ext/php7/ip2region/ip2region.php rename to binding/php7_ext/ip2region.php diff --git a/binding/php_ext/php7/ip2region/lib/README.md b/binding/php7_ext/lib/README.md similarity index 100% rename from binding/php_ext/php7/ip2region/lib/README.md rename to binding/php7_ext/lib/README.md diff --git a/binding/php_ext/php7/ip2region/php_ip2region.h b/binding/php7_ext/php_ip2region.h similarity index 100% rename from binding/php_ext/php7/ip2region/php_ip2region.h rename to binding/php7_ext/php_ip2region.h diff --git a/binding/php_ext/php7/ip2region/tests/001.phpt b/binding/php7_ext/tests/001.phpt similarity index 100% rename from binding/php_ext/php7/ip2region/tests/001.phpt rename to binding/php7_ext/tests/001.phpt From ceb31be88b665e4df65cae44b73bb8180923f3e1 Mon Sep 17 00:00:00 2001 From: lionsoul Date: Fri, 21 Feb 2020 13:56:56 +0800 Subject: [PATCH 08/11] Update the link for the php ext --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 14eddfd..3bf5ade 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ binding | 描述 | 开发状态 | binary查询耗时 | b-tree查询耗时 | memo [nginx](binding/nginx) | nginx的c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 [nodejs](binding/nodejs) | nodejs | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.1x毫秒 [php](binding/php) | php实现的binding | 已完成 | 0.x毫秒 | 0.1x毫秒 | 0.1x毫秒 -[php5_ext](binding/php_ext/php5) | php5的c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 -[php7_ext](binding/php_ext/php7) | php7的c扩展 | 已完成 | 0.0毫秒 | 0.0x毫秒 | 0.00x毫秒 +[php5_ext](binding/php5_ext) | php5的c扩展 | 已完成 | 0.0x毫秒 | 0.0x毫秒 | 0.00x毫秒 +[php7_ext](binding/php7_ext) | php7的c扩展 | 已完成 | 0.0毫秒 | 0.0x毫秒 | 0.00x毫秒 [python](binding/python) | python bindng | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 [rust](binding/rust) | rust binding | 已完成 | 0.x毫秒 | 0.x毫秒 | 0.x毫秒 From ce11dc76d9074368a9467df96d98eb3e38e1de79 Mon Sep 17 00:00:00 2001 From: dongyado Date: Mon, 16 Mar 2020 14:28:17 +0800 Subject: [PATCH 09/11] update db structure intro file link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3bf5ade..6f9b695 100644 --- a/README.md +++ b/README.md @@ -169,5 +169,5 @@ java -jar dbMaker-1.2.2.jar -src ./data/ip.merge.txt -region ./data/global_regio ip2region重点在于研究IP数据的存储设计和各种语言的查询实现,并没有原始IP数据的支撑,数据来源请参考上面的描述,升级数据需要很多IP的支撑并且会对原始平台造成一定量的请求压力,本项目不保证及时的数据更新,没有也不会有商用版本,你可以使用自定义的数据导入ip2region进行自定义查询的实现。 ### 技术交流 -1. 数据库文件的结构和原理请阅读 @冬芽 的blog:[“ip2region数据库文件的结构和原理”](http://dongyado.com/tool/2016/08/18/structure-of-ip2region-database-file/) +1. 数据库文件的结构和原理请阅读 @冬芽 的blog:[“ip2region数据库文件的结构和原理”](https://github.com/dongyado/dongyado.github.io/blob/master/_posts/2016-08-18-structure-of-ip2region-database-file.md) 2. ip2region交流分享,微信:lionsoul2014(请备注ip2region),QQ:1187582057(很少关注) From fc80149d82011c642b741ab5cf8fbf9d33023e74 Mon Sep 17 00:00:00 2001 From: PHP Static Date: Sun, 22 Mar 2020 11:38:21 +0800 Subject: [PATCH 10/11] fix memory leak and symbol duplicate --- binding/php5_ext/ip2region.c | 6 +++--- binding/php5_ext/php_ip2region.h | 1 - binding/php7_ext/ip2region.c | 8 ++++---- binding/php7_ext/php_ip2region.h | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/binding/php5_ext/ip2region.c b/binding/php5_ext/ip2region.c index 7139f3b..dc1d7f8 100644 --- a/binding/php5_ext/ip2region.c +++ b/binding/php5_ext/ip2region.c @@ -182,7 +182,7 @@ PHP_METHOD(ip2region_class_entry_ptr, binarySearch) PHP_MSHUTDOWN_FUNCTION(ip2region) { UNREGISTER_INI_ENTRIES(); - ip2region_destroy(&g_resource); + if(g_resource_ptr != NULL) ip2region_destroy(&g_resource); return SUCCESS; } /* }}} */ @@ -256,8 +256,8 @@ PHP_MINIT_FUNCTION(ip2region) ZEND_INIT_MODULE_GLOBALS(ip2region, php_ip2region_init_globals, NULL); REGISTER_INI_ENTRIES(); - - if (ip2region_create( &g_resource, IP2REGION_G(db_file)) == 0) + char* _db_file = IP2REGION_G(db_file); + if ( _db_file == NULL || ip2region_create( &g_resource, _db_file) == 0) { g_resource_ptr = NULL; } else { diff --git a/binding/php5_ext/php_ip2region.h b/binding/php5_ext/php_ip2region.h index 3ff128b..e2be7cc 100644 --- a/binding/php5_ext/php_ip2region.h +++ b/binding/php5_ext/php_ip2region.h @@ -65,7 +65,6 @@ static void php_ip2region_init_globals(zend_ip2region_globals *); #define le_ip2region_name "Ip2region" -void search( ip2region_t, uint_t (*func_ptr) (ip2region_t, uint_t, datablock_t), long , zval **, datablock_t); #endif /* PHP_IP2REGION_H */ /* diff --git a/binding/php7_ext/ip2region.c b/binding/php7_ext/ip2region.c index 6b6e121..1f7f062 100644 --- a/binding/php7_ext/ip2region.c +++ b/binding/php7_ext/ip2region.c @@ -50,7 +50,7 @@ static zend_class_entry *ip2region_class_entry_ptr; //} -void search( +static void search( ip2region_t g_resouce_ptr, uint_t (*func_ptr) (ip2region_t, uint_t, datablock_t), long ip, @@ -188,7 +188,7 @@ PHP_METHOD(ip2region_class_entry_ptr, binarySearch) PHP_MSHUTDOWN_FUNCTION(ip2region) { UNREGISTER_INI_ENTRIES(); - ip2region_destroy(&g_resource); + if( g_resource_ptr != NULL ) ip2region_destroy(&g_resource); return SUCCESS; } /* }}} */ @@ -262,8 +262,8 @@ PHP_MINIT_FUNCTION(ip2region) ZEND_INIT_MODULE_GLOBALS(ip2region, php_ip2region_init_globals, NULL); REGISTER_INI_ENTRIES(); - - if (ip2region_create( &g_resource, IP2REGION_G(db_file)) == 0) + char* _db_file = IP2REGION_G(db_file); + if ( _db_file == NULL || ip2region_create( &g_resource, _db_file) == 0) { g_resource_ptr = NULL; } else { diff --git a/binding/php7_ext/php_ip2region.h b/binding/php7_ext/php_ip2region.h index 3ff128b..e2be7cc 100644 --- a/binding/php7_ext/php_ip2region.h +++ b/binding/php7_ext/php_ip2region.h @@ -65,7 +65,6 @@ static void php_ip2region_init_globals(zend_ip2region_globals *); #define le_ip2region_name "Ip2region" -void search( ip2region_t, uint_t (*func_ptr) (ip2region_t, uint_t, datablock_t), long , zval **, datablock_t); #endif /* PHP_IP2REGION_H */ /* From 5ea194bb2271b17f3f0a5a05141975e4dace34d2 Mon Sep 17 00:00:00 2001 From: PHP Static Date: Sun, 22 Mar 2020 11:43:46 +0800 Subject: [PATCH 11/11] fix php5 symbol duplicate --- binding/php5_ext/ip2region.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/binding/php5_ext/ip2region.c b/binding/php5_ext/ip2region.c index dc1d7f8..bb7a2d6 100644 --- a/binding/php5_ext/ip2region.c +++ b/binding/php5_ext/ip2region.c @@ -50,7 +50,7 @@ static zend_class_entry *ip2region_class_entry_ptr; //} -void search( +static void search( ip2region_t g_resouce_ptr, uint_t (*func_ptr) (ip2region_t, uint_t, datablock_t), long ip,