diff --git a/modules/console.cc b/modules/console.cc index 7940a603c..2c3f16d95 100644 --- a/modules/console.cc +++ b/modules/console.cc @@ -135,6 +135,7 @@ find_cmd(const string_view &line) struct opt { std::ostream &out; + bool html {false}; operator std::ostream &() { @@ -163,7 +164,12 @@ console_command(std::ostream &out, const string_view &opts) try { - opt opt{out}; + opt opt + { + out, + has(opts, "html") + }; + const cmd *const cmd { find_cmd(line) @@ -595,9 +601,61 @@ console_cmd__db__list(opt &out, const string_view &line) // net // +static bool +html__net__peer(opt &out, const string_view &line) +{ + out << ""; + + out << ""; + out << ""; + out << ""; + out << ""; + out << ""; + out << ""; + out << ""; + out << ""; + out << ""; + + 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 << ""; + + out << ""; + out << ""; + + out << ""; + out << ""; + out << ""; + out << ""; + + out << ""; + + out << ""; + } + + out << "
HOST ADDR LINKS REQS ▲ BYTES ▼ BYTES ERROR
" << host << "" << ipp << "" << peer.link_count() << "" << peer.tag_count() << "" << peer.write_total() << "" << peer.read_total() << ""; + if(peer.err_has() && peer.err_msg()) + out << peer.err_msg(); + else if(peer.err_has()) + out << ""_sv; + out << "
"; + return true; +} + bool console_cmd__net__peer(opt &out, const string_view &line) { + if(out.html) + return html__net__peer(out, line); + for(const auto &p : server::peers) { using std::setw; diff --git a/modules/s_control.cc b/modules/s_control.cc index 2520d6d9b..ba0a428bc 100644 --- a/modules/s_control.cc +++ b/modules/s_control.cc @@ -184,7 +184,8 @@ noexcept try pubsetbuf(out, buf); out << "
";
-	command(out, body, {});
+	static const string_view opts{"html"};
+	command(out, body, opts);
 	out << "
"; const auto str //TODO: X