lua-cs-bouncer-mcaptcha/lib/utils.lua

8 lines
205 B
Lua
Raw Normal View History

2020-10-07 16:49:14 +02:00
function _M.ipToInt( str )
local num = 0
if str and type(str)=="string" then
local o1,o2,o3,o4 = str:match("(%d+)%.(%d+)%.(%d+)%.(%d+)" )
num = 2^24*o1 + 2^16*o2 + 2^8*o3 + o4
end
return num
end