projects
/
project
/
luci.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
luci-app-mwan3: pin diag ping command to interface device
[project/luci.git]
/
applications
/
luci-app-mwan3
/
luasrc
/
controller
/
mwan3.lua
diff --git
a/applications/luci-app-mwan3/luasrc/controller/mwan3.lua
b/applications/luci-app-mwan3/luasrc/controller/mwan3.lua
index
d8fba79
..
18c2135
100644
(file)
--- a/
applications/luci-app-mwan3/luasrc/controller/mwan3.lua
+++ b/
applications/luci-app-mwan3/luasrc/controller/mwan3.lua
@@
-85,7
+85,8
@@
function diagnosticsData(interface, task)
function getInterfaceNumber(interface)
local number = 0
local interfaceNumber
function getInterfaceNumber(interface)
local number = 0
local interfaceNumber
- uci.cursor():foreach("mwan3", "interface",
+ local uci = require "luci.model.uci".cursor()
+ uci:foreach("mwan3", "interface",
function (section)
number = number+1
if section[".name"] == interface then
function (section)
number = number+1
if section[".name"] == interface then
@@
-96,9
+97,9
@@
function diagnosticsData(interface, task)
return interfaceNumber
end
return interfaceNumber
end
- function diag_command(cmd, addr)
+ function diag_command(cmd,
device,
addr)
if addr and addr:match("^[a-zA-Z0-9%-%.:_]+$") then
if addr and addr:match("^[a-zA-Z0-9%-%.:_]+$") then
- local util = io.popen(cmd %
ut.shellquote(addr)
)
+ local util = io.popen(cmd %
{ut.shellquote(device), ut.shellquote(addr)}
)
if util then
while true do
local ln = util:read("*l")
if util then
while true do
local ln = util:read("*l")
@@
-113,8
+114,14
@@
function diagnosticsData(interface, task)
end
function get_gateway(inteface)
end
function get_gateway(inteface)
- local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
- local gateway
+ local gateway = nil
+ local dump = nil
+
+ dump = require("luci.util").ubus("network.interface.%s_4" % interface, "status", {})
+ if not dump then
+ dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
+ end
+
if dump and dump.route then
local _, route
for _, route in ipairs(dump.route) do
if dump and dump.route then
local _, route
for _, route in ipairs(dump.route) do
@@
-130,7
+137,7
@@
function diagnosticsData(interface, task)
local results = ""
local number = getInterfaceNumber(interface)
local results = ""
local number = getInterfaceNumber(interface)
- local uci =
uci
.cursor(nil, "/var/state")
+ local uci =
require "luci.model.uci"
.cursor(nil, "/var/state")
local device = uci:get("network", interface, "ifname")
luci.http.prepare_content("text/plain")
local device = uci:get("network", interface, "ifname")
luci.http.prepare_content("text/plain")
@@
-138,7
+145,7
@@
function diagnosticsData(interface, task)
if task == "ping_gateway" then
local gateway = get_gateway(interface)
if gateway ~= nil then
if task == "ping_gateway" then
local gateway = get_gateway(interface)
if gateway ~= nil then
- diag_command("ping -
c 5 -W 1 %s 2>&1"
, gateway)
+ diag_command("ping -
I %s -c 5 -W 1 %s 2>&1", device
, gateway)
else
luci.http.prepare_content("text/plain")
luci.http.write(string.format("No gateway for interface %s found.", interface))
else
luci.http.prepare_content("text/plain")
luci.http.write(string.format("No gateway for interface %s found.", interface))
@@
-147,7
+154,7
@@
function diagnosticsData(interface, task)
local trackips = uci:get("mwan3", interface, "track_ip")
if #trackips > 0 then
for i in pairs(trackips) do
local trackips = uci:get("mwan3", interface, "track_ip")
if #trackips > 0 then
for i in pairs(trackips) do
- diag_command("ping -
c 5 -W 1 %s 2>&1"
, trackips[i])
+ diag_command("ping -
I %s -c 5 -W 1 %s 2>&1", device
, trackips[i])
end
else
luci.http.write(string.format("No tracking Hosts for interface %s defined.", interface))
end
else
luci.http.write(string.format("No tracking Hosts for interface %s defined.", interface))