plug in RC/RouterID fetch handlers in LinkManager

This commit is contained in:
Thomas Winget 2023-11-28 20:34:35 -05:00
parent 0a7c122a46
commit a209182016
2 changed files with 6 additions and 11 deletions

View File

@ -160,16 +160,12 @@ namespace llarp
[this, msg = std::move(m)]() mutable { handle_gossip_rc(std::move(msg)); });
});
for (auto& method : direct_requests)
for (auto& [method, callback] : direct_requests)
{
s->register_command(
std::string{method.first}, [this, func = method.second](oxen::quic::message m) {
std::string{method}, [this, func = callback](oxen::quic::message m) {
_router.loop()->call([this, msg = std::move(m), func = std::move(func)]() mutable {
auto body = msg.body_str();
auto respond = [m = std::move(msg)](std::string response) mutable {
m.respond(std::move(response), not m);
};
std::invoke(func, this, body, std::move(respond));
std::invoke(func, this, std::move(msg));
});
});
}

View File

@ -345,13 +345,12 @@ namespace llarp
// these requests are direct, i.e. not over a path;
// the rest are relay->relay
// TODO: new RC fetch endpoint (which will be both client->relay and relay->relay)
std::unordered_map<
std::string_view,
void (LinkManager::*)(std::string_view body, std::function<void(std::string)> respond)>
void (LinkManager::*)(oxen::quic::message m)>
direct_requests = {
{"publish_intro"sv, &LinkManager::handle_publish_intro},
{"find_intro"sv, &LinkManager::handle_find_intro}};
{"fetch_rcs"sv, &LinkManager::handle_fetch_rcs},
{"fetch_router_ids"sv, &LinkManager::handle_fetch_router_ids}};
// Path relaying
void