mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-23 21:57:46 +00:00
daemon: fix print_pl only printing public zone peers
This commit is contained in:
parent
459beb50d4
commit
fd60d05d5d
5 changed files with 30 additions and 14 deletions
|
@ -66,15 +66,11 @@ namespace {
|
|||
time(&now);
|
||||
time_t last_seen = static_cast<time_t>(peer.last_seen);
|
||||
|
||||
std::string id_str;
|
||||
std::string elapsed = epee::misc_utils::get_time_interval_string(now - last_seen);
|
||||
std::string id_str = epee::string_tools::pad_string(epee::string_tools::to_string_hex(peer.id), 16, '0', true);
|
||||
std::string port_str;
|
||||
std::string elapsed = peer.last_seen == 0 ? "never" : epee::misc_utils::get_time_interval_string(now - last_seen);
|
||||
std::string ip_str = peer.ip != 0 ? epee::string_tools::get_ip_string_from_int32(peer.ip) : std::string("[") + peer.host + "]";
|
||||
std::stringstream peer_id_str;
|
||||
peer_id_str << std::hex << std::setw(16) << peer.id;
|
||||
peer_id_str >> id_str;
|
||||
epee::string_tools::xtype_to_string(peer.port, port_str);
|
||||
std::string addr_str = ip_str + ":" + port_str;
|
||||
std::string addr_str = peer.host + ":" + port_str;
|
||||
std::string rpc_port = peer.rpc_port ? std::to_string(peer.rpc_port) : "-";
|
||||
std::string pruning_seed = epee::string_tools::to_string_hex(peer.pruning_seed);
|
||||
tools::msg_writer() << boost::format("%-10s %-25s %-25s %-5s %-4s %s") % prefix % id_str % addr_str % rpc_port % pruning_seed % elapsed;
|
||||
|
@ -222,6 +218,9 @@ bool t_rpc_command_executor::print_peer_list_stats() {
|
|||
cryptonote::COMMAND_RPC_GET_PEER_LIST::response res;
|
||||
|
||||
std::string failure_message = "Couldn't retrieve peer list";
|
||||
|
||||
req.public_only = false;
|
||||
|
||||
if (m_is_rpc)
|
||||
{
|
||||
if (!m_rpc_client->rpc_request(req, res, "/get_peer_list", failure_message.c_str()))
|
||||
|
|
|
@ -254,6 +254,7 @@ namespace nodetool
|
|||
size_t get_public_white_peers_count();
|
||||
size_t get_public_gray_peers_count();
|
||||
void get_public_peerlist(std::vector<peerlist_entry>& gray, std::vector<peerlist_entry>& white);
|
||||
void get_peerlist(std::vector<peerlist_entry>& gray, std::vector<peerlist_entry>& white);
|
||||
size_t get_zone_count() const { return m_network_zones.size(); }
|
||||
|
||||
void change_max_out_public_peers(size_t count);
|
||||
|
|
|
@ -1739,6 +1739,15 @@ namespace nodetool
|
|||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
void node_server<t_payload_net_handler>::get_peerlist(std::vector<peerlist_entry>& gray, std::vector<peerlist_entry>& white)
|
||||
{
|
||||
for (auto &zone: m_network_zones)
|
||||
{
|
||||
zone.second.m_peerlist.get_peerlist(gray, white); // appends
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
template<class t_payload_net_handler>
|
||||
bool node_server<t_payload_net_handler>::idle_worker()
|
||||
{
|
||||
m_peer_handshake_idle_maker_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::peer_sync_idle_maker, this));
|
||||
|
|
|
@ -1044,31 +1044,35 @@ namespace cryptonote
|
|||
PERF_TIMER(on_get_peer_list);
|
||||
std::vector<nodetool::peerlist_entry> white_list;
|
||||
std::vector<nodetool::peerlist_entry> gray_list;
|
||||
m_p2p.get_public_peerlist(gray_list, white_list);
|
||||
|
||||
res.white_list.reserve(white_list.size());
|
||||
if (req.public_only)
|
||||
{
|
||||
m_p2p.get_public_peerlist(gray_list, white_list);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_p2p.get_peerlist(gray_list, white_list);
|
||||
}
|
||||
|
||||
for (auto & entry : white_list)
|
||||
{
|
||||
if (entry.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
|
||||
res.white_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv4_network_address>().ip(),
|
||||
entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen, entry.pruning_seed, entry.rpc_port);
|
||||
else if (entry.adr.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
|
||||
{
|
||||
res.white_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv6_network_address>().host_str(),
|
||||
entry.adr.as<epee::net_utils::ipv6_network_address>().port(), entry.last_seen, entry.pruning_seed, entry.rpc_port);
|
||||
}
|
||||
else
|
||||
res.white_list.emplace_back(entry.id, entry.adr.str(), entry.last_seen, entry.pruning_seed, entry.rpc_port);
|
||||
}
|
||||
|
||||
res.gray_list.reserve(gray_list.size());
|
||||
for (auto & entry : gray_list)
|
||||
{
|
||||
if (entry.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
|
||||
res.gray_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv4_network_address>().ip(),
|
||||
entry.adr.as<epee::net_utils::ipv4_network_address>().port(), entry.last_seen, entry.pruning_seed, entry.rpc_port);
|
||||
else if (entry.adr.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
|
||||
res.white_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv6_network_address>().host_str(),
|
||||
res.gray_list.emplace_back(entry.id, entry.adr.as<epee::net_utils::ipv6_network_address>().host_str(),
|
||||
entry.adr.as<epee::net_utils::ipv6_network_address>().port(), entry.last_seen, entry.pruning_seed, entry.rpc_port);
|
||||
else
|
||||
res.gray_list.emplace_back(entry.id, entry.adr.str(), entry.last_seen, entry.pruning_seed, entry.rpc_port);
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace cryptonote
|
|||
// advance which version they will stop working with
|
||||
// Don't go over 32767 for any of these
|
||||
#define CORE_RPC_VERSION_MAJOR 2
|
||||
#define CORE_RPC_VERSION_MINOR 8
|
||||
#define CORE_RPC_VERSION_MINOR 9
|
||||
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor))
|
||||
#define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)
|
||||
|
||||
|
@ -1228,7 +1228,10 @@ namespace cryptonote
|
|||
{
|
||||
struct request_t
|
||||
{
|
||||
bool public_only;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_OPT(public_only, true)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
typedef epee::misc_utils::struct_init<request_t> request;
|
||||
|
|
Loading…
Reference in a new issue