mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
No error if ndpi is not loaded
This commit is contained in:
parent
1bf6799321
commit
df7a7ffd2b
1 changed files with 13 additions and 10 deletions
|
@ -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.
|
-- Licensed to the public under the Apache License 2.0.
|
||||||
|
|
||||||
local ipc = require "luci.ip"
|
local ipc = require "luci.ip"
|
||||||
|
@ -86,16 +86,19 @@ s.template = "cbi/tblsection"
|
||||||
dpi = s:option(Value, "proto", translate("Protocol"))
|
dpi = s:option(Value, "proto", translate("Protocol"))
|
||||||
dpi.rmempty = true
|
dpi.rmempty = true
|
||||||
dpi.optional = false
|
dpi.optional = false
|
||||||
local protos = {}
|
local xt_ndpi_available = nixio.fs.access("/proc/net/xt_ndpi/proto")
|
||||||
for l in io.lines("/proc/net/xt_ndpi/proto") do
|
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+)')
|
local a,b,c,d = l:match('(%w+) (%w+)')
|
||||||
if b ~= "2" and not string.match(b,"custom") then
|
if b ~= "2" and not string.match(b,"custom") then
|
||||||
table.insert(protos,b)
|
table.insert(protos,b)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
table.sort(protos)
|
table.sort(protos)
|
||||||
for _,b in ipairs(protos) do
|
for _,b in ipairs(protos) do
|
||||||
dpi:value(b,"%s" % tostring(b))
|
dpi:value(b,"%s" % tostring(b))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ifp = s:option(ListValue, "interface", translate("Interface"))
|
ifp = s:option(ListValue, "interface", translate("Interface"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue