mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-30 07:59:35 +00:00
Initial support for DHCP range configuration
This commit is contained in:
parent
2ac8f4f716
commit
b778e77207
13 changed files with 427 additions and 10 deletions
40
scripts/lua/modules/dhcp_utils.lua
Normal file
40
scripts/lua/modules/dhcp_utils.lua
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
--
|
||||
-- (C) 2017-18 - ntop.org
|
||||
--
|
||||
|
||||
local dhcp_utils = {}
|
||||
|
||||
-- ##############################################
|
||||
|
||||
local function getDhcpRangesKey(ifid)
|
||||
return string.format("ntopng.prefs.ifid_%u.dhcp_ranges", ifid)
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function dhcp_utils.listRanges(ifid)
|
||||
local ranges_str = ntop.getPref(getDhcpRangesKey(ifid))
|
||||
local ranges = string.split(ranges_str, ",") or {ranges_str}
|
||||
local res = {}
|
||||
|
||||
for _, range in ipairs(ranges) do
|
||||
local r = string.split(range, "%-")
|
||||
|
||||
if r and #r == 2 then
|
||||
res[#res + 1] = {r[1], r[2]}
|
||||
end
|
||||
end
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function dhcp_utils.setRanges(ifid, ranges_str)
|
||||
ntop.setPref(getDhcpRangesKey(ifid), ranges_str)
|
||||
interface.reloadDhcpRanges()
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
return dhcp_utils
|
||||
Loading…
Add table
Add a link
Reference in a new issue