diff options
author | Manuel Munz <freifunk@somakoma.de> | 2010-12-17 03:35:17 +0000 |
---|---|---|
committer | Manuel Munz <freifunk@somakoma.de> | 2010-12-17 03:35:17 +0000 |
commit | 56bff936e759d85cd6de765b1f4cf4f485497ab8 (patch) | |
tree | 0d810345f33960f269eba1f266455e471ea773e1 /modules/freifunk/luasrc/controller | |
parent | 1a2165b0bd10694db696daa79ea1e388ecae4ef2 (diff) |
modules/freifunk: Fix a problem that happened when ipv6 was not enabled by adding checks
Diffstat (limited to 'modules/freifunk/luasrc/controller')
-rw-r--r-- | modules/freifunk/luasrc/controller/freifunk/freifunk.lua | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua index f4f9b97c0d..db4e00c1e6 100644 --- a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua +++ b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua @@ -256,23 +256,33 @@ function public_status_json() membuffers / 1024, tostring(i18n.translate("buffered")) ) - + local dr4 = sys.net.defaultroute() local dr6 = sys.net.defaultroute6() - + + if dr6 then + def6 = { + gateway = dr6.nexthop:string(), + dest = dr6.dest:string(), + dev = dr6.device, + metr = dr6.metric } + end + + if dr4 then + def4 = { + gateway = dr4.gateway:string(), + dest = dr4.dest:string(), + dev = dr4.device, + metr = dr4.metric } + end + rv[#rv+1] = { time = os.date("%c"), uptime = twa.date_format(tonumber(sys.uptime())), load = string.format("%.2f, %.2f, %.2f", load1, load5, load15), mem = mem, - defroutev4 = { gateway = dr4.gateway:string(), - dest = dr4.dest:string(), - dev = dr4.device, - metr = dr4.metric }, - defroutev6 = { gateway = dr6.nexthop:string(), - dest = dr6.dest:string(), - dev = dr6.device, - metr = dr6.metric } + defroutev4 = def4, + defroutev6 = def6 } luci.http.prepare_content("application/json") |