@@ -550,15 +550,26 @@ class NetinfoRequestHandler : public BaseRequestHandler
550
550
}
551
551
552
552
// Report peer connection totals by type.
553
- result += " ipv4 ipv6 onion" ;
554
- const bool any_i2p_peers = m_counts.at (2 ).at (3 ); // false if total i2p peers count is 0, otherwise true
555
- if (any_i2p_peers) result += " i2p" ;
553
+ result += " " ;
554
+ std::vector<int8_t > reachable_networks;
555
+ for (const UniValue& network : networkinfo[" networks" ].getValues ()) {
556
+ if (network[" reachable" ].get_bool ()) {
557
+ const std::string& network_name{network[" name" ].get_str ()};
558
+ const int8_t network_id{NetworkStringToId (network_name)};
559
+ if (network_id == UNKNOWN_NETWORK) continue ;
560
+ result += strprintf (" %8s" , network_name); // column header
561
+ reachable_networks.push_back (network_id);
562
+ }
563
+ };
556
564
result += " total block" ;
557
565
if (m_manual_peers_count) result += " manual" ;
566
+
558
567
const std::array rows{" in" , " out" , " total" };
559
- for (uint8_t i = 0 ; i < 3 ; ++i) {
560
- result += strprintf (" \n %-5s %5i %5i %5i" , rows.at (i), m_counts.at (i).at (0 ), m_counts.at (i).at (1 ), m_counts.at (i).at (2 )); // ipv4/ipv6/onion peers counts
561
- if (any_i2p_peers) result += strprintf (" %5i" , m_counts.at (i).at (3 )); // i2p peers count
568
+ for (size_t i = 0 ; i < rows.size (); ++i) {
569
+ result += strprintf (" \n %-5s" , rows[i]); // row header
570
+ for (int8_t n : reachable_networks) {
571
+ result += strprintf (" %8i" , m_counts.at (i).at (n)); // network peers count
572
+ }
562
573
result += strprintf (" %5i" , m_counts.at (i).at (m_networks.size ())); // total peers count
563
574
if (i == 1 ) { // the outbound row has two extra columns for block relay and manual peer counts
564
575
result += strprintf (" %5i" , m_block_relay_peers_count);
0 commit comments