require the local xdb_searcher.so and fix the bug for err check and print

This commit is contained in:
Lion 2022-07-05 13:47:47 +08:00
parent 9376c56688
commit 785016bc60
3 changed files with 12 additions and 3 deletions

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))