mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-23 17:08:36 +00:00
lua - use pcall with mmdb functions
This commit is contained in:
parent
658ab75049
commit
e62523d1dc
1 changed files with 8 additions and 2 deletions
|
|
@ -317,7 +317,10 @@ utils.get_country = function(ip)
|
|||
if not mmdb.country_db then
|
||||
return false, "mmdb country not loaded"
|
||||
end
|
||||
local result, err = mmdb.country_db:lookup(ip)
|
||||
local ok, result, err = pcall(mmdb.country_db:lookup(ip))
|
||||
if not ok then
|
||||
return nil, result
|
||||
end
|
||||
if not result then
|
||||
return nil, err
|
||||
end
|
||||
|
|
@ -328,7 +331,10 @@ utils.get_asn = function(ip)
|
|||
if not mmdb.asn_db then
|
||||
return false, "mmdb asn not loaded"
|
||||
end
|
||||
local result, err = mmdb.asn_db:lookup(ip)
|
||||
local ok, result, err = pcall(mmdb.asn_db:lookup(ip))
|
||||
if not ok then
|
||||
return nil, result
|
||||
end
|
||||
if not result then
|
||||
return nil, err
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue