mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
plug in RC/RouterID fetch handlers in LinkManager
This commit is contained in:
parent
0a7c122a46
commit
a209182016
|
@ -160,16 +160,12 @@ namespace llarp
|
||||||
[this, msg = std::move(m)]() mutable { handle_gossip_rc(std::move(msg)); });
|
[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(
|
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 {
|
_router.loop()->call([this, msg = std::move(m), func = std::move(func)]() mutable {
|
||||||
auto body = msg.body_str();
|
std::invoke(func, this, std::move(msg));
|
||||||
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));
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,13 +345,12 @@ namespace llarp
|
||||||
|
|
||||||
// these requests are direct, i.e. not over a path;
|
// these requests are direct, i.e. not over a path;
|
||||||
// the rest are relay->relay
|
// the rest are relay->relay
|
||||||
// TODO: new RC fetch endpoint (which will be both client->relay and relay->relay)
|
|
||||||
std::unordered_map<
|
std::unordered_map<
|
||||||
std::string_view,
|
std::string_view,
|
||||||
void (LinkManager::*)(std::string_view body, std::function<void(std::string)> respond)>
|
void (LinkManager::*)(oxen::quic::message m)>
|
||||||
direct_requests = {
|
direct_requests = {
|
||||||
{"publish_intro"sv, &LinkManager::handle_publish_intro},
|
{"fetch_rcs"sv, &LinkManager::handle_fetch_rcs},
|
||||||
{"find_intro"sv, &LinkManager::handle_find_intro}};
|
{"fetch_router_ids"sv, &LinkManager::handle_fetch_router_ids}};
|
||||||
|
|
||||||
// Path relaying
|
// Path relaying
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue