add feature to client_test to print the local IP for peer connections (for multi-homing)

This commit is contained in:
arvidn 2020-01-09 17:39:50 +01:00 committed by Arvid Norberg
parent 1cdff958f1
commit 4d28ad0fea
1 changed files with 9 additions and 1 deletions

View File

@ -192,6 +192,7 @@ bool show_dht_status = false;
bool sequential_download = false;
bool print_ip = true;
bool print_local_ip = false;
bool print_timers = false;
bool print_block = false;
bool print_peer_rate = false;
@ -314,6 +315,7 @@ int print_peer_info(std::string& out
using namespace lt;
int pos = 0;
if (print_ip) out += "IP ";
if (print_local_ip) out += "local IP ";
out += "progress down (total | peak ) up (total | peak ) sent-req tmo bsy rcv flags dn up source ";
if (print_fails) out += "fail hshf ";
if (print_send_bufs) out += "rq sndb (recvb |alloc | wmrk ) q-bytes ";
@ -342,6 +344,11 @@ int print_peer_info(std::string& out
).c_str());
out += str;
}
if (print_local_ip)
{
std::snprintf(str, sizeof(str), "%-30s ", ::print_endpoint(i->local_endpoint).c_str());
out += str;
}
char temp[10];
std::snprintf(temp, sizeof(temp), "%d/%d"
@ -1603,6 +1610,7 @@ example alert_masks:
if (c == '5') print_peer_rate = !print_peer_rate;
if (c == '6') print_fails = !print_fails;
if (c == '7') print_send_bufs = !print_send_bufs;
if (c == '8') print_local_ip = !print_local_ip;
if (c == 'C')
{
cache_size = (cache_size == 0) ? -1 : 0;
@ -1643,7 +1651,7 @@ COLUMN OPTIONS
[1] toggle IP column [2] toggle show peer connection attempts
[3] toggle timers column [4] toggle block progress column
[5] toggle peer rate column [6] toggle failures column
[7] toggle send buffers column
[7] toggle send buffers column [8] toggle local IP column
)");
int tmp;
while (sleep_and_input(&tmp, lt::milliseconds(500)) == false);