From bee0d4122d7b80b72f5c86afda6b861d7a9f0622 Mon Sep 17 00:00:00 2001 From: dracoTrier Date: Sun, 1 Mar 2015 21:51:27 +0100 Subject: [PATCH] add legacy-support for Internet Explorer There are still a bunch of Windows Phone or Internet Explorer users out there. This shows an [IE not supported, click here for legacy......] link and adds the old status page for these users. (can also be used by users without IPv6-support. --- .../lib/gluon/status-page/www/cgi-bin/status | 148 ++++++++++++++++++ .../lib/gluon/status-page/www/index.html | 6 + 2 files changed, 154 insertions(+) create mode 100644 gluon/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status diff --git a/gluon/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status b/gluon/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status new file mode 100644 index 0000000..4b6d550 --- /dev/null +++ b/gluon/gluon-status-page/files/lib/gluon/status-page/www/cgi-bin/status @@ -0,0 +1,148 @@ +#!/usr/bin/lua + +local util = require("luci.util") +local fs = require("luci.fs") +local ltn12 = require 'luci.ltn12' +local sys = require("luci.sys") +local json = require("luci.json") +local nixio = require 'nixio' +local platform_info = require("platform_info") + +local hostname = sys.hostname() +local model = platform_info.get_model() +local release = util.trim(fs.readfile("/lib/gluon/release") or "") + +function escape_html(s) + return (s:gsub('&', '&'):gsub('<', '<'):gsub('>', '>'):gsub('"', '"')) +end + +function neighbours(ifname) + local info = util.exec("gluon-neighbour-info -d ff02::2:1001 -p 1001 -r nodeinfo -t 3 -i " .. ifname) + local macs = {} + for _, line in ipairs(util.split(info)) do + local data = json.decode(line) + if data then + if data["network"] and data["network"]["mesh_interfaces"] then + for _, mac in ipairs(data["network"]["mesh_interfaces"]) do + macs[mac] = data + end + end + end + end + + return macs +end + +io.write("Content-type: text/html\n\n") +io.write("\n") +io.write("") +io.write("") +io.write("") +io.write("" .. escape_html(hostname) .. "") +io.write("") +io.write("") + +io.write("

Statusseite (veraltet)

") +io.write("

" .. escape_html(hostname) .. "

") +io.write("
")
+
+io.write("Model: " .. escape_html(model) .. "\n")
+io.write("Firmware release: " .. escape_html(release) .. "\n\n")
+
+io.write(escape_html(util.trim(sys.exec("uptime | sed 's/^ \+//'"))) .. "\n\n")
+io.write(escape_html(sys.exec("ip address show dev br-client")) .. "\n")
+io.write(escape_html(sys.exec("free -m")) .. "\n")
+io.write(escape_html(sys.exec("df /rom /overlay")))
+io.write("
") + +io.write("

Neighbours

") + +local interfaces = util.split(util.trim(util.exec("iw dev | grep IBSS -B 5 | grep Interface | cut -d' ' -f2"))) + +for _, ifname in ipairs(interfaces) do + io.write("

" .. escape_html(ifname) .. "

") + io.write("
")
+
+  io.write(escape_html(sys.exec("iw dev " .. ifname .. " link")) .. "\n")
+
+  for _, line in ipairs(util.split(util.exec("iw dev " .. ifname .. " station dump"))) do
+    local mac = line:match("^Station (.*) %(on ")
+    if mac then
+      io.write("Station " .. mac .. " (on " .. escape_html(ifname) .. ")\n")
+    else
+      io.write(escape_html(line) .. "\n")
+    end
+  end
+
+  io.write("
") +end + +local stat, fastd_status = pcall( + function() + local fastd_sock = nixio.socket('unix', 'stream') + assert(fastd_sock:connect('/var/run/fastd.mesh_vpn.socket')) + + decoder = json.Decoder() + ltn12.pump.all(ltn12.source.file(fastd_sock), decoder:sink()) + return decoder:get() + end +) + +io.write("

VPN status

") +io.write("
")
+
+if stat then
+  io.write(string.format("fastd running for %.3f seconds\n", fastd_status.uptime/1000))
+
+  local peers = 0
+  local connections = 0
+
+  for key, peer in pairs(fastd_status.peers) do
+    peers = peers+1
+
+    if peer.connection then
+      connections = connections+1
+    end
+  end
+
+  io.write(string.format("There are %i peers configured, of which %i are connected:\n\n", peers, connections))
+
+  for key, peer in pairs(fastd_status.peers) do
+    io.write(string.format("%s: ", escape_html(peer.name)))
+
+    if peer.connection then
+      io.write(string.format("connected for %.3f seconds\n", peer.connection.established/1000))
+    else
+      io.write("not connected\n")
+    end
+  end
+
+else
+  io.write("fastd not running")
+end
+
+io.write("
") + +io.write("") +io.write("") +io.write("") diff --git a/gluon/gluon-status-page/files/lib/gluon/status-page/www/index.html b/gluon/gluon-status-page/files/lib/gluon/status-page/www/index.html index 0ce1ca6..8d59a0d 100644 --- a/gluon/gluon-status-page/files/lib/gluon/status-page/www/index.html +++ b/gluon/gluon-status-page/files/lib/gluon/status-page/www/index.html @@ -1,14 +1,20 @@ + + + +