提交 013021c3 编写于 作者: L Lion

Merge branch 'master' into lua_binding

......@@ -39,7 +39,7 @@ API 介绍,使用文档和测试程序请参考对应 `searcher` 查询客户
| [java](binding/java) | java 查询客户端实现 | 已完成 | [Lion](https://github.com/lionsoul2014) |
| [lua](binding/lua) | lua 查询客户端实现 | 开发中... | [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) |
| [python](binding/python) | python 查询客户端实现 | 待开始 | 待确定 |
| [nodejs](binding/nodejs) | nodejs 查询客户端实现 | 待开始 | 待确定 |
......
......@@ -49,7 +49,7 @@ int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
char *db_path = "ip2region.xdb file path";
char *v_index;
xdb_vector_index_t *v_index;
xdb_searcher_t searcher;
char region_buffer[256], ip_buffer[16], *ip = "1.2.3.4";
long s_time;
......@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) {
// 4、关闭 xdb 查询器,如果是要关闭服务,也需要释放 v_index 的内存。
xdb_close(&searcher);
xdb_free(v_index);
xdb_close_vector_index(v_index);
return 0;
}
```
......@@ -98,7 +98,7 @@ int main(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
char *db_path = "ip2region.xdb file path";
char *c_buffer;
xdb_content_t *c_buffer;
xdb_searcher_t searcher;
char region_buffer[256], ip_buffer[16], *ip = "1.2.3.4";
long s_time;
......@@ -132,7 +132,7 @@ int main(int argc, char *argv[]) {
// 4、关闭 xdb 查询器,关闭服务的时候需要释放 c_buffer 的内存。
xdb_close(&searcher);
xdb_free(c_buffer);
xdb_close_content(c_buffer);
return 0;
}
```
......
......@@ -7,7 +7,7 @@
<dependency>
<groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId>
<version>2.6.2</version>
<version>2.6.3</version>
</dependency>
```
......
......@@ -4,7 +4,7 @@
<groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId>
<version>2.6.2</version>
<version>2.6.3</version>
<packaging>jar</packaging>
<name>ip2region</name>
......
......@@ -15,6 +15,7 @@ public class Header {
public final int createdAt;
public final int startIndexPtr;
public final int endIndexPtr;
public final byte[] buffer;
public Header(byte[] buff) {
assert buff.length >= 16;
......@@ -23,6 +24,7 @@ public class Header {
createdAt = Searcher.getInt(buff, 4);
startIndexPtr = Searcher.getInt(buff, 8);
endIndexPtr = Searcher.getInt(buff, 12);
buffer = buff;
}
@Override public String toString() {
......
......@@ -6,6 +6,9 @@
-- @Author Lion <chenxin619315@gmail.com>
-- @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")
function printHelp()
......
......@@ -6,6 +6,9 @@
-- @Author Lion <chenxin619315@gmail.com>
-- @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")
function printHelp()
......
......@@ -6,6 +6,9 @@
-- @Author Lion <chenxin619315@gmail.com>
-- @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")
---- ip checking testing
......@@ -18,9 +21,9 @@ local ip_list = {
local s_time = xdb.now()
for _, ip_src in ipairs(ip_list) do
ip, ok = xdb.check_ip(ip_src)
if ok == false then
print(string.format("invalid ip address `%s`", ip_src))
ip, err = xdb.check_ip(ip_src)
if err ~= nil then
print(string.format("invalid ip address `%s`: %s", ip_src, err))
else
ip_dst = xdb.long2ip(ip)
io.write(string.format("long(%-15s)=%10d, long2ip(%-10d)=%-15s", ip_src, ip, ip, ip_dst))
......
::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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册