mirror of
https://github.com/matrix-construct/construct
synced 2024-10-02 13:48:53 +02:00
modules/console: Add peer close cmd.
This commit is contained in:
parent
0f4270e91a
commit
9787885ca4
1 changed files with 45 additions and 0 deletions
|
@ -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
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue