1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

prevent crash

This commit is contained in:
Jeff Becker 2019-05-07 09:04:43 -04:00
parent 12589c4a3a
commit 61d42811be
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05
4 changed files with 16 additions and 11 deletions

View file

@ -277,7 +277,7 @@ namespace llarp
r->TryConnectAsync(results[0], 5);
});
}
else if(!BuildCooldownHit(now))
else if(ShouldBuildMore(now))
BuildOneAlignedTo(m_ExitRouter);
}
return true;

View file

@ -47,7 +47,7 @@ namespace llarp
/// return true if we are established
virtual bool
IsEstablished() = 0;
IsEstablished() const = 0;
/// return true if this session has timed out
virtual bool

View file

@ -221,12 +221,15 @@ namespace llarp
}
bool got = false;
router->ForEachPeer(
[&](const ILinkSession* s, bool) {
const PubKey k(s->GetPubKey());
if(got || router->IsBootstrapNode(k))
return;
cur = s->GetRemoteRC();
got = true;
[&](const ILinkSession* s, bool isOutbound) {
if(s && s->IsEstablished() && isOutbound && !got)
{
const RouterContact rc = s->GetRemoteRC();
if(got || router->IsBootstrapNode(rc.pubkey))
return;
cur = rc;
got = true;
}
},
true);
return got;
@ -328,7 +331,8 @@ namespace llarp
}
if(hops.size() == 0)
{
LogInfo(Name(), " building path to ", remote);
hops.resize(numHops);
auto nodedb = router->nodedb();
for(size_t hop = 0; hop < numHops; ++hop)
{
@ -362,6 +366,7 @@ namespace llarp
return false;
}
}
LogInfo(Name(), " building path to ", remote);
Build(hops);
return true;
}

View file

@ -120,9 +120,9 @@ namespace llarp
SendKeepAlive() override;
bool
IsEstablished() override
IsEstablished() const override
{
return state == eSessionReady || state == eLinkEstablished;
return state == eSessionReady;
}
bool