Merge branch 'master' into lua_binding

This commit is contained in:
Lion 2022-07-06 10:05:40 +08:00
commit 1aed3ecc46
9 changed files with 39 additions and 10 deletions

View File

@ -39,7 +39,7 @@ API 介绍,使用文档和测试程序请参考对应 `searcher` 查询客户
| [java](binding/java) | java 查询客户端实现 | 已完成 | [Lion](https://github.com/lionsoul2014) | | [java](binding/java) | java 查询客户端实现 | 已完成 | [Lion](https://github.com/lionsoul2014) |
| [lua](binding/lua) | lua 查询客户端实现 | 开发中... | [Lion](https://github.com/lionsoul2014) | | [lua](binding/lua) | lua 查询客户端实现 | 开发中... | [Lion](https://github.com/lionsoul2014) |
| [c](binding/c) | ANSC c 查询客户端实现 | 已完成 | [Lion](https://github.com/lionsoul2014) | | [c](binding/c) | ANSC c 查询客户端实现 | 已完成 | [Lion](https://github.com/lionsoul2014) |
| [lua_c](binding/lua_c) | lua 查询客户端实现 | 开发中... | [Lion](https://github.com/lionsoul2014) | | [lua_c](binding/lua_c) | lua 查询客户端实现 | 已完成 | [Lion](https://github.com/lionsoul2014) |
| [rust](binding/rust) | rust 查询客户端实现 | 开发中... | [Lion](https://github.com/lionsoul2014) | | [rust](binding/rust) | rust 查询客户端实现 | 开发中... | [Lion](https://github.com/lionsoul2014) |
| [python](binding/python) | python 查询客户端实现 | 待开始 | 待确定 | | [python](binding/python) | python 查询客户端实现 | 待开始 | 待确定 |
| [nodejs](binding/nodejs) | nodejs 查询客户端实现 | 待开始 | 待确定 | | [nodejs](binding/nodejs) | nodejs 查询客户端实现 | 待开始 | 待确定 |

View File

@ -49,7 +49,7 @@ int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
char *db_path = "ip2region.xdb file path"; char *db_path = "ip2region.xdb file path";
char *v_index; xdb_vector_index_t *v_index;
xdb_searcher_t searcher; xdb_searcher_t searcher;
char region_buffer[256], ip_buffer[16], *ip = "1.2.3.4"; char region_buffer[256], ip_buffer[16], *ip = "1.2.3.4";
long s_time; long s_time;
@ -84,7 +84,7 @@ int main(int argc, char *argv[]) {
// 4、关闭 xdb 查询器,如果是要关闭服务,也需要释放 v_index 的内存。 // 4、关闭 xdb 查询器,如果是要关闭服务,也需要释放 v_index 的内存。
xdb_close(&searcher); xdb_close(&searcher);
xdb_free(v_index); xdb_close_vector_index(v_index);
return 0; return 0;
} }
``` ```
@ -98,7 +98,7 @@ int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
char *db_path = "ip2region.xdb file path"; char *db_path = "ip2region.xdb file path";
char *c_buffer; xdb_content_t *c_buffer;
xdb_searcher_t searcher; xdb_searcher_t searcher;
char region_buffer[256], ip_buffer[16], *ip = "1.2.3.4"; char region_buffer[256], ip_buffer[16], *ip = "1.2.3.4";
long s_time; long s_time;
@ -132,7 +132,7 @@ int main(int argc, char *argv[]) {
// 4、关闭 xdb 查询器,关闭服务的时候需要释放 c_buffer 的内存。 // 4、关闭 xdb 查询器,关闭服务的时候需要释放 c_buffer 的内存。
xdb_close(&searcher); xdb_close(&searcher);
xdb_free(c_buffer); xdb_close_content(c_buffer);
return 0; return 0;
} }
``` ```

View File

@ -7,7 +7,7 @@
<dependency> <dependency>
<groupId>org.lionsoul</groupId> <groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId> <artifactId>ip2region</artifactId>
<version>2.6.2</version> <version>2.6.3</version>
</dependency> </dependency>
``` ```

View File

@ -4,7 +4,7 @@
<groupId>org.lionsoul</groupId> <groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId> <artifactId>ip2region</artifactId>
<version>2.6.2</version> <version>2.6.3</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>ip2region</name> <name>ip2region</name>

View File

@ -15,6 +15,7 @@ public class Header {
public final int createdAt; public final int createdAt;
public final int startIndexPtr; public final int startIndexPtr;
public final int endIndexPtr; public final int endIndexPtr;
public final byte[] buffer;
public Header(byte[] buff) { public Header(byte[] buff) {
assert buff.length >= 16; assert buff.length >= 16;
@ -23,6 +24,7 @@ public class Header {
createdAt = Searcher.getInt(buff, 4); createdAt = Searcher.getInt(buff, 4);
startIndexPtr = Searcher.getInt(buff, 8); startIndexPtr = Searcher.getInt(buff, 8);
endIndexPtr = Searcher.getInt(buff, 12); endIndexPtr = Searcher.getInt(buff, 12);
buffer = buff;
} }
@Override public String toString() { @Override public String toString() {

View File

@ -6,6 +6,9 @@
-- @Author Lion <chenxin619315@gmail.com> -- @Author Lion <chenxin619315@gmail.com>
-- @Date 2022/06/30 -- @Date 2022/06/30
-- set the package to load the current xdb_searcher.so
package.path = "./?.lua" .. package.path
package.cpath = "./?.so" .. package.cpath
local xdb = require("xdb_searcher") local xdb = require("xdb_searcher")
function printHelp() function printHelp()

View File

@ -6,6 +6,9 @@
-- @Author Lion <chenxin619315@gmail.com> -- @Author Lion <chenxin619315@gmail.com>
-- @Date 2022/06/30 -- @Date 2022/06/30
-- set the package to load the current xdb_searcher.so
package.path = "./?.lua" .. package.path
package.cpath = "./?.so" .. package.cpath
local xdb = require("xdb_searcher") local xdb = require("xdb_searcher")
function printHelp() function printHelp()

View File

@ -6,6 +6,9 @@
-- @Author Lion <chenxin619315@gmail.com> -- @Author Lion <chenxin619315@gmail.com>
-- @Date 2022/06/30 -- @Date 2022/06/30
-- set the package to load the current xdb_searcher.so
package.path = "./?.lua" .. package.path
package.cpath = "./?.so" .. package.cpath
local xdb = require("xdb_searcher") local xdb = require("xdb_searcher")
---- ip checking testing ---- ip checking testing
@ -18,9 +21,9 @@ local ip_list = {
local s_time = xdb.now() local s_time = xdb.now()
for _, ip_src in ipairs(ip_list) do for _, ip_src in ipairs(ip_list) do
ip, ok = xdb.check_ip(ip_src) ip, err = xdb.check_ip(ip_src)
if ok == false then if err ~= nil then
print(string.format("invalid ip address `%s`", ip_src)) print(string.format("invalid ip address `%s`: %s", ip_src, err))
else else
ip_dst = xdb.long2ip(ip) ip_dst = xdb.long2ip(ip)
io.write(string.format("long(%-15s)=%10d, long2ip(%-10d)=%-15s", ip_src, ip, ip, ip_dst)) io.write(string.format("long(%-15s)=%10d, long2ip(%-10d)=%-15s", ip_src, ip, ip, ip_dst))

18
maker/golang/make.bat Normal file
View File

@ -0,0 +1,18 @@
::ip2region golang maker makefile in windows
@echo off
if [%1] == [] goto:build
if %1==clean (
call:clean
) else if %1==build (
call:build
)
exit /b 0
:build
go build -o xdb_maker.exe
exit /b 0
:clean
del/f/s/q xdb_maker.exe