prevent crash

pull/598/head
Jeff Becker 5 years ago
parent 12589c4a3a
commit 61d42811be
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

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

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

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

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

Loading…
Cancel
Save