aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2023-06-27 11:28:24 -0500
committerluigi1111 <luigi1111w@gmail.com>2023-06-27 11:28:24 -0500
commit57c58fd5bdcf4bcc190ca496500403c7efd554d5 (patch)
tree5ef60a3d4df8d931431fb4c0c6e2e18f913d5a64 /src
parentMerge pull request #8701 (diff)
parentShow IPv6 addresses in connection list (diff)
downloadmonero-57c58fd5bdcf4bcc190ca496500403c7efd554d5.tar.xz
Merge pull request #8703
c90c1c3 Show IPv6 addresses in connection list (Guillaume Le Vaillant)
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl5
-rw-r--r--src/daemon/rpc_command_executor.cpp13
2 files changed, 15 insertions, 3 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index 325737789..5dbc614ca 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -281,6 +281,11 @@ namespace cryptonote
cnx.ip = cnx.host;
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_credits_per_hash = cntxt.m_rpc_credits_per_hash;
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index 0dcfc9d53..fbf26db85 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -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(6) << "SSL"
<< std::setw(20) << "Peer id"
@@ -661,11 +668,11 @@ bool t_rpc_command_executor::print_connections() {
for (auto & info : res.connections)
{
std::string address = info.incoming ? "INC " : "OUT ";
- address += info.ip + ":" + info.port;
+ address += info.address;
//std::string in_out = info.incoming ? "INC " : "OUT ";
tools::msg_writer()
//<< 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(6) << (info.ssl ? "yes" : "no")
<< std::setw(20) << info.peer_id