diff --git a/files/www/cgi-bin/status b/files/www/cgi-bin/status
index f7ae57df..4d8b249c 100755
--- a/files/www/cgi-bin/status
+++ b/files/www/cgi-bin/status
@@ -49,7 +49,8 @@ function mesh_ip_to_hostnames(ip)
if not ip or ip == "" or ip == "none" then
return ""
end
- local pattern = "^" .. ip .. "%s+([%w%-]+)"
+ local pattern = "^" .. ip .. "%s+([%w%-%.]+)"
+ local host = "none"
for line in io.lines("/etc/hosts")
do
local host = line:match(pattern)
@@ -57,35 +58,34 @@ function mesh_ip_to_hostnames(ip)
return host.gsub("%s+", " / ")
end
end
- local hosts = ""
if nixio.fs.stat("/var/run/hosts_olsr.stable") then
for line in io.lines("/var/run/hosts_olsr.stable")
do
local host = line:match(pattern)
if host then
- hosts = hosts .. " / " .. host
+ host = host:gsub("^dtdlink%.","")
+ host = host:gsub("^mid[0-9]*%.","")
+ host = host:gsub("%.local.mesh$","")
+ return host
end
end
end
- return hosts:sub(4, #hosts)
+ return host
end
-function get_default_gw()
- -- a node with a wired default gw will route via this
- local p = io.popen("ip route list table 254")
- if p then
- for line in p:lines()
- do
- local gw = line:match("^default%svia%s([%d%.]+)")
- if gw then
- p:close()
- return gw
- end
- end
- p:close()
+function get_default_gw(iface)
+ -- wan will route via table 254 default gw
+ -- wifi will route via OLSR table 31 default gw
+ local rtable = ""
+ if iface == "wan" then
+ rtable = "ip route list table 254"
+ elseif iface == "wifi" then
+ rtable = "ip route list table 31"
+ else
+ return "none"
end
- -- table 31 is populated by OLSR
- p = io.popen("ip route list table 31")
+
+ local p = io.popen(rtable)
if p then
for line in p:lines()
do
@@ -320,7 +320,8 @@ local cidr = netmask_to_cidr(cursor:get("network", "wifi", "netmask"))
if wifi_disabled then
col1[#col1 + 1] = "
"
end
ip = cursor:get("network", "lan", "ipaddr")
@@ -337,80 +338,97 @@ if remote_ip then
hide_local = true
end
end
-
if ip:match("^10%.") or not hide_local then
cidr = netmask_to_cidr(mask)
- col1[#col1 + 1] = "
LAN address:
" .. ip .. " / " .. cidr .. " "
-end
-
-local wan_iface = aredn.hardware.get_iface_name("wan")
-if not hide_local and wan_iface then
- local ip, bcast, mask = aredn.hardware.get_interface_ip4(wan_iface)
- local wprefix = ""
- local wan_wifi_sig = "none"
- local wan_wifi_noi = "none"
- local wan_wifi_snr = "none"
- if wan_iface:match("^wlan%d+$") then
- wprefix = "wifi "
- local s, n = get_wifi_signal(wan_iface)
- if s ~= "none" and n ~= "none" then
- wan_wifi_sig = s
- wan_wifi_noi = n
- wan_wifi_snr = math.abs(s - n)
- end
- end
- local wan_wifi_ssid
+ local lan_wifi_ssid = "none"
cursor:foreach("wireless", "wifi-iface",
function (section)
- if section.network == "wan" then
- wan_wifi_ssid = section.ssid
+ if section.network == "lan" then
+ lan_wifi_ssid = section.ssid
return false
end
end
)
- if not wan_wifi_ssid then -- if still nil then set default
- wan_wifi_ssid = "none"
- end
-
- if ip then
- cidr = netmask_to_cidr(mask)
- if wprefix == "" then
- col1[#col1 + 1] = "
WAN address: " .. "
" .. ip .. " / " .. cidr .. "
"
- else
- if wan_wifi_ssid ~= "none" and wan_wifi_snr ~= "none" then
- col1[#col1 + 1] = "
"
end
end
-ip = get_default_gw()
-if ip:match("^10%.") or not hide_local then
- col1[#col1 + 1] = "
default gateway:
" .. ip
- if ip:match("^10%.") then
- col1[#col1] = col1[#col1] .. " " .. mesh_ip_to_hostnames(ip) .. ""
+local wan_iface = aredn.hardware.get_iface_name("wan")
+if wan_iface and not hide_local then
+ local ip, bcast, mask = aredn.hardware.get_interface_ip4(wan_iface)
+ if not ip then
+ col1[#col1 + 1] = "
"
+ else
+ local wprefix = ""
+ local wan_wifi_snr = "none"
+ local wan_wifi_ssid
+ if wan_iface:match("^wlan%d+$") then
+ wprefix = "wifi "
+ local s, n = get_wifi_signal(wan_iface)
+ if s ~= "none" and n ~= "none" then
+ wan_wifi_snr = math.abs(s - n)
+ end
+ cursor:foreach("wireless", "wifi-iface",
+ function (section)
+ if section.network == "wan" then
+ wan_wifi_ssid = section.ssid
+ return false
+ end
+ end
+ )
+ if not wan_wifi_ssid then -- if still nil then set default
+ wan_wifi_ssid = "none"
+ end
+ end
+
+ cidr = netmask_to_cidr(mask)
+ wan_gw = get_default_gw("wan")
+ if wprefix == "" then -- no wifi wan
+ if wan_gw:match("^10%.") or not hide_local then
+ if wan_gw:match("^10%.") then
+ col1[#col1 + 1] = "
"
+ end
+ end
+ else -- with wifi wan
+ if wan_wifi_ssid ~= "none" and wan_wifi_snr ~= "none" then
+ if wan_gw:match("^10%.") or not hide_local then
+ if wan_gw:match("^10%.") then
+ col1[#col1 + 1] = "