Show IPv6 addresses in connection list

This commit is contained in:
Guillaume Le Vaillant 2023-04-14 13:34:30 +02:00
parent 9367b432f6
commit c90c1c3fe1
3 changed files with 16 additions and 4 deletions

View File

@ -281,6 +281,11 @@ namespace cryptonote
cnx.ip = cnx.host; cnx.ip = cnx.host;
cnx.port = std::to_string(cntxt.m_remote_address.as<epee::net_utils::ipv4_network_address>().port()); cnx.port = std::to_string(cntxt.m_remote_address.as<epee::net_utils::ipv4_network_address>().port());
} }
else if (cntxt.m_remote_address.get_type_id() == epee::net_utils::ipv6_network_address::get_type_id())
{
cnx.ip = cnx.host;
cnx.port = std::to_string(cntxt.m_remote_address.as<epee::net_utils::ipv6_network_address>().port());
}
cnx.rpc_port = cntxt.m_rpc_port; cnx.rpc_port = cntxt.m_rpc_port;
cnx.rpc_credits_per_hash = cntxt.m_rpc_credits_per_hash; cnx.rpc_credits_per_hash = cntxt.m_rpc_credits_per_hash;

View File

@ -644,7 +644,14 @@ bool t_rpc_command_executor::print_connections() {
} }
} }
tools::msg_writer() << std::setw(30) << std::left << "Remote Host" auto longest_host = *std::max_element(res.connections.begin(), res.connections.end(),
[](const auto &info1, const auto &info2)
{
return info1.address.length() < info2.address.length();
});
int host_field_width = std::max(15, 8 + (int) longest_host.address.length());
tools::msg_writer() << std::setw(host_field_width) << std::left << "Remote Host"
<< std::setw(8) << "Type" << std::setw(8) << "Type"
<< std::setw(6) << "SSL" << std::setw(6) << "SSL"
<< std::setw(20) << "Peer id" << std::setw(20) << "Peer id"
@ -661,11 +668,11 @@ bool t_rpc_command_executor::print_connections() {
for (auto & info : res.connections) for (auto & info : res.connections)
{ {
std::string address = info.incoming ? "INC " : "OUT "; std::string address = info.incoming ? "INC " : "OUT ";
address += info.ip + ":" + info.port; address += info.address;
//std::string in_out = info.incoming ? "INC " : "OUT "; //std::string in_out = info.incoming ? "INC " : "OUT ";
tools::msg_writer() tools::msg_writer()
//<< std::setw(30) << std::left << in_out //<< std::setw(30) << std::left << in_out
<< std::setw(30) << std::left << address << std::setw(host_field_width) << std::left << address
<< std::setw(8) << (get_address_type_name((epee::net_utils::address_type)info.address_type)) << std::setw(8) << (get_address_type_name((epee::net_utils::address_type)info.address_type))
<< std::setw(6) << (info.ssl ? "yes" : "no") << std::setw(6) << (info.ssl ? "yes" : "no")
<< std::setw(20) << info.peer_id << std::setw(20) << info.peer_id

View File

@ -88,7 +88,7 @@ namespace cryptonote
// advance which version they will stop working with // advance which version they will stop working with
// Don't go over 32767 for any of these // Don't go over 32767 for any of these
#define CORE_RPC_VERSION_MAJOR 3 #define CORE_RPC_VERSION_MAJOR 3
#define CORE_RPC_VERSION_MINOR 11 #define CORE_RPC_VERSION_MINOR 12
#define MAKE_CORE_RPC_VERSION(major,minor) (((major)<<16)|(minor)) #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) #define CORE_RPC_VERSION MAKE_CORE_RPC_VERSION(CORE_RPC_VERSION_MAJOR, CORE_RPC_VERSION_MINOR)