mirror of
https://github.com/matrix-construct/construct
synced 2024-11-26 00:32:35 +01:00
ircd:Ⓜ️:keys: Add an iteration over node's cached keys.
This commit is contained in:
parent
cf3b1218c4
commit
fcbd31f672
3 changed files with 57 additions and 0 deletions
|
@ -66,6 +66,7 @@ struct ircd::m::keys
|
|||
|
||||
struct ircd::m::keys::cache
|
||||
{
|
||||
static bool for_each(const string_view &server, const closure_bool &);
|
||||
static bool get(const string_view &server, const string_view &key_id, const closure &);
|
||||
static size_t set(const json::object &keys);
|
||||
};
|
||||
|
|
|
@ -5469,6 +5469,33 @@ console_cmd__key__get(opt &out, const string_view &line)
|
|||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// keys
|
||||
//
|
||||
|
||||
bool
|
||||
console_cmd__keys(opt &out, const string_view &line)
|
||||
{
|
||||
const params param{line, " ",
|
||||
{
|
||||
"server_name"
|
||||
}};
|
||||
|
||||
const auto &server_name
|
||||
{
|
||||
param.at("server_name")
|
||||
};
|
||||
|
||||
m::keys::cache::for_each(server_name, [&out]
|
||||
(const json::object &object)
|
||||
{
|
||||
out << object << std::endl;
|
||||
return true;
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
// stage
|
||||
//
|
||||
|
|
|
@ -352,6 +352,35 @@ ircd::m::keys::cache::get(const string_view &server_name,
|
|||
node_room.get(std::nothrow, "ircd.key", key_id, reclosure);
|
||||
}
|
||||
|
||||
bool
|
||||
IRCD_MODULE_EXPORT
|
||||
ircd::m::keys::cache::for_each(const string_view &server_name,
|
||||
const keys::closure_bool &closure)
|
||||
{
|
||||
const m::node::room node_room
|
||||
{
|
||||
server_name
|
||||
};
|
||||
|
||||
const m::room::state state
|
||||
{
|
||||
node_room
|
||||
};
|
||||
|
||||
return state.for_each("ircd.key", [&closure]
|
||||
(const auto &type, const auto &key_id, const auto event_idx)
|
||||
{
|
||||
bool ret{true};
|
||||
m::get(std::nothrow, event_idx, "content", [&closure, &ret]
|
||||
(const json::object &content)
|
||||
{
|
||||
ret = closure(content);
|
||||
});
|
||||
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// (internal) ed25519 support sanity test
|
||||
|
|
Loading…
Reference in a new issue