cli -netinfo: handle longer tor v3 local addresses

pull/764/head
Jon Atack 4 years ago
parent 33e987452f
commit 773f4c99c0
No known key found for this signature in database
GPG Key ID: 4F5721B3D0E3921D

@ -20,6 +20,7 @@
#include <util/translation.h>
#include <util/url.h>
#include <algorithm>
#include <functional>
#include <memory>
#include <stdio.h>
@ -455,12 +456,16 @@ public:
// Report local addresses, ports, and scores.
result += "\nLocal addresses";
const UniValue& local_addrs{networkinfo["localaddresses"]};
const std::vector<UniValue>& local_addrs{networkinfo["localaddresses"].getValues()};
if (local_addrs.empty()) {
result += ": n/a\n";
} else {
for (const UniValue& addr : local_addrs.getValues()) {
result += strprintf("\n%-40i port %5i score %6i", addr["address"].get_str(), addr["port"].get_int(), addr["score"].get_int());
size_t max_addr_size{0};
for (const UniValue& addr : local_addrs) {
max_addr_size = std::max(addr["address"].get_str().length() + 1, max_addr_size);
}
for (const UniValue& addr : local_addrs) {
result += strprintf("\n%-*s port %6i score %6i", max_addr_size, addr["address"].get_str(), addr["port"].get_int(), addr["score"].get_int());
}
}

Loading…
Cancel
Save