1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-15 03:51:51 +00:00

No error if ndpi is not loaded

This commit is contained in:
Ycarus 2019-01-26 13:50:03 +01:00
parent 1bf6799321
commit df7a7ffd2b

View file

@ -1,4 +1,4 @@
-- Copyright 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
-- Copyright 2018-2019 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
-- Licensed to the public under the Apache License 2.0.
local ipc = require "luci.ip"
@ -86,6 +86,8 @@ s.template = "cbi/tblsection"
dpi = s:option(Value, "proto", translate("Protocol"))
dpi.rmempty = true
dpi.optional = false
local xt_ndpi_available = nixio.fs.access("/proc/net/xt_ndpi/proto")
if xt_ndpi_available then
local protos = {}
for l in io.lines("/proc/net/xt_ndpi/proto") do
local a,b,c,d = l:match('(%w+) (%w+)')
@ -97,6 +99,7 @@ table.sort(protos)
for _,b in ipairs(protos) do
dpi:value(b,"%s" % tostring(b))
end
end
ifp = s:option(ListValue, "interface", translate("Interface"))
ifp.rmempty = true