summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-olsr/luasrc/controller
diff options
context:
space:
mode:
authorPatrick Grimm <patrick@lunatiki.de>2013-08-07 20:25:17 +0000
committerPatrick Grimm <patrick@lunatiki.de>2013-08-07 20:25:17 +0000
commitbffccf25c5042a248b26ad7945f7fec59801c82f (patch)
tree46f411a394bfefc993524915a7229b18110c6ee0 /applications/luci-olsr/luasrc/controller
parenta394b4f474a6294af56cd688b7049f77fb42b1cd (diff)
luci-olsr: fix ipv6 ipv4 detection
Diffstat (limited to 'applications/luci-olsr/luasrc/controller')
-rw-r--r--applications/luci-olsr/luasrc/controller/olsr.lua33
1 files changed, 20 insertions, 13 deletions
diff --git a/applications/luci-olsr/luasrc/controller/olsr.lua b/applications/luci-olsr/luasrc/controller/olsr.lua
index 94240dac16..cf3743f46a 100644
--- a/applications/luci-olsr/luasrc/controller/olsr.lua
+++ b/applications/luci-olsr/luasrc/controller/olsr.lua
@@ -105,18 +105,18 @@ end
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 = utl.exec("echo /status | nc 127.0.0.1 9090")
- local jsonreq6 = utl.exec("echo /status | nc ::1 9090")
- http.prepare_content("application/json")
-
- if #jsonreq4 < 1 then
- jsonreq4 = "{}"
+ local IpVersion = uci:get_first("olsrd", "olsrd","IpVersion")
+ if IpVersion == "4" or IpVersion == "6and4" then
+ jsonreq4 = utl.exec("echo /status | nc 127.0.0.1 9090")
end
-
- if #jsonreq6 < 1 then
- jsonreq6 = "{}"
+ if IpVersion == "6" or IpVersion == "6and4" then
+ jsonreq6 = utl.exec("echo /status | nc ::1 9090")
end
+ http.prepare_content("application/json")
http.write("{v4:" .. jsonreq4 .. ", v6:" .. jsonreq6 .. "}")
end
@@ -384,9 +384,16 @@ function fetch_jsoninfo(otable)
local uci = require "luci.model.uci".cursor_state()
local utl = require "luci.util"
local json = require "luci.json"
- local jsonreq4 = utl.exec("echo /" .. otable .. " | nc 127.0.0.1 9090")
+ local IpVersion = uci:get_first("olsrd", "olsrd","IpVersion")
+ local jsonreq4 = ""
+ local jsonreq6 = ""
+ if IpVersion == "4" or IpVersion == "6and4" then
+ jsonreq4 = utl.exec("echo /" .. otable .. " | nc 127.0.0.1 9090")
+ end
+ if IpVersion == "6" or IpVersion == "6and4" then
+ jsonreq6 = utl.exec("echo /" .. otable .. " | nc ::1 9090")
+ end
local jsondata4 = {}
- local jsonreq6 = utl.exec("echo /" .. otable .. " | nc ::1 9090")
local jsondata6 = {}
local data4 = {}
local data6 = {}
@@ -398,7 +405,7 @@ function fetch_jsoninfo(otable)
return nil, 0, 0, true
end
- if #jsonreq4 ~= 0 then
+ if jsonreq4 ~= "" then
has_v4 = 1
jsondata4 = json.decode(jsonreq4)
if otable == 'status' then
@@ -412,7 +419,7 @@ function fetch_jsoninfo(otable)
end
end
- if #jsonreq6 ~= 0 then
+ if jsonreq6 ~= "" then
has_v6 = 1
jsondata6 = json.decode(jsonreq6)
if otable == 'status' then