luci-app-qos_gargoyle: fix get_wan

This commit is contained in:
ElonH 2020-02-27 00:19:53 +08:00
parent d50a3495c8
commit 939cdafcf1
No known key found for this signature in database
GPG Key ID: 5BCDD7F78A258D4C
2 changed files with 12 additions and 4 deletions

View File

@ -104,8 +104,9 @@ o = s:option(Value, "ptarget_ip", translate("Use Non-standard Ping Target"),
.. "link will occur in a different segment then you can enter an alternate ping target. Leave "
.. "empty to use the default settings."))
o:depends("qos_monenabled", "true")
local wan = qos.get_wan()
if wan then o:value(wan:gwaddr()) end
-- local wan = qos.get_wan()
-- if wan then o:value(wan:gwaddr()) end
-- TODO: get wan address
o.datatype = "ipaddr"
o = s:option(Value, "pinglimit", translate("Manual Ping Limit"),

View File

@ -26,6 +26,13 @@ function cbi_add_dpi_protocols(field)
end
function get_wan()
local net = require "luci.model.network".init()
return net:get_wannet()
local network = require "luci.model.network".init()
local bundle = network:get_status_by_route("0.0.0.0", 0)
local net, stat
for k, v in pairs(bundle) do
net = k
stat = v
break
end
return net and network:network(net, stat.proto)
end