diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2021-12-09 22:45:43 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2021-12-09 22:45:59 +0100 |
commit | 380f8e539d73f37c2ef5d7133d3e1b6dda105f4a (patch) | |
tree | 505f743d8de3e1fcb20f10e99ab56f81feae8461 /src/main.cpp | |
parent | 1cef5fc2744d2428f28976c7adb0f476d8bc3bcf (diff) |
Test: distinguish address and identity info for peers
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
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 <erebos/storage.h> #include <erebos/sync.h> +#include <arpa/inet.h> +#include <netinet/in.h> +#include <sys/socket.h> + #include <filesystem> #include <functional> #include <future> @@ -140,11 +144,16 @@ void startServer(const vector<string> &) 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() : "<unnamed>"); + } else { + const auto & paddr = peer->address(); + ss << " addr " << inet_ntoa(paddr.sin_addr) << " " << ntohs(paddr.sin_port); + } } else { ss << " deleted"; } |