Added user role in About page

Fixed SQL when exploring subnets
Modified preferences to specify that when nDPI RRDs are created, they do for both local hosts and networks
This commit is contained in:
Luca Deri 2015-09-14 14:16:11 +02:00
parent 228c407249
commit 4bf10f4fce
7 changed files with 72 additions and 23 deletions

View file

@ -9,6 +9,30 @@ require "template"
local db_debug = false
--- ====================================================================
function iptonumber(str)
local num = 0
for elem in str:gmatch("%d+") do
num = num * 256 + assert(tonumber(elem))
end
return num
end
function expandIpV4Network(net)
local prefix = net:match("/(.+)")
address = net:gsub("/.+","")
if(prefix == nil) then prefix = 32 end
local num_hosts = 2^(32-prefix)
local addr = iptonumber(address)
return({ addr, addr+num_hosts-1 })
end
--- ====================================================================
function getInterfaceTopFlows(interface_id, version, host, l7proto, l4proto, port, begin_epoch, end_epoch, offset, max_num_flows, sort_column, sort_order)
@ -28,7 +52,9 @@ function getInterfaceTopFlows(interface_id, version, host, l7proto, l4proto, por
if((host ~= nil) and (host ~= "")) then
if(version == 4) then
follow = follow .." AND (IP_SRC_ADDR=INET_ATON('"..host.."') OR IP_DST_ADDR=INET_ATON('"..host.."'))"
rsp = expandIpV4Network(host)
follow = follow .." AND ((IP_SRC_ADDR>="..rsp[1]..") AND (IP_SRC_ADDR <= "..rsp[2].."))"
follow = follow .." OR ((IP_DST_ADDR>="..rsp[1]..") AND (IP_DST_ADDR <= "..rsp[2].."))"
else
follow = follow .." AND (IP_SRC_ADDR='"..host.."' OR IP_DST_ADDR='"..host.."')"
end
@ -38,6 +64,8 @@ function getInterfaceTopFlows(interface_id, version, host, l7proto, l4proto, por
sql = sql .. follow
-- io.write(sql.."\n")
if(db_debug == true) then io.write(sql.."\n") end
res = interface.execSQLQuery(sql)