From 380f8e539d73f37c2ef5d7133d3e1b6dda105f4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 9 Dec 2021 22:45:43 +0100 Subject: Test: distinguish address and identity info for peers --- src/main.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index a3805e0..b061747 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,10 @@ #include #include +#include +#include +#include + #include #include #include @@ -140,11 +144,16 @@ void startServer(const vector &) server->peerList().onUpdate([](size_t idx, const Peer * peer) { ostringstream ss; - ss << "peer " << idx; + ss << "peer " << idx + 1; if (peer) { - ss << " " << peer->name(); - if (peer->identity() && peer->identity()->name()) - ss << " " << *peer->identity()->name(); + if (peer->identity()) { + ss << " id"; + for (auto idt = peer->identity(); idt; idt = idt->owner()) + ss << " " << (idt->name() ? *idt->name() : ""); + } else { + const auto & paddr = peer->address(); + ss << " addr " << inet_ntoa(paddr.sin_addr) << " " << ntohs(paddr.sin_port); + } } else { ss << " deleted"; } -- cgit v1.2.3