Browse Source

Show connected vpn peers

Michael Schwarz 8 years ago
parent
commit
51872f0a66
1 changed files with 23 additions and 0 deletions
  1. 23 0
      lib/infobox/node.js

+ 23 - 0
lib/infobox/node.js

@@ -36,6 +36,28 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
     }
   }
 
+  function showConnectedVpnPeers(d) {
+    var peers = ""
+    if (d.statistics.vpn_peers) {
+      var vpnGroups = d.statistics.vpn_peers.groups
+      for ( var group in vpnGroups ) {
+        var vpnPeers = vpnGroups[group].peers
+        for ( var gw in vpnPeers ) {
+          if ( vpnPeers[gw] !== null ) {
+            if (peers !== "")
+              peers += ", "
+            var time = moment.duration(vpnPeers[gw].established, "seconds").humanize()
+            peers += gw + " (" + time + ")"
+          }
+        }
+      }
+    }
+    if (peers !== "")
+      return peers
+    else
+      return "Keine"
+  }
+
   function showStatus(d) {
     return function (el) {
       el.classList.add(d.flags.online ? "online" : "offline")
@@ -194,6 +216,7 @@ define(["moment", "numeral", "tablesort", "tablesort.numeric"],
     attributeEntry(attributes, "Firmware", showFirmware(d))
     attributeEntry(attributes, "Uptime", showUptime(d))
     attributeEntry(attributes, "Teil des Netzes", showFirstseen(d))
+    attributeEntry(attributes, "VPN-Verbindung", showConnectedVpnPeers(d))
     attributeEntry(attributes, "Arbeitsspeicher", showRAM(d))
     attributeEntry(attributes, "IP Adressen", showIPs(d))
     attributeEntry(attributes, "Autom. Updates", showAutoupdate(d))