From df7a7ffd2b6eaee9fa0c66733c9811dba6c419c6 Mon Sep 17 00:00:00 2001 From: Ycarus Date: Sat, 26 Jan 2019 13:50:03 +0100 Subject: [PATCH] No error if ndpi is not loaded --- .../luasrc/model/cbi/omr-bypass.lua | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/luci-app-omr-bypass/luasrc/model/cbi/omr-bypass.lua b/luci-app-omr-bypass/luasrc/model/cbi/omr-bypass.lua index b8d78b639..4fdd4ccbd 100644 --- a/luci-app-omr-bypass/luasrc/model/cbi/omr-bypass.lua +++ b/luci-app-omr-bypass/luasrc/model/cbi/omr-bypass.lua @@ -1,4 +1,4 @@ --- Copyright 2018 Ycarus (Yannick Chabanois) +-- Copyright 2018-2019 Ycarus (Yannick Chabanois) -- Licensed to the public under the Apache License 2.0. local ipc = require "luci.ip" @@ -86,16 +86,19 @@ s.template = "cbi/tblsection" dpi = s:option(Value, "proto", translate("Protocol")) dpi.rmempty = true dpi.optional = false -local protos = {} -for l in io.lines("/proc/net/xt_ndpi/proto") do - local a,b,c,d = l:match('(%w+) (%w+)') - if b ~= "2" and not string.match(b,"custom") then - table.insert(protos,b) +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+)') + if b ~= "2" and not string.match(b,"custom") then + table.insert(protos,b) + end + end + table.sort(protos) + for _,b in ipairs(protos) do + dpi:value(b,"%s" % tostring(b)) end -end -table.sort(protos) -for _,b in ipairs(protos) do - dpi:value(b,"%s" % tostring(b)) end ifp = s:option(ListValue, "interface", translate("Interface"))