0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-25 16:22:35 +01:00

modules/console: Add net host cache SRV cmd to clear cache entry(s).

This commit is contained in:
Jason Volk 2018-09-13 19:39:02 -07:00
parent 8317773df0
commit 1768cd1041

View file

@ -2734,6 +2734,47 @@ console_cmd__net__host__cache__SRV__count(opt &out, const string_view &line)
return true;
}
bool
console_cmd__net__host__cache__SRV__clear(opt &out, const string_view &line)
{
const params param{line, " ",
{
"hostport", "[service]"
}};
if(!param.count())
{
const size_t size{net::dns::cache.SRV.size()};
net::dns::cache.SRV.clear();
out << size << std::endl;
return true;
}
const net::hostport hostport
{
param.at("hostport")
};
net::dns::opts opts;
opts.srv = param.at("[service]", "_matrix._tcp."_sv);
thread_local char srv_key_buf[128];
const auto srv_key
{
net::dns::make_SRV_key(srv_key_buf, hostport, opts)
};
out << srv_key << std::endl;
const auto ret
{
net::dns::cache.SRV.erase(srv_key)
};
out << ret << std::endl;
return true;
}
bool
console_cmd__net__host__prefetch(opt &out, const string_view &line)
{