-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime error when IPv6 log client #7
Comments
solution function ipv6toInt ( str )
local o1,o2,o3,o4,o5,o5,o6,o7,o8 = str:match("(%w+):(%w+):(%w+):(%w+):(%w+):(%w+):(%w+):(%w+)" )
print (o1)
local num = 0
if o1 ~= nil then
num=num+2^56*tonumber(o1,16)
end
if o2 ~= nil then
num=num+2^48*tonumber(o2,16)
end
if o3 ~= nil then
num=num+2^40*tonumber(o3,16)
end
if o4 ~= nil then
num=num+2^32*tonumber(o4,16)
end
if o5 ~= nil then
num=num+2^24*tonumber(o5,16)
end
if o6 ~= nil then
num=num+2^16*tonumber(o6,16)
end
if o7 ~= nil then
num=num+2^8*tonumber(o7,16)
end
if o8 ~= nil then
num=num+tonumber(o8,16)
end
return num
end
function ipToInt( str )
local num = 0
if str and type(str)=="string" then
if str:find(".", 4,true) then
local o1,o2,o3,o4 = str:match("(%d+)%.(%d+)%.(%d+)%.(%d+)" )
num = 2^24*o1 + 2^16*o2 + 2^8*o3 + o4
else
num = ipv6toInt (str)
end
end
return num
end
print(ipToInt("2a01:e0a:169:7f90::d73a:9b9d"))
print(ipToInt("0000:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"))
print(ipToInt("0.0.3.0"))
|
thelittlefireman
added a commit
to thelittlefireman/lua-cs-bouncer
that referenced
this issue
Dec 28, 2020
wrong test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi,
I've got a nil issue when bouncer is using a nginx log which contains an ipv6.
original nginx log :
The text was updated successfully, but these errors were encountered: