diff options
author | Jo-Philipp Wich <jo@mein.io> | 2018-09-19 11:36:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-19 11:36:30 +0200 |
commit | 1a0316bbbaad3f6befce34014d7e204cb1c76ec0 (patch) | |
tree | fc0fc433eff96f4be37fed76696c35da8185452a /modules/luci-base | |
parent | 9142a714691dc4f801a238bec3cec5101d374c29 (diff) | |
parent | a13748d4145edd3edc70e462714a115f7c99470e (diff) |
Merge pull request #2140 from kristrev/multiple-upstream-interfaces-status
luci-base: Show multiple upstream interface
Diffstat (limited to 'modules/luci-base')
-rw-r--r-- | modules/luci-base/luasrc/model/network.lua | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/modules/luci-base/luasrc/model/network.lua b/modules/luci-base/luasrc/model/network.lua index cce559aab..7f7397032 100644 --- a/modules/luci-base/luasrc/model/network.lua +++ b/modules/luci-base/luasrc/model/network.lua @@ -813,6 +813,7 @@ function del_wifinet(self, net) end function get_status_by_route(self, addr, mask) + local route_statuses = { } local _, object for _, object in ipairs(utl.ubus()) do local net = object:match("^network%.interface%.(.+)") @@ -822,12 +823,14 @@ function get_status_by_route(self, addr, mask) local rt for _, rt in ipairs(s.route) do if not rt.table and rt.target == addr and rt.mask == mask then - return net, s + route_statuses[net] = s end end end end end + + return route_statuses end function get_status_by_address(self, addr) @@ -856,24 +859,28 @@ function get_status_by_address(self, addr) end end -function get_wannet(self) - local net, stat = self:get_status_by_route("0.0.0.0", 0) - return net and network(net, stat.proto) -end +function get_wan_networks(self) + local k, v + local wan_nets = { } + local route_statuses = self:get_status_by_route("0.0.0.0", 0) -function get_wandev(self) - local _, stat = self:get_status_by_route("0.0.0.0", 0) - return stat and interface(stat.l3_device or stat.device) -end + for k, v in pairs(route_statuses) do + wan_nets[#wan_nets+1] = network(k, v.proto) + end -function get_wan6net(self) - local net, stat = self:get_status_by_route("::", 0) - return net and network(net, stat.proto) + return wan_nets end -function get_wan6dev(self) - local _, stat = self:get_status_by_route("::", 0) - return stat and interface(stat.l3_device or stat.device) +function get_wan6_networks(self) + local k, v + local wan6_nets = { } + local route_statuses = self:get_status_by_route("::", 0) + + for k, v in pairs(route_statuses) do + wan6_nets[#wan6_nets+1] = network(k, v.proto) + end + + return wan6_nets end function get_switch_topologies(self) |