Andrew Boyson / web

Dependents:   oldheating gps motorhome heating

Revision:
143:cc2e148cb96a
Parent:
133:98c6bf14bc37
Child:
144:7106252b7abf
diff -r b472ba95b018 -r cc2e148cb96a base/net/web-net-script.js
--- a/base/net/web-net-script.js	Wed Dec 23 09:57:17 2020 +0000
+++ b/base/net/web-net-script.js	Sat Dec 26 19:38:40 2020 +0000
@@ -3,6 +3,7 @@
 
 let mac = '';
 let tcp = '';
+let dns = '';
 
 function parseTcpLine(line)
 {
@@ -45,6 +46,22 @@
     tcp = "State Idle Protocol ARI Port-Loc Port-Rem  Rcvd  Sent\n";
     text.split('\n').forEach(parseTcpLine);
 }
+function parseDnsLine(line)
+{
+    if (line.length == 0) return;
+    let fields = line.split('\t');
+    
+    dns += parseInt(fields[0], 16).toString().padStart(2, ' ');
+    let minutes  = parseInt(fields[1], 16) / 1000 / 60;
+    dns += Math.floor(minutes).toString().padStart(4, ' ');
+    dns += ' ';
+    dns += Net.makeIp6(fields[2]).padEnd(40, ' ');
+    dns += ' ';
+    dns += fields[3];
+    dns += ' ';
+    dns += fields[4];
+    dns += '\r\n';
+}
 function parseGenLines(text)
 {
     let lines = text.split('\n');
@@ -55,6 +72,7 @@
     let topics = Ajax.response.split('\f');
     parseGenLines(topics[0]);
     parseTcpLines(topics[1]);
+    parseDnsLines(topics[2]);
 }
 function display()
 {
@@ -62,6 +80,7 @@
 
     elem = Ajax.getElementOrNull('ajax-tcp'         ); if (elem) elem.textContent = tcp;
     elem = Ajax.getElementOrNull('ajax-mac'         ); if (elem) elem.textContent = mac;
+    elem = Ajax.getElementOrNull('ajax-dns'         ); if (elem) elem.textContent = dns;
 }
 
 Ajax.server     = '/net-ajax';