mirror of
https://github.com/matrix-construct/construct
synced 2024-07-10 12:38:36 +02:00
modules/console: Add argument to list single peer; left justify hostname.
This commit is contained in:
parent
ae3eede730
commit
289f9faf4a
|
@ -2013,25 +2013,15 @@ console_cmd__peer(opt &out, const string_view &line)
|
||||||
if(out.html)
|
if(out.html)
|
||||||
return html__peer(out, line);
|
return html__peer(out, line);
|
||||||
|
|
||||||
const bool all
|
const auto print{[&out]
|
||||||
{
|
(const auto &host, const auto &peer)
|
||||||
has(line, "all")
|
|
||||||
};
|
|
||||||
|
|
||||||
for(const auto &p : server::peers)
|
|
||||||
{
|
{
|
||||||
using std::setw;
|
using std::setw;
|
||||||
using std::left;
|
using std::left;
|
||||||
using std::right;
|
using std::right;
|
||||||
|
|
||||||
const auto &host{p.first};
|
|
||||||
const auto &peer{*p.second};
|
|
||||||
const net::ipport &ipp{peer.remote};
|
const net::ipport &ipp{peer.remote};
|
||||||
|
out << setw(40) << left << host;
|
||||||
if(peer.err_has() && !all)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
out << setw(40) << right << host;
|
|
||||||
|
|
||||||
if(ipp)
|
if(ipp)
|
||||||
out << ' ' << setw(22) << left << ipp;
|
out << ' ' << setw(22) << left << ipp;
|
||||||
|
@ -2053,6 +2043,42 @@ console_cmd__peer(opt &out, const string_view &line)
|
||||||
out << " <unknown error>"_sv;
|
out << " <unknown error>"_sv;
|
||||||
|
|
||||||
out << std::endl;
|
out << std::endl;
|
||||||
|
}};
|
||||||
|
|
||||||
|
const params param{line, " ",
|
||||||
|
{
|
||||||
|
"[hostport]", "[all]"
|
||||||
|
}};
|
||||||
|
|
||||||
|
const auto &hostport
|
||||||
|
{
|
||||||
|
param[0]
|
||||||
|
};
|
||||||
|
|
||||||
|
const bool all
|
||||||
|
{
|
||||||
|
has(line, "all")
|
||||||
|
};
|
||||||
|
|
||||||
|
if(hostport && hostport != "all")
|
||||||
|
{
|
||||||
|
auto &peer
|
||||||
|
{
|
||||||
|
server::find(hostport)
|
||||||
|
};
|
||||||
|
|
||||||
|
print(peer.hostname, peer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(const auto &p : server::peers)
|
||||||
|
{
|
||||||
|
const auto &host{p.first};
|
||||||
|
const auto &peer{*p.second};
|
||||||
|
if(peer.err_has() && !all)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
print(host, peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue