From 907f2d0435a5fd49c568835371d674468b17233d Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sat, 24 Mar 2018 18:06:03 -0700 Subject: [PATCH] modules/console: Add net__peer__version to list all gathered peer.server_name. --- modules/console.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/modules/console.cc b/modules/console.cc index bf872c168..f77458660 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -513,6 +513,7 @@ console_cmd__net(const string_view &line) } } +static bool console_cmd__net__peer__version(const string_view &line); static bool console_cmd__net_peer__clear(const string_view &line); static bool console_cmd__net_peer__default(); @@ -532,6 +533,9 @@ console_cmd__net_peer(const string_view &line) case hash("clear"): return console_cmd__net_peer__clear(args); + case hash("version"): + return console_cmd__net__peer__version(args); + default: throw bad_command{}; } @@ -556,6 +560,35 @@ console_cmd__net_peer__clear(const string_view &line) return true; } +bool +console_cmd__net__peer__version(const string_view &line) +{ + for(const auto &p : server::peers) + { + using std::setw; + using std::left; + using std::right; + + const auto &host{p.first}; + const auto &peer{*p.second}; + const net::ipport &ipp{peer.remote}; + + out << setw(40) << right << host; + + if(ipp) + out << ' ' << setw(22) << left << ipp; + else + out << ' ' << setw(22) << left << " "; + + if(!empty(peer.server_name)) + out << " :" << peer.server_name; + + out << std::endl; + } + + return true; +} + bool console_cmd__net_peer__default() {