From 3e0fb41524ea0e12851ffe7b1e711b93c5c90e66 Mon Sep 17 00:00:00 2001 From: Noah Zalev Date: Mon, 12 Jul 2021 17:23:53 -0400 Subject: [PATCH 1/3] Added netif2 to meshctrl displayinfo --- meshctrl.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/meshctrl.js b/meshctrl.js index 3287d309..7065691d 100644 --- a/meshctrl.js +++ b/meshctrl.js @@ -2337,6 +2337,67 @@ function displayDeviceInfo(sysinfo, lastconnect, network, nodes) { } } + if (network.netif2 != null) { + var minfo = {}; + for (var i in network.netif2) { + var m = network.netif2[i], moutput = {}, moutputCount = 0; + + if (Array.isArray(m) == false || + m.length < 1 || + m[0] == null || + ((typeof m[0].mac == 'string') && (m[0].mac.startsWith('00:00:00:00'))) + ) + continue; + + var ifTitle = ''; + if (i != null) ifTitle += i; + if (m[0].fqdn != null && m[0].fqdn != '') ifTitle += ', ' + m[0].fqdn; + + if (typeof m[0].mac == 'string') { + if (m[0].gatewaymac) { + moutput['MAC Layer'] = format("MAC: {0}, Gateway: {1}", m[0].mac, m[0].gatewaymac); + } else { + moutput['MAC Layer'] = format("MAC: {0}", m[0].mac); + } + moutputCount++; + } + + moutput['IPv4 Layer'] = ''; + moutput['IPv6 Layer'] = ''; + for (var j = 0; j < m.length; j++) { + var iplayer = m[j]; + if (iplayer.family == 'IPv4') { + if (iplayer.gateway && iplayer.netmask) { + moutput['IPv4 Layer'] += format("IP: {0}, Mask: {1}, Gateway: {2} ", iplayer.address, iplayer.netmask, iplayer.gateway); + moutputCount++; + } else { + if (iplayer.address) { + moutput['IPv4 Layer'] += format("IP: {0} ", iplayer.address); + moutputCount++; + } + } + } + if (iplayer.family == 'IPv6') { + if (iplayer.gateway && iplayer.netmask) { + moutput['IPv6 Layer'] += format("IP: {0}, Mask: {1}, Gateway: {2} ", iplayer.address, iplayer.netmask, iplayer.gateway); + moutputCount++; + } else { + if (iplayer.address) { + moutput['IPv6 Layer'] += format("IP: {0} ", iplayer.address); + moutputCount++; + } + } + } + } + if (moutput['IPv4 Layer'] == '') delete moutput['IPv4 Layer']; + if (moutput['IPv6 Layer'] == '') delete moutput['IPv6 Layer']; + if (moutputCount > 0) { + minfo[ifTitle] = moutput; + info["Networking"] = minfo; + } + } + } + // Intel AMT if (node.intelamt != null) { var output = {}, outputCount = 0; From 992e538d5116b4814c6e7bfa88e2fa4a611ea8f3 Mon Sep 17 00:00:00 2001 From: Noah Zalev Date: Mon, 12 Jul 2021 17:51:40 -0400 Subject: [PATCH 2/3] Remove trailing commas from interface titles --- views/default.handlebars | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/views/default.handlebars b/views/default.handlebars index e60e0b81..930d3f88 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -10001,10 +10001,10 @@ var m = network.netif2[i]; if ((Array.isArray(m) == false) || (m.length < 1) || (m[0] == null) || ((typeof m[0].mac == 'string') && (m[0].mac.startsWith('00:00:00:00')))) continue; x += '
'; - var ifTitle = []; - if (i != null) { ifTitle.push(i); } - if (m[0].fqdn != null) { ifTitle.push(m[0].fqdn); } - if (ifTitle.length > 0) { x += '
' + EscapeHtml(ifTitle.join(', ')) + '
'; } + var ifTitle = ''; + if (i != null) ifTitle += i; + if (m[0].fqdn != null && m[0].fqdn != '') ifTitle += ', ' + m[0].fqdn; + if (ifTitle.length > 0) { x += '
' + EscapeHtml(ifTitle) + '
'; } if (m.desc) { x += addDetailItem("Description", EscapeHtml(m.desc).split('(R)').join('®')); } //if (m.dnssuffix) { x += addDetailItem("DNS Suffix", m.dnssuffix); } if (typeof m[0].mac == 'string') { From f98e5fcefba395bb2b85356a3de0c721aeef056f Mon Sep 17 00:00:00 2001 From: Noah Zalev Date: Mon, 12 Jul 2021 18:08:30 -0400 Subject: [PATCH 3/3] Deduplication in meshctrl netif2 --- meshctrl.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/meshctrl.js b/meshctrl.js index 7065691d..73c91262 100644 --- a/meshctrl.js +++ b/meshctrl.js @@ -2349,8 +2349,7 @@ function displayDeviceInfo(sysinfo, lastconnect, network, nodes) { ) continue; - var ifTitle = ''; - if (i != null) ifTitle += i; + var ifTitle = '' + i; if (m[0].fqdn != null && m[0].fqdn != '') ifTitle += ', ' + m[0].fqdn; if (typeof m[0].mac == 'string') { @@ -2366,24 +2365,13 @@ function displayDeviceInfo(sysinfo, lastconnect, network, nodes) { moutput['IPv6 Layer'] = ''; for (var j = 0; j < m.length; j++) { var iplayer = m[j]; - if (iplayer.family == 'IPv4') { + if (iplayer.family == 'IPv4' || iplayer.family == 'IPv6') { if (iplayer.gateway && iplayer.netmask) { - moutput['IPv4 Layer'] += format("IP: {0}, Mask: {1}, Gateway: {2} ", iplayer.address, iplayer.netmask, iplayer.gateway); + moutput[iplayer.family + ' Layer'] += format("IP: {0}, Mask: {1}, Gateway: {2} ", iplayer.address, iplayer.netmask, iplayer.gateway); moutputCount++; } else { if (iplayer.address) { - moutput['IPv4 Layer'] += format("IP: {0} ", iplayer.address); - moutputCount++; - } - } - } - if (iplayer.family == 'IPv6') { - if (iplayer.gateway && iplayer.netmask) { - moutput['IPv6 Layer'] += format("IP: {0}, Mask: {1}, Gateway: {2} ", iplayer.address, iplayer.netmask, iplayer.gateway); - moutputCount++; - } else { - if (iplayer.address) { - moutput['IPv6 Layer'] += format("IP: {0} ", iplayer.address); + moutput[iplayer.family + ' Layer'] += format("IP: {0} ", iplayer.address); moutputCount++; } }