summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-yggdrasil/htdocs
diff options
context:
space:
mode:
authorWilliam Fleurant <meshnet@protonmail.com>2023-11-30 20:30:45 +0100
committerWilliam Fleurant <meshnet@protonmail.com>2023-11-30 20:30:45 +0100
commitc9786be7518929f076ad9a1abe190b2573851128 (patch)
tree5c0dfefd43d36cb1844b2f809ca9c9a76ef127e0 /applications/luci-app-yggdrasil/htdocs
parent6fdafc4155899da13c17ab4a6f5d78bc90cc18ef (diff)
luci-app-yggdrasil: revert: remove package in favor of luci-proto-yggdrasil
This reverts commit e6a1f119e6ec2eed48ea583d8176c21bf658a499. Signed-off-by: William Fleurant <meshnet@protonmail.com>
Diffstat (limited to 'applications/luci-app-yggdrasil/htdocs')
-rw-r--r--applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/keys.js20
-rw-r--r--applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/peers.js32
-rw-r--r--applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/settings.js58
-rw-r--r--applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/status.js104
4 files changed, 214 insertions, 0 deletions
diff --git a/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/keys.js b/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/keys.js
new file mode 100644
index 0000000000..7e9bef46e4
--- /dev/null
+++ b/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/keys.js
@@ -0,0 +1,20 @@
+'use strict';
+'require view';
+'require form';
+
+return view.extend({
+ render: function() {
+ var m, s, o;
+
+ m = new form.Map('yggdrasil', 'Yggdrasil');
+
+ s = m.section(form.TypedSection, "yggdrasil", _("Encryption keys"));
+ s.anonymous = true;
+
+ s.option(form.Value, "PublicKey", _("Encryption public key"));
+ s.option(form.Value, "PrivateKey", _("Encryption private key"),
+ _("Keep this private. When compromised, generate a new keypair and IPv6."));
+
+ return m.render();
+ }
+});
diff --git a/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/peers.js b/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/peers.js
new file mode 100644
index 0000000000..7d392901c5
--- /dev/null
+++ b/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/peers.js
@@ -0,0 +1,32 @@
+'use strict';
+'require view';
+'require form';
+
+return view.extend({
+ render: function() {
+ var m, s, o;
+
+ m = new form.Map('yggdrasil', 'Yggdrasil');
+
+ o = m.section(form.TableSection, "peer", _("Peers"),
+ _("List of connection strings for outbound peer connections in URI format, " +
+ "e.g. tcp://a.b.c.d:e or socks://a.b.c.d:e/f.g.h.i:j. These connections " +
+ "will obey the operating system routing table, therefore you should " +
+ "use this section when you may connect via different interfaces."));
+ o.option(form.Value, "uri", "URI");
+ o.anonymous = true;
+ o.addremove = true;
+
+ o = m.section(form.TableSection, "interface_peer", _("Interface peers"),
+ _("List of connection strings for outbound peer connections in URI format, " +
+ "arranged by source interface, e.g. { \"eth0\": [ tcp://a.b.c.d:e ] }. " +
+ "Note that SOCKS peerings will NOT be affected by this option and should " +
+ "go in the \"Peers\" section instead."));
+ o.option(form.Value, "interface", _("Interface"));
+ o.option(form.Value, "uri", "URI");
+ o.anonymous = true;
+ o.addremove = true;
+
+ return m.render();
+ }
+});
diff --git a/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/settings.js b/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/settings.js
new file mode 100644
index 0000000000..8bc63dadc2
--- /dev/null
+++ b/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/settings.js
@@ -0,0 +1,58 @@
+'use strict';
+'require view';
+'require form';
+
+return view.extend({
+ render: function() {
+ var m, s, o;
+
+ m = new form.Map('yggdrasil', 'Yggdrasil');
+
+ s = m.section(form.TypedSection, 'yggdrasil', _('General settings'));
+ s.anonymous = true;
+
+ s.option(form.Value, "IfName", _("Yggdrasil's network interface name"));
+
+ s.option(form.Flag, "NodeInfoPrivacy", _("Enable NodeInfo privacy"),
+ _("By default, nodeinfo contains some defaults including the platform," +
+ " architecture and Yggdrasil version. These can help when surveying" +
+ " the network and diagnosing network routing problems. Enabling" +
+ " nodeinfo privacy prevents this, so that only items specified in" +
+ " \"NodeInfo\" are sent back if specified."));
+
+ o = s.option(form.Value, "NodeInfo", _("NodeInfo"),
+ _("Optional node info. This must be a { \"key\": \"value\", ... } map " +
+ "or set as null. This is entirely optional but, if set, is visible " +
+ "to the whole network on request."));
+ o.validate = function(k, v) {
+ try { JSON.parse(v); return true; } catch (e) { return e.message; }
+ }
+
+ s.option(form.Value, "IfMTU", _("MTU size for the interface"));
+
+ o = m.section(form.TableSection, "listen_address", _("Listen addresses"),
+ _("Listen addresses for incoming connections. You will need to add " +
+ "listeners in order to accept incoming peerings from non-local nodes. " +
+ "Multicast peer discovery will work regardless of any listeners set " +
+ "here. Each listener should be specified in URI format as above, e.g. " +
+ "tcp://0.0.0.0:0 or tcp://[::]:0 to listen on all interfaces."));
+ o.option(form.Value, "uri",
+ _("e.g. tcp://0.0.0.0:0 or tcp://[::]:0"));
+ o.anonymous = true;
+ o.addremove = true;
+
+ o = m.section(form.TableSection, "multicast_interface", _("Multicast interface"),
+ _("Configuration for which interfaces multicast peer discovery should be enabled on. " +
+ "Regex is a regular expression which is matched against an interface name, and interfaces use the first configuration that they match gainst. " +
+ "Beacon configures whether or not the node should send link-local multicast beacons to advertise their presence, while listening for incoming connections on Port. " +
+ "Listen controls whether or not the node listens for multicast beacons and opens outgoing connections."));
+ o.option(form.Value, "regex", _("Regular expression"));
+ o.option(form.Flag, "beacon", _("Send beacons"));
+ o.option(form.Flag, "listen", _("Listen for beacons"));
+ o.option(form.Value, "port", _("Link-local port"));
+ o.anonymous = true;
+ o.addremove = true;
+
+ return m.render();
+ }
+});
diff --git a/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/status.js b/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/status.js
new file mode 100644
index 0000000000..d47ccb2f5d
--- /dev/null
+++ b/applications/luci-app-yggdrasil/htdocs/luci-static/resources/view/yggdrasil/status.js
@@ -0,0 +1,104 @@
+'use strict';
+'require view';
+'require fs';
+'require form';
+
+function init_view() {
+ var view = document.createElement("div");
+ var self_info = document.createElement("div"); self_info.setAttribute("class", "table");
+
+ var table_data = {
+ "IPv6 address": "self-address",
+ "IPv6 subnet": "self-subnet",
+ "Coords": "self-coords",
+ "Public key": "self-key",
+ "Build name": "self-buildname",
+ "Build version": "self-version"
+ };
+
+ Object.keys(table_data).forEach(function(k) {
+ var tr = document.createElement("div");
+ tr.setAttribute("class", "tr");
+ var td1 = document.createElement("div"); td1.setAttribute("class", "td left");
+ td1.textContent = k;
+ var td2 = document.createElement("div"); td2.setAttribute("class", "td left");
+ td2.id = table_data[k];
+
+ tr.appendChild(td1); tr.appendChild(td2); self_info.appendChild(tr);
+ });
+
+ var info_title = document.createElement("h2"); info_title.innerText = _("Yggdrasil node status");
+ view.appendChild(info_title);
+ view.appendChild(self_info);
+ var peering_title = document.createElement("h3"); peering_title.innerText = _("Active peers");
+ view.appendChild(peering_title);
+
+ var peerings = document.createElement("table");
+ peerings.setAttribute("class", "table"); peerings.id = "yggdrasil-peerings";
+ var tr = document.createElement("tr");
+ tr.setAttribute("class", "tr table-titles");
+ ["Endpoint", "Address", "Coords", "Key", "Port"].forEach(function(t) {
+ var th = document.createElement("th"); th.setAttribute("class", "th nowrap left");
+ th.innerText = t;
+ tr.appendChild(th);
+ });
+ peerings.appendChild(tr);
+ view.appendChild(peerings);
+ return view;
+}
+
+function update_active_peers() {
+ fs.exec("/usr/sbin/yggdrasilctl", ["-json", "getPeers"]).then(function(res){
+ if (res && res.code === 0) {
+ var peers = JSON.parse(res.stdout.trim())["peers"];
+ var table = document.querySelector('#yggdrasil-peerings');
+ while (table.rows.length > 1) { table.deleteRow(1); }
+ Object.keys(peers).forEach(function(address) {
+ var row = table.insertRow(-1);
+ row.style.fontSize = "xx-small";
+ row.insertCell(-1).textContent = peers[address].remote;
+ row.insertCell(-1).textContent = address;
+ row.insertCell(-1).textContent = "[" + peers[address].coords.toString() + "]";
+ row.insertCell(-1).textContent = peers[address].key;
+ row.insertCell(-1).textContent = peers[address].port;
+ });
+ }
+ setTimeout(update_active_peers, 5000);
+ });
+}
+
+return view.extend({
+ load: function() {
+ return Promise.all([
+ L.resolveDefault(fs.stat("/usr/sbin/yggdrasilctl"), null),
+ L.resolveDefault(fs.exec("/usr/sbin/yggdrasilctl", ["-json", "getSelf"]), null),
+ L.resolveDefault(fs.exec("/usr/sbin/yggdrasilctl", ["-json", "getPeers"]), null)
+ ]);
+ },
+ render: function(info) {
+ var view = init_view();
+
+ if (info[0] && info[1] && info[1].code === 0) {
+ var obj = JSON.parse(info[1].stdout.trim())["self"];
+ var peers = JSON.parse(info[2].stdout.trim())["peers"];
+
+ var address = Object.keys(obj)[0];
+ var r = obj[address];
+ view.querySelector('#self-address').innerText = address;
+ view.querySelector('#self-subnet').innerText = r.subnet;
+ view.querySelector('#self-coords').innerText = "[" + r.coords + "]";
+ view.querySelector('#self-key').innerText = r.key;
+ view.querySelector('#self-buildname').innerText = r.build_name;
+ view.querySelector('#self-version').innerText = r.build_version;
+
+ update_active_peers();
+ } else {
+ view.innerHTML = "<h2>Yggdrasil is not running</h2>";
+ }
+ return view;
+ },
+
+ handleSaveApply: null,
+ handleSave: null,
+ handleReset: null
+});