luci-app-mwan3: remove duplicated code section
[project/luci.git] / applications / luci-app-mwan3 / luasrc / controller / mwan3.lua
index cf57080..64ee9f5 100644 (file)
@@ -1,3 +1,7 @@
+-- Copyright 2014 Aedan Renner <chipdankly@gmail.com>
+-- Copyright 2018 Florian Eckert <fe@dev.tdt.de>
+-- Licensed to the public under the GNU General Public License v2.
+
 module("luci.controller.mwan3", package.seeall)
 
 sys = require "luci.sys"
@@ -111,11 +115,11 @@ function diagnosticsData(interface, task)
        function get_gateway(inteface)
                local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
                local gateway
-               if dump then
+               if dump and dump.route then
                        local _, route
                        for _, route in ipairs(dump.route) do
                                if dump.route[_].target == "0.0.0.0" then
-                                       gateway =  dump.route[_].nexthop
+                                       gateway = dump.route[_].nexthop
                                end
                        end
                end