try deferred resolve for exit handler

pull/737/head
Jeff Becker 5 years ago
parent 697ece64cc
commit b29ec20ad4
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -171,10 +171,20 @@ namespace llarp
} }
else if(m_SNodeKeys.find(pubKey) == m_SNodeKeys.end()) else if(m_SNodeKeys.find(pubKey) == m_SNodeKeys.end())
{ {
// we do not have it mapped // we do not have it mapped, async obtain it
// map it ObtainSNodeSession(
ip = ObtainServiceNodeIP(r); r, [&](std::shared_ptr< exit::BaseSession > session) {
msg.AddINReply(ip, isV6); if(session && session->IsReady())
{
msg.AddINReply(m_KeyToIP[pubKey], isV6);
}
else
{
msg.AddNXReply();
}
reply(msg);
});
return;
} }
else else
{ {
@ -196,6 +206,14 @@ namespace llarp
return true; return true;
} }
void
ExitEndpoint::ObtainSNodeSession(const RouterID &router,
exit::SessionReadyFunc obtainCb)
{
ObtainServiceNodeIP(router);
m_SNodeSessions[router]->AddReadyHook(obtainCb);
}
llarp_time_t llarp_time_t
ExitEndpoint::Now() const ExitEndpoint::Now() const
{ {

@ -120,6 +120,11 @@ namespace llarp
huint128_t huint128_t
ObtainServiceNodeIP(const RouterID& router); ObtainServiceNodeIP(const RouterID& router);
/// async obtain snode session and call callback when it's ready to send
void
ObtainSNodeSession(const RouterID& router,
exit::SessionReadyFunc obtainCb);
bool bool
QueueSNodePacket(const llarp_buffer_t& buf, huint128_t from); QueueSNodePacket(const llarp_buffer_t& buf, huint128_t from);

Loading…
Cancel
Save