Merge pull request #2120 from TDT-AG/pr/20180830-luci-app-mwan3-fixes
luci-app-mwan3: fixes and improvements
This commit is contained in:
commit
0208b957a7
2 changed files with 16 additions and 13 deletions
|
@ -101,6 +101,10 @@ function diagnosticsData(interface, task)
|
||||||
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(device), ut.shellquote(addr)})
|
local util = io.popen(cmd %{ut.shellquote(device), ut.shellquote(addr)})
|
||||||
if util then
|
if util then
|
||||||
|
luci.http.write("Command:\n")
|
||||||
|
luci.http.write(cmd %{ut.shellquote(device),
|
||||||
|
ut.shellquote(addr)} .. "\n\n")
|
||||||
|
luci.http.write("Result:\n")
|
||||||
while true do
|
while true do
|
||||||
local ln = util:read("*l")
|
local ln = util:read("*l")
|
||||||
if not ln then break end
|
if not ln then break end
|
||||||
|
@ -140,7 +144,8 @@ function diagnosticsData(interface, task)
|
||||||
local uci = require "luci.model.uci".cursor(nil, "/var/state")
|
local uci = require "luci.model.uci".cursor(nil, "/var/state")
|
||||||
local nw = require "luci.model.network".init()
|
local nw = require "luci.model.network".init()
|
||||||
local network = nw:get_network(interface)
|
local network = nw:get_network(interface)
|
||||||
local device = network and network:ifname()
|
local device = network and network:get_interface()
|
||||||
|
device = device:name()
|
||||||
|
|
||||||
luci.http.prepare_content("text/plain")
|
luci.http.prepare_content("text/plain")
|
||||||
if device then
|
if device then
|
||||||
|
@ -150,7 +155,7 @@ function diagnosticsData(interface, task)
|
||||||
diag_command("ping -I %s -c 5 -W 1 %s 2>&1", device, gateway)
|
diag_command("ping -I %s -c 5 -W 1 %s 2>&1", device, gateway)
|
||||||
else
|
else
|
||||||
luci.http.prepare_content("text/plain")
|
luci.http.prepare_content("text/plain")
|
||||||
luci.http.write(string.format("No gateway for interface %s found.", interface))
|
luci.http.write(translatef("No gateway for interface %s found.", interface))
|
||||||
end
|
end
|
||||||
elseif task == "ping_trackips" then
|
elseif task == "ping_trackips" then
|
||||||
local trackips = uci:get("mwan3", interface, "track_ip")
|
local trackips = uci:get("mwan3", interface, "track_ip")
|
||||||
|
@ -159,7 +164,7 @@ function diagnosticsData(interface, task)
|
||||||
diag_command("ping -I %s -c 5 -W 1 %s 2>&1", device, trackips[i])
|
diag_command("ping -I %s -c 5 -W 1 %s 2>&1", device, trackips[i])
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
luci.http.write(string.format("No tracking Hosts for interface %s defined.", interface))
|
luci.http.write(translatef("No tracking Hosts for interface %s defined.", interface))
|
||||||
end
|
end
|
||||||
elseif task == "check_rules" then
|
elseif task == "check_rules" then
|
||||||
local number = getInterfaceNumber(interface)
|
local number = getInterfaceNumber(interface)
|
||||||
|
@ -168,30 +173,30 @@ function diagnosticsData(interface, task)
|
||||||
local iif_rule = sys.exec(string.format("ip rule | grep %d", iif))
|
local iif_rule = sys.exec(string.format("ip rule | grep %d", iif))
|
||||||
local fwmark_rule = sys.exec(string.format("ip rule | grep %d", fwmark))
|
local fwmark_rule = sys.exec(string.format("ip rule | grep %d", fwmark))
|
||||||
if iif_rule ~= "" and fwmark_rule ~= "" then
|
if iif_rule ~= "" and fwmark_rule ~= "" then
|
||||||
luci.http.write(string.format("All required IP rules for interface %s found", interface))
|
luci.http.write(translatef("All required IP rules for interface %s found", interface))
|
||||||
luci.http.write("\n")
|
luci.http.write("\n")
|
||||||
luci.http.write(fwmark_rule)
|
luci.http.write(fwmark_rule)
|
||||||
luci.http.write(iif_rule)
|
luci.http.write(iif_rule)
|
||||||
elseif iif_rule == "" and fwmark_rule ~= "" then
|
elseif iif_rule == "" and fwmark_rule ~= "" then
|
||||||
luci.http.write(string.format("Only one IP rules for interface %s found", interface))
|
luci.http.write(translatef("Only one IP rules for interface %s found", interface))
|
||||||
luci.http.write("\n")
|
luci.http.write("\n")
|
||||||
luci.http.write(fwmark_rule)
|
luci.http.write(fwmark_rule)
|
||||||
elseif iif_rule ~= "" and fwmark_rule == "" then
|
elseif iif_rule ~= "" and fwmark_rule == "" then
|
||||||
luci.http.write(string.format("Only one IP rules for interface %s found", interface))
|
luci.http.write(translatef("Only one IP rules for interface %s found", interface))
|
||||||
luci.http.write("\n")
|
luci.http.write("\n")
|
||||||
luci.http.write(iif_rule)
|
luci.http.write(iif_rule)
|
||||||
else
|
else
|
||||||
luci.http.write(string.format("Missing both IP rules for interface %s", interface))
|
luci.http.write(translatef("Missing both IP rules for interface %s", interface))
|
||||||
end
|
end
|
||||||
elseif task == "check_routes" then
|
elseif task == "check_routes" then
|
||||||
local number = getInterfaceNumber(interface)
|
local number = getInterfaceNumber(interface)
|
||||||
local routeTable = sys.exec(string.format("ip route list table %s", number))
|
local routeTable = sys.exec(string.format("ip route list table %s", number))
|
||||||
if routeTable ~= "" then
|
if routeTable ~= "" then
|
||||||
luci.http.write(string.format("Routing table %s for interface %s found", number, interface))
|
luci.http.write(translatef("Routing table %s for interface %s found", number, interface))
|
||||||
luci.http.write("\n")
|
luci.http.write("\n")
|
||||||
luci.http.write(routeTable)
|
luci.http.write(routeTable)
|
||||||
else
|
else
|
||||||
luci.http.write(string.format("Routing table %s for interface %s not found", number, interface))
|
luci.http.write(translatef("Routing table %s for interface %s not found", number, interface))
|
||||||
end
|
end
|
||||||
elseif task == "hotplug_ifup" then
|
elseif task == "hotplug_ifup" then
|
||||||
os.execute(string.format("/usr/sbin/mwan3 ifup %s", ut.shellquote(interface)))
|
os.execute(string.format("/usr/sbin/mwan3 ifup %s", ut.shellquote(interface)))
|
||||||
|
|
|
@ -13,10 +13,8 @@ mwan_interface = m5:section(NamedSection, arg[1], "interface", "")
|
||||||
mwan_interface.addremove = false
|
mwan_interface.addremove = false
|
||||||
mwan_interface.dynamic = false
|
mwan_interface.dynamic = false
|
||||||
|
|
||||||
enabled = mwan_interface:option(ListValue, "enabled", translate("Enabled"))
|
enabled = mwan_interface:option(Flag, "enabled", translate("Enabled"))
|
||||||
enabled.default = "1"
|
enabled.default = false
|
||||||
enabled:value("1", translate("Yes"))
|
|
||||||
enabled:value("0", translate("No"))
|
|
||||||
|
|
||||||
initial_state = mwan_interface:option(ListValue, "initial_state", translate("Initial state"),
|
initial_state = mwan_interface:option(ListValue, "initial_state", translate("Initial state"),
|
||||||
translate("Expect interface state on up event"))
|
translate("Expect interface state on up event"))
|
||||||
|
|
Loading…
Reference in a new issue