summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-bmx7/root/usr/lib
diff options
context:
space:
mode:
authorPaul Spooren <mail@aparcar.org>2019-07-06 01:25:07 +0200
committerPaul Spooren <mail@aparcar.org>2019-07-10 17:44:13 +0200
commit9aa507790e8a75ab8f52e267e29059a080d55122 (patch)
tree7c6f6fc8b4a077b3e107aab387697af4147d6d56 /applications/luci-app-bmx7/root/usr/lib
parent69e5488c139f249fcf785d4ba170a90ed0e7f33c (diff)
luci-app-bmx7: transfer from routing
The Makefile is minified as the LuCi build system does most of the job. Signed-off-by: Paul Spooren <mail@aparcar.org>
Diffstat (limited to 'applications/luci-app-bmx7/root/usr/lib')
-rw-r--r--applications/luci-app-bmx7/root/usr/lib/lua/luci/controller/bmx7.lua101
-rw-r--r--applications/luci-app-bmx7/root/usr/lib/lua/luci/view/admin_status/index/bmx7_nodes.htm40
-rw-r--r--applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/nodes_j.htm155
-rw-r--r--applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/status_j.htm130
-rw-r--r--applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/topology.htm54
-rw-r--r--applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/tunnels_j.htm76
6 files changed, 556 insertions, 0 deletions
diff --git a/applications/luci-app-bmx7/root/usr/lib/lua/luci/controller/bmx7.lua b/applications/luci-app-bmx7/root/usr/lib/lua/luci/controller/bmx7.lua
new file mode 100644
index 0000000000..482fb5db51
--- /dev/null
+++ b/applications/luci-app-bmx7/root/usr/lib/lua/luci/controller/bmx7.lua
@@ -0,0 +1,101 @@
+--[[
+ Copyright (C) 2011 Pau Escrich <pau@dabax.net>
+ Contributors Jo-Philipp Wich <xm@subsignal.org>
+ Roger Pueyo Centelles <roger.pueyo@guifi.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ The full GNU General Public License is included in this distribution in
+ the file called "COPYING".
+--]]
+
+module("luci.controller.bmx7", package.seeall)
+
+function index()
+ local place = {}
+ local ucim = require "luci.model.uci"
+ local uci = ucim.cursor()
+
+ -- checking if ignore is on
+ if uci:get("luci-bmx7","luci","ignore") == "1" then
+ return nil
+ end
+
+ -- getting value from uci database
+ local uci_place = uci:get("luci-bmx7","luci","place")
+
+ -- default values
+ if uci_place == nil then
+ place = {"bmx7"}
+ else
+ local util = require "luci.util"
+ place = util.split(uci_place," ")
+ end
+
+ -- getting position of menu
+ local uci_position = uci:get("luci-bmx7","luci","position")
+
+
+ ---------------------------
+ -- Placing the pages in the menu
+ ---------------------------
+
+ -- Status (default)
+ entry(place,call("action_status_j"),place[#place],tonumber(uci_position))
+
+ table.insert(place,"Status")
+ entry(place,call("action_status_j"),"Status",0)
+ table.remove(place)
+
+ -- Topology
+ table.insert(place,"Topology")
+ entry(place,call("topology"),"Topology",1)
+ table.remove(place)
+
+ -- Nodes
+ table.insert(place,"Nodes")
+ entry(place,call("action_nodes_j"),"Nodes",2)
+ table.remove(place)
+
+ -- Tunnels
+ table.insert(place,"Gateways")
+ entry(place,call("action_tunnels_j"),"Gateways",3)
+ table.remove(place)
+
+ -- Integrate bmx7-mdns if present
+ if nixio.fs.stat("/usr/lib/lua/luci/model/cbi/bmx7-mdns.lua","type") ~= nil then
+ table.insert(place,"mDNS")
+ entry(place, cbi("bmx7-mdns"), "mesh DNS", 1).dependent=false
+ table.remove(place)
+ end
+
+end
+
+
+function action_status_j()
+ luci.template.render("bmx7/status_j", {})
+end
+
+function action_tunnels_j()
+ luci.template.render("bmx7/tunnels_j", {})
+end
+
+function topology()
+ luci.template.render("bmx7/topology", {})
+end
+
+function action_nodes_j()
+ luci.template.render("bmx7/nodes_j", {})
+end
diff --git a/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/admin_status/index/bmx7_nodes.htm b/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/admin_status/index/bmx7_nodes.htm
new file mode 100644
index 0000000000..8a6aefaa20
--- /dev/null
+++ b/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/admin_status/index/bmx7_nodes.htm
@@ -0,0 +1,40 @@
+<div class="cbi-map">
+<div class="cbi-section">
+ <legend><%:Bmx7 mesh nodes%></legend>
+ <div class="cbi-section-node">
+ <div class="table" id="nodes_div">
+ <div class="tr table-titles">
+ <div class="th"><%:Name%></div>
+ <div class="th"><%:Short ID%></div>
+ <div class="th"><%:S/s/T/t%></div>
+ <div class="th"><%:Primary IPv6%></div>
+ <div class="th"><%:Via Neighbour%></div>
+ <div class="th"><%:Device%></div>
+ <div class="th"><%:Metric%></div>
+ <div class="th"><%:Last Ref%></div>
+ </div>
+ </div>
+ </div>
+</div>
+</div>
+
+<script type="text/javascript" src="<%=resource%>/bmx7/js/polling.js"></script>
+<script type="text/javascript">//<![CDATA[
+ new TablePooler(10,"/cgi-bin/bmx7-info", {'$originators':''}, "nodes_div", function(st){
+ var originators = st.originators;
+ var res = Array();
+ originators.forEach(function(originator,i){
+ var name = originator.name;
+ var shortId = originator.shortId;
+ var SsTt = originator.S+'/'+originator.s+'/'+originator.T+'/'+originator.t;
+ var primaryIp = originator.primaryIp;
+ var nbName = originator.nbName;
+ var dev = originator.dev;
+ var metric = originator.metric;
+ var lastRef = originator.lastRef;
+ res.push([name, shortId, SsTt, primaryIp,
+ nbName, dev, metric, lastRef]);
+ });
+ return res;
+ });
+//]]></script>
diff --git a/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/nodes_j.htm b/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/nodes_j.htm
new file mode 100644
index 0000000000..a631c93e89
--- /dev/null
+++ b/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/nodes_j.htm
@@ -0,0 +1,155 @@
+<%#
+ Copyright © 2011 Pau Escrich <pau@dabax.net>
+ Contributors Lluis Esquerda <eskerda@gmail.com>
+ Roger Pueyo Centelles <roger.pueyo@guifi.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ The full GNU General Public License is included in this distribution in
+ the file called "COPYING".
+-%>
+
+<%+header%>
+<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
+<script type="text/javascript" src="<%=resource%>/bmx7/js/polling.js"></script>
+
+
+<style>
+ div.hideme{
+ display: none;
+ }
+ div.info{
+ background: #FFF;
+ border: solid 0px;
+ height: 190px;
+ display: block;
+ overflow: auto;
+ }
+ div.inforow{
+ text-align:left;
+ display:inline-block;
+ margin:10px;
+ vertical-align:top;
+ float: left;
+ white-space:nowrap;
+ }
+ div.inforow.newline{
+ clear: both;
+ }
+ u {
+ text-decoration: underline;
+ }
+#extra-info ul { list-style: none outside none; margin-left: 0em; }
+</style>
+
+<div class="cbi-map">
+
+<h2>Mesh nodes</h2>
+<div class="cbi-map-descr"></div>
+<div id="extra-info" class="info">
+ <br />
+ <center>
+ Tip: click the <img src="<%=resource%>/bmx7/world.png" /> icon to see individual node information.
+ </center>
+</div>
+
+
+<div class="cbi-section">
+ <legend><%:Originators%></legend>
+ <div class="cbi-section-node">
+ <div class="table" id="nodes_div">
+ <div class="tr table-titles">
+ <div class="th"></div>
+ <div class="th"><%:Name%></div>
+ <div class="th"><%:Short ID%></div>
+ <div class="th"><%:S/s/T/t%></div>
+ <div class="th"><%:Primary IPv6%></div>
+ <div class="th"><%:Via Neighbour%></div>
+ <div class="th"><%:Metric%></div>
+ <div class="th"><%:Last Desc%></div>
+ <div class="th"><%:Last Ref%></div>
+ <div class="th"><%: %></div>
+ </div>
+ </div>
+ </div>
+</div>
+
+</div>
+
+<script type="text/javascript">//<![CDATA[
+ var displayExtraInfo = function ( id ) {
+ document.getElementById('extra-info').innerHTML = document.getElementById(id).innerHTML;
+ }
+ new TablePooler(5,"/cgi-bin/bmx7-info", {'$originators':''}, "nodes_div", function(st){
+ var infoicon = "<%=resource%>/bmx7/world_small.png";
+ var originators = st.originators;
+ var res = Array();
+ originators.forEach(function(originator,i){
+ var name = originator.name;
+ var shortId = originator.shortId;
+ var nodeId = originator.nodeId;
+ var extensions = originator.name;
+ var SsTt = originator.S+'/'+originator.s+'/'+originator.T+'/'+originator.t;
+ var nodeKey = originator.nodeKey;
+ var descSize = originator.descSize;
+ var primaryIp = originator.primaryIp;
+ var nbName = originator.nbName;
+ var dev = originator.dev;
+ var nbLocalIp = originator.nbLocalIp;
+ var metric = originator.metric;
+ var lastDesc = originator.lastDesc;
+ var lastRef = originator.lastRef;
+
+ var extrainfo = '<a onclick="displayExtraInfo(\'ip-' + i + '\')"><img src="' + infoicon + '" / ></a>';
+ var extrainfo_link = '<a onclick="displayExtraInfo(\'ip-' + i + '\')">' + '<img src="' + infoicon + '" />' + '</a>';
+
+ extrainfo = '<div id="ip-'+ i +'" class="hideme">'
+ + "<div class='inforow'>"
+ + "<h4><u>" + name + '</u></h4>\n'
+ + 'Node ID: ' + shortId + "</div>"
+ + "<div class='inforow'>"
+ + "<h5>Primary IPv6 address</h5>\n"
+ + primaryIp + "</div>\n"
+ + "<div class='inforow'>"
+ + "<h5>Support & Trust</h5>\n"
+ + SsTt + "</div>\n"
+ + "<div class='inforow'>"
+ + "<h5>Node key</h5>\n"
+ + nodeKey + "</div>\n"
+ + "<div class='inforow newline'>"
+ + "<h5>Via neighbour</h5>\n"
+ + nbName + "</div>\n"
+ + "<div class='inforow'>"
+ + "<h5>Via device</h5>\n"
+ + dev + "</div>\n"
+ + "<div class='inforow'>"
+ + "<h5>Via link-local IPv6</h5>\n"
+ + nbLocalIp + "</div>\n"
+ + "<div class='inforow'>"
+ + "<h5>Route metric</h5>\n"
+ + metric + "</div>\n"
+ + "<div class='inforow'>"
+ + "<h5>Desc. size</h5>\n"
+ + descSize + "</div>\n"
+ + "\n</div>";
+
+ res.push([extrainfo_link, name, shortId, SsTt, primaryIp,
+ nbName, metric, lastDesc, lastRef, extrainfo]);
+ });
+ return res;
+ });
+//]]></script>
+
+<%+footer%>
diff --git a/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/status_j.htm b/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/status_j.htm
new file mode 100644
index 0000000000..b7609d7a52
--- /dev/null
+++ b/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/status_j.htm
@@ -0,0 +1,130 @@
+<%+header%>
+<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
+<script type="text/javascript" src="<%=resource%>/bmx7/js/polling.js"></script>
+
+<div class="cbi-map">
+ <center>
+ <img src="<%=resource%>/bmx7/bmx7logo.png" />
+ <br />
+ <br />
+ A mesh routing protocol for Linux devices.<br />
+ Visit <a href="http://bmx6.net">bmx6.net</a> for more information.<br />
+ <br />
+ </center>
+
+<div class="cbi-map-descr"></div>
+
+<div class="cbi-section">
+ <legend><%:Node configuration%></legend>
+ <div class="cbi-section-node">
+ <div class="table" id="config_div">
+ <div class="tr table-titles">
+ <div class="th"><%:Short ID%></div>
+ <div class="th"><%:Node name%></div>
+ <div class="th"><%:Primary IPv6 address%></div>
+ <div class="th"><%:Node key%></div>
+ <div class="th"><%:Short DHash%></div>
+ <div class="th"><%:BMX7 revision%></div>
+ </div>
+ </div>
+ </div>
+</div>
+
+
+<div class="cbi-section">
+ <legend><%:Node status%></legend>
+ <div class="cbi-section-node">
+ <div class="table" id="status_div">
+ <div class="tr table-titles">
+ <div class="th"><%:Nodes seen%></div>
+ <div class="th"><%:Neighbours%></div>
+ <div class="th"><%:Tunnelled IPv6 address%></div>
+ <div class="th"><%:Tunnelled IPv4 address%></div>
+ <div class="th"><%:Uptime%></div>
+ <div class="th"><%:CPU usage%></div>
+ <div class="th"><%:Memory usage%></div>
+ <div class="th"><%:Tx queue%></div>
+ </div>
+ </div>
+ </div>
+</div>
+
+<div class="cbi-section">
+ <legend><%:Network interfaces%></legend>
+ <div class="cbi-section-node">
+ <div class="table" id="ifaces_div">
+ <div class="tr table-titles">
+ <div class="th"><%:Interface%></div>
+ <div class="th"><%:State%></div>
+ <div class="th"><%:Type%></div>
+ <div class="th"><%:Max rate%></div>
+ <div class="th"><%:LinkLocal Ipv6%></div>
+ <div class="th"><%:RX BpP%></div>
+ <div class="th"><%:TX BpP%></div>
+ </div>
+ </div>
+ </div>
+</div>
+
+
+<div class="cbi-section">
+ <legend><%:Links%></legend>
+ <div class="cbi-section-node">
+ <div class="table" id="links_div">
+ <div class="tr table-titles">
+ <div class="th"><%:Short ID%></div>
+ <div class="th"><%:Name%></div>
+ <div class="th"><%:Link key%></div>
+ <div class="th"><%:Remote linklocal IPv6%></div>
+ <div class="th"><%:Device%></div>
+ <div class="th"><%:RX rate%></div>
+ <div class="th"><%:TX rate%></div>
+ <div class="th"><%:Routes%></div>
+ </div>
+ </div>
+ </div>
+</div>
+
+</div>
+
+<script type="text/javascript">//<![CDATA[
+ new TablePooler(1,"/cgi-bin/bmx7-info", {'$info':''}, "config_div", function(st){
+ var res = Array();
+ var sta = st.info[0].status;
+ res.push([sta.shortId, sta.name, sta.primaryIp, sta.nodeKey, sta.shortDhash, sta.revision]);
+ return res;
+ });
+
+ new TablePooler(1,"/cgi-bin/bmx7-info", {'$info':''}, "status_div", function(st){
+ var res = Array();
+ var sta = st.info[0].status;
+ var mem = st.info[3].memory.bmx7;
+ var txQ = sta.txQ.split('/');
+ var ptxQ = '<p style="color:rgb('+parseInt(255*txQ[0]/txQ[1])+','+parseInt(128*(txQ[1]-txQ[0])/txQ[1])+',0)")>'+sta.txQ+'</p>';
+ res.push([sta.nodes, sta.nbs, sta.tun6Address, sta.tun4Address, sta.uptime, sta.cpu, mem, ptxQ]);
+ return res;
+ });
+
+ new TablePooler(1,"/cgi-bin/bmx7-info", {'$info':''}, "ifaces_div", function(st){
+ var res = Array();
+ var ifaces = st.info[1].interfaces;
+
+ ifaces.forEach(function(iface){
+ res.push([iface.dev, iface.state, iface.type, iface.rateMax, iface.localIp, iface.rxBpP, iface.txBpP]);
+ });
+ return res;
+ });
+
+ new TablePooler(1,"/cgi-bin/bmx7-info", {'$info':''}, "links_div", function(st){
+ var res = Array();
+ links = st.info[2].links;
+
+ links.forEach(function(link){
+ res.push([link.shortId, link.name, link.linkKey, link.nbLocalIp, link.dev, link.rxRate, link.txRate, link.rts]);
+ });
+ return res;
+ });
+
+//]]></script>
+
+<%+footer%>
diff --git a/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/topology.htm b/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/topology.htm
new file mode 100644
index 0000000000..58ce9fdbf0
--- /dev/null
+++ b/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/topology.htm
@@ -0,0 +1,54 @@
+<%+header%>
+<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.12/d3.min.js"></script>
+<script type="text/javascript" src="<%=resource%>/bmx7/js/netjsongraph.js"></script>
+
+<link href="<%=resource%>/bmx7/css/netjsongraph.css" rel="stylesheet">
+ <style type="text/css">
+ body {
+ font-family: Arial, sans-serif;
+ font-size: 13px;
+ }
+
+ .njg-overlay{
+ width: auto;
+ height: auto;
+ min-width: 200px;
+ max-width: 400px;
+ border: 1px solid #000;
+ border-radius: 2px;
+ background: rgba(0, 0, 0, 0.7);
+ top: 10px;
+ right: 10px;
+ padding: 0 15px;
+ font-family: Arial, sans-serif;
+ font-size: 14px;
+ color: #fff
+ }
+
+ .njg-node {
+ fill: #008000;
+ fill-opacity: 0.8;
+ stroke: #008000;
+ stroke-width: 1px;
+ cursor: pointer;
+ }
+ .njg-node:hover,
+ .njg-node.njg-open{
+ fill-opacity: 1;
+ }
+
+ .njg-link {
+ stroke: #00ff00;
+ stroke-width: 2;
+ stroke-opacity: .5;
+ cursor: pointer;
+ }
+ .njg-link:hover,
+ .njg-link.njg-open{
+ stroke-width: 3;
+ stroke-opacity: 1
+ }
+</style>
+<script>d3.netJsonGraph("/cgi-bin/bmx7-info?netjson/network-graph.json", { defaultStyle: false });</script>
+<%+footer%>
+
diff --git a/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/tunnels_j.htm b/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/tunnels_j.htm
new file mode 100644
index 0000000000..aaa79a8f4e
--- /dev/null
+++ b/applications/luci-app-bmx7/root/usr/lib/lua/luci/view/bmx7/tunnels_j.htm
@@ -0,0 +1,76 @@
+<%#
+ Copyright (C) 2011 Pau Escrich <pau@dabax.net>
+ Contributors Lluis Esquerda <eskerda@gmail.com>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+ The full GNU General Public License is included in this distribution in
+ the file called "COPYING".
+-%>
+
+
+<%+header%>
+<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
+<script type="text/javascript" src="<%=resource%>/bmx7/js/polling.js"></script>
+
+<div class="cbi-map">
+<h2>Gateway announcements</h2>
+<div class="cbi-map-descr">Networks announced by mesh nodes</div>
+
+<div class="cbi-section">
+ <legend><%:Announcements%></legend>
+ <div class="cbi-section-node">
+ <div class="table" id="tunnels_div">
+ <div class="tr table-titles">
+ <div class="th"><%:Status%></div>
+ <div class="th"><%:Name%></div>
+ <div class="th"><%:Node%></div>
+ <div class="th"><%:Network%></div>
+ <div class="th"><%:Bandwith%></div>
+ <div class="th"><%:Local net%></div>
+ <div class="th"><%:Path Metric%></div>
+ <div class="th"><%:Tun Metric%></div>
+ <div class="th"><%:Rating%></div>
+ </div>
+ </div>
+ </div>
+</div>
+
+</div>
+
+<script type="text/javascript">//<![CDATA[
+ new TablePooler(5,"/cgi-bin/bmx7-info", {'$tunnels':''}, "tunnels_div", function(st){
+ var tunicon = "<%=resource%>/icons/tunnel.png";
+ var tunicon_dis = "<%=resource%>/icons/tunnel_disabled.png";
+ var applyicon = "<%=resource%>/cbi/apply.gif";
+ var res = Array();
+ for ( var k in st.tunnels ) {
+ var tunnel = st.tunnels[k];
+ var nodename = tunnel.remoteName;
+ var advnet = tunnel.advNet;
+ var status = '<img src="'+tunicon_dis+'"/>';
+ if ( tunnel.tunName != "---" ) status = '<img src="'+tunicon+'"/>';
+ if ( advnet == "0.0.0.0/0" ) advnet = "<b>Internet IPv4</b>";
+ if ( advnet == "::/0" ) advnet = "<b>Internet IPv6</b>";
+ if (nodename != "---") {
+ res.push([status, tunnel.tunName, nodename, advnet, tunnel.advBw, tunnel.net,
+ tunnel.pathMtc, tunnel.tunMtc, tunnel.rating]);
+ }
+ }
+ return res;
+ });
+//]]></script>
+
+<%+footer%>