limit number of snode sessions client side

pull/1014/head
Jeff Becker 5 years ago
parent 4126d307b3
commit 79c3c748e4
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -494,12 +494,11 @@ namespace llarp
else
{
auto *replyMsg = new dns::Message(std::move(msg));
EnsurePathToSNode(addr.as_array(),
[=](const RouterID &, exit::BaseSession_ptr s) {
SendDNSReply(addr, s, replyMsg, reply, true,
isV6);
});
return true;
return EnsurePathToSNode(
addr.as_array(),
[=](const RouterID &, exit::BaseSession_ptr s) {
SendDNSReply(addr, s, replyMsg, reply, true, isV6);
});
}
}
else

@ -1019,10 +1019,17 @@ namespace llarp
return false;
}
void
bool
Endpoint::EnsurePathToSNode(const RouterID snode, SNodeEnsureHook h)
{
static constexpr size_t MaxConcurrentSNodeSessions = 16;
auto& nodeSessions = m_state->m_SNodeSessions;
if(nodeSessions.size() >= MaxConcurrentSNodeSessions)
{
// a quick client side work arround before we do proper limiting
LogError(Name(), " has too many snode sessions");
return false;
}
using namespace std::placeholders;
if(nodeSessions.count(snode) == 0)
{
@ -1054,6 +1061,7 @@ namespace llarp
}
++itr;
}
return true;
}
bool

@ -294,7 +294,7 @@ namespace llarp
std::function< void(const RouterID, exit::BaseSession_ptr) >;
/// ensure a path to a service node by public key
void
bool
EnsurePathToSNode(const RouterID remote, SNodeEnsureHook h);
/// return true if this endpoint is trying to lookup this router right now

@ -96,20 +96,13 @@ namespace llarp
return true;
}
auto now = Now();
const llarp_time_t now = Now();
if(i->IsExpired(now))
{
LogError("got expired introset from lookup from ", endpoint);
return true;
}
currentIntroSet = *i;
if(!ShiftIntroduction())
{
LogWarn("failed to pick new intro during introset update");
}
if(GetPathByRouter(m_NextIntro.router) == nullptr
&& !BuildCooldownHit(Now()))
BuildOneAlignedTo(m_NextIntro.router);
}
else
{
@ -222,14 +215,21 @@ namespace llarp
{
if(updatingIntroSet || markedBad)
return;
auto addr = currentIntroSet.A.Addr();
const auto addr = currentIntroSet.A.Addr();
path::Path_ptr path = nullptr;
if(randomizePath)
{
path = m_Endpoint->PickRandomEstablishedPath();
}
else
path = m_Endpoint->GetEstablishedPathClosestTo(addr.as_array());
if(path == nullptr)
{
path = PickRandomEstablishedPath();
}
if(path)
{
HiddenServiceAddressLookup* job = new HiddenServiceAddressLookup(

Loading…
Cancel
Save