mirror of
https://github.com/wownero/wownero.git
synced 2026-10-17 15:41:44 +02:00
wallet2: validate public node addresses before display
(cherry picked from commit c683bf08850161d6b072fd70c0e1325cb39e0a61)
This commit is contained in:
@@ -2345,8 +2345,9 @@ bool simple_wallet::public_nodes(const std::vector<std::string> &args)
|
||||
const float cph = node.rpc_credits_per_hash / RPC_CREDITS_PER_HASH_SCALE;
|
||||
char cphs[9];
|
||||
snprintf(cphs, sizeof(cphs), "%.3f", cph);
|
||||
const std::string last_seen = node.last_seen == 0 ? tr("never") : get_human_readable_timespan(std::chrono::seconds(now - node.last_seen));
|
||||
std::string host = node.host + ":" + std::to_string(node.rpc_port);
|
||||
const std::string last_seen = node.last_seen == 0 ? tr("never") : get_human_readable_timespan(std::chrono::seconds(now - std::min(now, node.last_seen)));
|
||||
const std::string host = (node.host.find(':') == std::string::npos ? node.host : "[" + node.host + "]")
|
||||
+ ":" + std::to_string(node.rpc_port);
|
||||
message_writer() << boost::format("%32s %12s %16s") % host % cphs % last_seen;
|
||||
m_claimed_cph[host] = node.rpc_credits_per_hash;
|
||||
}
|
||||
|
||||
+13
-1
@@ -16400,7 +16400,19 @@ std::vector<cryptonote::public_node> wallet2::get_public_nodes(bool white_only)
|
||||
nodes = res.white;
|
||||
nodes.reserve(nodes.size() + res.gray.size());
|
||||
std::copy(res.gray.begin(), res.gray.end(), std::back_inserter(nodes));
|
||||
return nodes;
|
||||
std::vector<cryptonote::public_node> valid_nodes;
|
||||
valid_nodes.reserve(nodes.size());
|
||||
for (auto &node: nodes)
|
||||
{
|
||||
if (node.rpc_port == 0)
|
||||
continue;
|
||||
const auto address = net::get_network_address(node.host, node.rpc_port);
|
||||
if (!address || (node.host != address->host_str() && node.host != address->str()))
|
||||
continue;
|
||||
node.host = address->host_str();
|
||||
valid_nodes.push_back(std::move(node));
|
||||
}
|
||||
return valid_nodes;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
std::pair<size_t, uint64_t> wallet2::estimate_tx_size_and_weight(bool use_rct, int n_inputs, int ring_size, int n_outputs, size_t extra_size)
|
||||
|
||||
Reference in New Issue
Block a user