mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
prevent crash
This commit is contained in:
parent
12589c4a3a
commit
61d42811be
4 changed files with 16 additions and 11 deletions
|
@ -277,7 +277,7 @@ namespace llarp
|
|||
r->TryConnectAsync(results[0], 5);
|
||||
});
|
||||
}
|
||||
else if(!BuildCooldownHit(now))
|
||||
else if(ShouldBuildMore(now))
|
||||
BuildOneAlignedTo(m_ExitRouter);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -120,9 +120,9 @@ namespace llarp
|
|||
SendKeepAlive() override;
|
||||
|
||||
bool
|
||||
IsEstablished() override
|
||||
IsEstablished() const override
|
||||
{
|
||||
return state == eSessionReady || state == eLinkEstablished;
|
||||
return state == eSessionReady;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Loading…
Reference in a new issue