From 7f4cf692a18dc8e89b39b691e7d1deb2f9f3a8c4 Mon Sep 17 00:00:00 2001
From: Dan Janosik <dan@47.io>
Date: Fri, 21 Feb 2020 13:12:01 -0500
Subject: [PATCH] more detailed network info on /node-status

---
 app.js                |  2 ++
 views/node-status.pug | 55 ++++++++++++++++++++++++++++++++++---------
 2 files changed, 46 insertions(+), 11 deletions(-)

diff --git a/app.js b/app.js
index 7810730..650220c 100755
--- a/app.js
+++ b/app.js
@@ -204,6 +204,8 @@ function onRpcConnectionVerified(getnetworkinfo, getblockchaininfo) {
 	// localservicenames introduced in 0.19
 	var services = getnetworkinfo.localservicesnames ? ("[" + getnetworkinfo.localservicesnames.join(", ") + "]") : getnetworkinfo.localservices;
 
+	global.getnetworkinfo = getnetworkinfo;
+
 	debugLog(`RPC Connected: version=${getnetworkinfo.version} (${getnetworkinfo.subversion}), protocolversion=${getnetworkinfo.protocolversion}, chain=${getblockchaininfo.chain}, services=${services}`);
 
 	// load historical/fun items for this chain
diff --git a/views/node-status.pug b/views/node-status.pug
index 89e2631..ea181eb 100644
--- a/views/node-status.pug
+++ b/views/node-status.pug
@@ -56,10 +56,7 @@ block content
 									td(class="monospace") #{sizeData[0]} #{sizeData[1].abbreviation}B
 										br
 										span(class="text-muted")  (pruned: #{getblockchaininfo.pruned})
-							tr
-								td(class="properties-header") Connections
-								td(class="monospace") #{getnetworkinfo.connections.toLocaleString()}
-
+							
 							tr
 								td(class="properties-header") Block Count
 								td(class="monospace") #{getblockchaininfo.blocks.toLocaleString()}
@@ -88,6 +85,23 @@ block content
 								td(class="properties-header") Uptime
 								td(class="monospace") #{startTimeAgo.format()}
 
+							tr
+								td(class="properties-header") Warnings
+								td(class="monospace")
+									if (getblockchaininfo.warnings && getblockchaininfo.warnings.trim().length > 0)
+										span #{getblockchaininfo.warnings}
+									else
+										span None
+
+				div(class="card mb-3 shadow-sm")
+					div(class="card-header")
+						span(class="h6") Network Info
+					div(class="card-body")
+						table(class="table details-table mb-0")
+							tr
+								td(class="properties-header") Peers
+								td(class="monospace") #{getnetworkinfo.connections.toLocaleString()}
+
 							tr
 								td(class="properties-header") Network Traffic
 								td(class="monospace")
@@ -102,13 +116,32 @@ block content
 									span Total Upload: #{upData[0]} #{upData[1].abbreviation}B
 									span(class="text-muted")  (avg #{upRateData[0]} #{upRateData[1].abbreviation}B/s)
 
-							tr
-								td(class="properties-header") Warnings
-								td(class="monospace")
-									if (getblockchaininfo.warnings && getblockchaininfo.warnings.trim().length > 0)
-										span #{getblockchaininfo.warnings}
-									else
-										span None
+							if (global.getnetworkinfo.networks)
+								tr
+									td(class="properties-header") Interfaces
+									td(class="monospace")
+										each item, index in global.getnetworkinfo.networks
+											div
+												span.font-weight-bold #{item.name}: 
+												if (item.reachable)
+													span reachable
+														i.fa.fa-check.ml-2.text-success
+
+												else
+													span unreachable
+														i.fa.fa-times.ml-2.text-danger
+
+												if (item.proxy)
+													span.text-muted.ml-3 (proxy: #{item.proxy})
+
+							td(class="properties-header") Local Addresses
+							td(class="monospace")
+								if (global.getnetworkinfo.localaddresses)
+									each item, index in global.getnetworkinfo.localaddresses
+										div #{item.address}:#{item.port}
+											span.text-muted.ml-3 (score: #{item.score.toLocaleString()})
+
+							
 
 			div(id="tab-json", class="tab-pane", role="tabpanel")