summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-olsr/luasrc/controller
diff options
context:
space:
mode:
authorManuel Munz <freifunk@somakoma.de>2013-09-19 16:49:28 +0000
committerManuel Munz <freifunk@somakoma.de>2013-09-19 16:49:28 +0000
commit148b883c110f6ada30b3604cfadeeb8c3fd2432d (patch)
treea8b4555b9e082ebdfea77122cbc8db490f9e4b70 /applications/luci-olsr/luasrc/controller
parent110e0874414652e231048d91be5efd6cdf777f52 (diff)
applications/olsr: Fix invalid json output
Diffstat (limited to 'applications/luci-olsr/luasrc/controller')
-rw-r--r--applications/luci-olsr/luasrc/controller/olsr.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/applications/luci-olsr/luasrc/controller/olsr.lua b/applications/luci-olsr/luasrc/controller/olsr.lua
index 9661318dbd..44849dfcce 100644
--- a/applications/luci-olsr/luasrc/controller/olsr.lua
+++ b/applications/luci-olsr/luasrc/controller/olsr.lua
@@ -106,8 +106,8 @@ function action_json()
local http = require "luci.http"
local utl = require "luci.util"
local uci = require "luci.model.uci".cursor_state()
- local jsonreq4 = ""
- local jsonreq6 = ""
+ local jsonreq4
+ local jsonreq6
local IpVersion = uci:get_first("olsrd", "olsrd","IpVersion")
if IpVersion == "4" or IpVersion == "6and4" then
@@ -117,8 +117,13 @@ function action_json()
jsonreq6 = utl.exec("echo /status | nc ::1 9090")
end
http.prepare_content("application/json")
-
- http.write("{v4:" .. jsonreq4 .. ", v6:" .. jsonreq6 .. "}")
+ if not jsonreq4 or jsonreq4 == "" then
+ jsonreq4 = "{}"
+ end
+ if not jsonreq6 or jsonreq6 == "" then
+ jsonreq6 = "{}"
+ end
+ http.write('{"v4":' .. jsonreq4 .. ', "v6":' .. jsonreq6 .. '}')
end
function action_neigh(json)