Andrew Boyson / web

Dependents:   oldheating gps motorhome heating

Committer:
andrewboyson
Date:
Sat Dec 26 20:02:22 2020 +0000
Revision:
144:7106252b7abf
Parent:
142:b472ba95b018
Child:
146:6bc151bd7063
Moved name resolution web info from IPv4 and IPv6 pages to general net page.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 96:eb2eb75bad0f 1 "//Net6 script\n"
andrewboyson 86:f3c9beec4ee7 2 "'use strict';\n"
andrewboyson 86:f3c9beec4ee7 3 "\n"
andrewboyson 96:eb2eb75bad0f 4 "let arp = '';\n"
andrewboyson 142:b472ba95b018 5 "\n"
andrewboyson 96:eb2eb75bad0f 6 "let hopLimit = '';\n"
andrewboyson 142:b472ba95b018 7 "let mtu = '';\n"
andrewboyson 96:eb2eb75bad0f 8 "let managed = false;\n"
andrewboyson 96:eb2eb75bad0f 9 "let other = false;\n"
andrewboyson 96:eb2eb75bad0f 10 "let routerMac = '';\n"
andrewboyson 96:eb2eb75bad0f 11 "let dnsLife = '';\n"
andrewboyson 96:eb2eb75bad0f 12 "let dnsIp = '';\n"
andrewboyson 96:eb2eb75bad0f 13 "let ndpLease = '';\n"
andrewboyson 96:eb2eb75bad0f 14 "let ndpElapsed = '';\n"
andrewboyson 96:eb2eb75bad0f 15 "let slaac = '';\n"
andrewboyson 142:b472ba95b018 16 "\n"
andrewboyson 142:b472ba95b018 17 "let uniquePrefixLength = '';\n"
andrewboyson 142:b472ba95b018 18 "let uniquePrefixL = false;\n"
andrewboyson 142:b472ba95b018 19 "let uniquePrefixA = false;\n"
andrewboyson 142:b472ba95b018 20 "let uniquePrefixLimit = '';\n"
andrewboyson 142:b472ba95b018 21 "let uniquePrefixPreferred = '';\n"
andrewboyson 142:b472ba95b018 22 "let uniquePrefix = '';\n"
andrewboyson 142:b472ba95b018 23 "let globalPrefixLength = '';\n"
andrewboyson 142:b472ba95b018 24 "let globalPrefixL = false;\n"
andrewboyson 142:b472ba95b018 25 "let globalPrefixA = false;\n"
andrewboyson 142:b472ba95b018 26 "let globalPrefixLimit = '';\n"
andrewboyson 142:b472ba95b018 27 "let globalPrefixPreferred = '';\n"
andrewboyson 142:b472ba95b018 28 "let globalPrefix = '';\n"
andrewboyson 86:f3c9beec4ee7 29 "\n"
andrewboyson 88:2857259fc2b4 30 "function parseArpLine(line)\n"
andrewboyson 88:2857259fc2b4 31 "{\n"
andrewboyson 88:2857259fc2b4 32 " if (line.length == 0) return;\n"
andrewboyson 136:be1d42268b5d 33 " let fields = line.split('\\t');\n"
andrewboyson 136:be1d42268b5d 34 " \n"
andrewboyson 136:be1d42268b5d 35 " arp += parseInt(fields[0], 16).toString().padStart(2, ' ');\n"
andrewboyson 136:be1d42268b5d 36 " \n"
andrewboyson 136:be1d42268b5d 37 " let minutes = parseInt(fields[1], 16) / 1000 / 60;\n"
andrewboyson 88:2857259fc2b4 38 " arp += Math.floor(minutes).toString().padStart(4, ' ');\n"
andrewboyson 88:2857259fc2b4 39 " arp += ' ';\n"
andrewboyson 136:be1d42268b5d 40 " \n"
andrewboyson 136:be1d42268b5d 41 " arp += Net.makeIp6(fields[2]).padEnd(40, ' ');\n"
andrewboyson 88:2857259fc2b4 42 " arp += ' ';\n"
andrewboyson 136:be1d42268b5d 43 " \n"
andrewboyson 136:be1d42268b5d 44 " arp += Net.makeMac(fields[3]);\n"
andrewboyson 88:2857259fc2b4 45 " arp += '\\r\\n';\n"
andrewboyson 88:2857259fc2b4 46 "}\n"
andrewboyson 88:2857259fc2b4 47 "function parseArpLines(text)\n"
andrewboyson 88:2857259fc2b4 48 "{\n"
andrewboyson 88:2857259fc2b4 49 " arp = '';\n"
andrewboyson 88:2857259fc2b4 50 " text.split('\\n').forEach(parseArpLine);\n"
andrewboyson 88:2857259fc2b4 51 "}\n"
andrewboyson 89:615fb951df69 52 "function parseGenLines(text)\n"
andrewboyson 89:615fb951df69 53 "{\n"
andrewboyson 96:eb2eb75bad0f 54 " let lines = text.split('\\n');\n"
andrewboyson 89:615fb951df69 55 " \n"
andrewboyson 142:b472ba95b018 56 " slaac = Net.makeIp6 (lines[ 0] );\n"
andrewboyson 142:b472ba95b018 57 " \n"
andrewboyson 142:b472ba95b018 58 " hopLimit = parseInt(lines[ 1], 16);\n"
andrewboyson 142:b472ba95b018 59 " mtu = parseInt(lines[ 2], 16);\n"
andrewboyson 142:b472ba95b018 60 " managed = Net.hexToBit(lines[ 3], 0);\n"
andrewboyson 142:b472ba95b018 61 " other = Net.hexToBit(lines[ 3], 1);\n"
andrewboyson 142:b472ba95b018 62 " routerMac = Net.makeMac (lines[ 4], 16);\n"
andrewboyson 142:b472ba95b018 63 " ndpLease = parseInt(lines[ 5], 16);\n"
andrewboyson 142:b472ba95b018 64 " ndpElapsed = parseInt(lines[ 6], 16);\n"
andrewboyson 142:b472ba95b018 65 " \n"
andrewboyson 142:b472ba95b018 66 " dnsIp = Net.makeIp6 (lines[ 7] );\n"
andrewboyson 142:b472ba95b018 67 " dnsLife = parseInt(lines[ 8], 16);\n"
andrewboyson 142:b472ba95b018 68 " \n"
andrewboyson 142:b472ba95b018 69 " uniquePrefixL = Net.hexToBit(lines[ 9], 0);\n"
andrewboyson 142:b472ba95b018 70 " uniquePrefixA = Net.hexToBit(lines[ 9], 1);\n"
andrewboyson 142:b472ba95b018 71 " uniquePrefixLength = parseInt(lines[10], 16);\n"
andrewboyson 142:b472ba95b018 72 " uniquePrefix = Net.makeIp6 (lines[11] );\n"
andrewboyson 142:b472ba95b018 73 " uniquePrefixLimit = parseInt(lines[12], 16);\n"
andrewboyson 142:b472ba95b018 74 " uniquePrefixPreferred = parseInt(lines[13], 16);\n"
andrewboyson 142:b472ba95b018 75 " \n"
andrewboyson 142:b472ba95b018 76 " globalPrefixL = Net.hexToBit(lines[14], 0);\n"
andrewboyson 142:b472ba95b018 77 " globalPrefixA = Net.hexToBit(lines[14], 1);\n"
andrewboyson 142:b472ba95b018 78 " globalPrefixLength = parseInt(lines[15], 16);\n"
andrewboyson 142:b472ba95b018 79 " globalPrefix = Net.makeIp6 (lines[16] );\n"
andrewboyson 142:b472ba95b018 80 " globalPrefixLimit = parseInt(lines[17], 16);\n"
andrewboyson 142:b472ba95b018 81 " globalPrefixPreferred = parseInt(lines[18], 16);\n"
andrewboyson 89:615fb951df69 82 "}\n"
andrewboyson 96:eb2eb75bad0f 83 "function parse()\n"
andrewboyson 86:f3c9beec4ee7 84 "{\n"
andrewboyson 96:eb2eb75bad0f 85 " let topics = Ajax.response.split('\\f');\n"
andrewboyson 89:615fb951df69 86 " parseGenLines(topics[0]);\n"
andrewboyson 89:615fb951df69 87 " parseArpLines(topics[1]);\n"
andrewboyson 86:f3c9beec4ee7 88 "}\n"
andrewboyson 96:eb2eb75bad0f 89 "function display()\n"
andrewboyson 86:f3c9beec4ee7 90 "{\n"
andrewboyson 96:eb2eb75bad0f 91 " let elem;\n"
andrewboyson 89:615fb951df69 92 " \n"
andrewboyson 96:eb2eb75bad0f 93 " elem = Ajax.getElementOrNull('ajax-arp' ); if (elem) elem.textContent = arp;\n"
andrewboyson 142:b472ba95b018 94 " elem = Ajax.getElementOrNull('ajax-slaac' ); if (elem) elem.textContent = slaac;\n"
andrewboyson 96:eb2eb75bad0f 95 " elem = Ajax.getElementOrNull('ajax-hop-limit' ); if (elem) elem.textContent = hopLimit;\n"
andrewboyson 142:b472ba95b018 96 " elem = Ajax.getElementOrNull('ajax-mtu' ); if (elem) elem.textContent = mtu;\n"
andrewboyson 96:eb2eb75bad0f 97 " elem = Ajax.getElementOrNull('ajax-managed' ); if (elem) elem.setAttribute('dir', managed ? 'rtl' : 'ltr');\n"
andrewboyson 96:eb2eb75bad0f 98 " elem = Ajax.getElementOrNull('ajax-other' ); if (elem) elem.setAttribute('dir', other ? 'rtl' : 'ltr');\n"
andrewboyson 96:eb2eb75bad0f 99 " elem = Ajax.getElementOrNull('ajax-router-mac' ); if (elem) elem.textContent = routerMac;\n"
andrewboyson 142:b472ba95b018 100 " elem = Ajax.getElementOrNull('ajax-ndp-lease' ); if (elem) elem.textContent = ndpLease;\n"
andrewboyson 142:b472ba95b018 101 " elem = Ajax.getElementOrNull('ajax-ndp-elapsed' ); if (elem) elem.textContent = ndpElapsed;\n"
andrewboyson 96:eb2eb75bad0f 102 " elem = Ajax.getElementOrNull('ajax-dns-life' ); if (elem) elem.textContent = dnsLife;\n"
andrewboyson 96:eb2eb75bad0f 103 " elem = Ajax.getElementOrNull('ajax-dns-ip' ); if (elem) elem.textContent = dnsIp;\n"
andrewboyson 142:b472ba95b018 104 " \n"
andrewboyson 142:b472ba95b018 105 " elem = Ajax.getElementOrNull('ajax-unique-prefix-l' ); if (elem) elem.setAttribute('dir', uniquePrefixL ? 'rtl' : 'ltr');\n"
andrewboyson 142:b472ba95b018 106 " elem = Ajax.getElementOrNull('ajax-unique-prefix-a' ); if (elem) elem.setAttribute('dir', uniquePrefixA ? 'rtl' : 'ltr');\n"
andrewboyson 142:b472ba95b018 107 " elem = Ajax.getElementOrNull('ajax-unique-prefix-length' ); if (elem) elem.textContent = uniquePrefixLength;\n"
andrewboyson 142:b472ba95b018 108 " elem = Ajax.getElementOrNull('ajax-unique-prefix' ); if (elem) elem.textContent = uniquePrefix;\n"
andrewboyson 142:b472ba95b018 109 " elem = Ajax.getElementOrNull('ajax-unique-prefix-limit' ); if (elem) elem.textContent = uniquePrefixLimit;\n"
andrewboyson 142:b472ba95b018 110 " elem = Ajax.getElementOrNull('ajax-unique-prefix-preferred'); if (elem) elem.textContent = uniquePrefixPreferred;\n"
andrewboyson 142:b472ba95b018 111 " \n"
andrewboyson 142:b472ba95b018 112 " elem = Ajax.getElementOrNull('ajax-global-prefix-l' ); if (elem) elem.setAttribute('dir', globalPrefixL ? 'rtl' : 'ltr');\n"
andrewboyson 142:b472ba95b018 113 " elem = Ajax.getElementOrNull('ajax-global-prefix-a' ); if (elem) elem.setAttribute('dir', globalPrefixA ? 'rtl' : 'ltr');\n"
andrewboyson 142:b472ba95b018 114 " elem = Ajax.getElementOrNull('ajax-global-prefix-length' ); if (elem) elem.textContent = globalPrefixLength;\n"
andrewboyson 142:b472ba95b018 115 " elem = Ajax.getElementOrNull('ajax-global-prefix' ); if (elem) elem.textContent = globalPrefix;\n"
andrewboyson 142:b472ba95b018 116 " elem = Ajax.getElementOrNull('ajax-global-prefix-limit' ); if (elem) elem.textContent = globalPrefixLimit;\n"
andrewboyson 142:b472ba95b018 117 " elem = Ajax.getElementOrNull('ajax-global-prefix-preferred'); if (elem) elem.textContent = globalPrefixPreferred;\n"
andrewboyson 86:f3c9beec4ee7 118 "}\n"
andrewboyson 86:f3c9beec4ee7 119 "\n"
andrewboyson 96:eb2eb75bad0f 120 "Ajax.server = '/net6-ajax';\n"
andrewboyson 96:eb2eb75bad0f 121 "Ajax.onResponse = function() { parse(); display(); };\n"
andrewboyson 96:eb2eb75bad0f 122 "Ajax.init();"