From db8972c0efdcf08d2000048e97cce574c5d6a1ba Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 13 Apr 2018 17:04:37 -0700 Subject: [PATCH] modules/console: Add client base command to explore the client::list. --- modules/console.cc | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/modules/console.cc b/modules/console.cc index 7d18b18a4..496fc1230 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -1104,6 +1104,53 @@ console_cmd__net__host__cache(opt &out, const string_view &line) } } +// +// client +// + +bool +console_cmd__client(opt &out, const string_view &line) +{ + for(const auto *const &client : ircd::client::list) + { + out << "client(" << (const void *)client << ")" + << " socket(" << client->sock.get() << ")" + << " " << local(*client) + << " " << remote(*client); + + if(bool(client->sock)) + { + const auto stat + { + net::bytes(*client->sock) + }; + + out << " OUT: " << stat.second + << " IN: " << stat.first; + } + + if(client->longpoll) + out << " LONGPOLL"; + + if(client->reqctx) + out << " CTX " << id(*client->reqctx); + + if(client->request.user_id) + out << " USER " << client->request.user_id; + + if(client->request.origin) + out << " PEER " << client->request.origin; + + if(client->request.head.method) + out << " " << client->request.head.method << "" + << " " << client->request.head.path; + + out << std::endl; + } + + return true; +} + // // key //