0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-02 16:58:19 +02:00

modules/console: Add peer close cmd.

This commit is contained in:
Jason Volk 2018-05-30 03:13:36 -07:00
parent 0f4270e91a
commit 9787885ca4

View file

@ -2228,6 +2228,51 @@ catch(const std::out_of_range &e)
};
}
bool
console_cmd__peer__close(opt &out, const string_view &line)
try
{
const params param{line, " ",
{
"hostport", "[dc]"
}};
const auto &hostport
{
param.at(0)
};
const auto &dc
{
param.at(1, "SSL_NOTIFY"_sv)
};
auto &peer
{
server::find(hostport)
};
const net::close_opts opts
{
dc == "RST"?
net::dc::RST:
dc == "SSL_NOTIFY"?
net::dc::SSL_NOTIFY:
net::dc::SSL_NOTIFY
};
peer.close(opts);
peer.err_clear();
return true;
}
catch(const std::out_of_range &e)
{
throw error
{
"Peer not found"
};
}
//
// net
//