|
|
|
@ -44,8 +44,6 @@ namespace llarp
|
|
|
|
|
if(MarkCurrentIntroBad(Now()))
|
|
|
|
|
{
|
|
|
|
|
SwapIntros();
|
|
|
|
|
LogInfo(Name(), " switched intros to ", remoteIntro.router, " via ",
|
|
|
|
|
remoteIntro.pathID);
|
|
|
|
|
}
|
|
|
|
|
UpdateIntroSet(true);
|
|
|
|
|
}
|
|
|
|
@ -53,13 +51,13 @@ namespace llarp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
OutboundContext::OutboundContext(const IntroSet& introset, Endpoint* parent)
|
|
|
|
|
: path::Builder(parent->Router(), 3, path::default_len)
|
|
|
|
|
: path::Builder(parent->Router(), 4, path::default_len)
|
|
|
|
|
, SendContext(introset.A, {}, this, parent)
|
|
|
|
|
, currentIntroSet(introset)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
updatingIntroSet = false;
|
|
|
|
|
for(const auto intro : introset.I)
|
|
|
|
|
for(const auto& intro : introset.I)
|
|
|
|
|
{
|
|
|
|
|
if(intro.expiresAt > m_NextIntro.expiresAt)
|
|
|
|
|
m_NextIntro = intro;
|
|
|
|
@ -75,6 +73,7 @@ namespace llarp
|
|
|
|
|
{
|
|
|
|
|
if(remoteIntro != m_NextIntro)
|
|
|
|
|
{
|
|
|
|
|
LogInfo(Name(), " swap intro to use ", RouterID(m_NextIntro.router));
|
|
|
|
|
remoteIntro = m_NextIntro;
|
|
|
|
|
m_DataHandler->PutIntroFor(currentConvoTag, remoteIntro);
|
|
|
|
|
ShiftIntroduction(false);
|
|
|
|
@ -114,7 +113,10 @@ namespace llarp
|
|
|
|
|
BuildOneAlignedTo(m_NextIntro.router);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
++m_LookupFails;
|
|
|
|
|
LogWarn(Name(), " failed to look up introset, fails=", m_LookupFails);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -125,6 +127,32 @@ namespace llarp
|
|
|
|
|
&& GetPathByRouter(remoteIntro.router) != nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
OutboundContext::ShiftIntroRouter(const RouterID r)
|
|
|
|
|
{
|
|
|
|
|
const auto now = Now();
|
|
|
|
|
Introduction selectedIntro;
|
|
|
|
|
for(const auto& intro : currentIntroSet.I)
|
|
|
|
|
{
|
|
|
|
|
if(intro.expiresAt > selectedIntro.expiresAt && intro.router != r)
|
|
|
|
|
{
|
|
|
|
|
selectedIntro = intro;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(selectedIntro.router.IsZero() || selectedIntro.ExpiresSoon(now))
|
|
|
|
|
return;
|
|
|
|
|
LogWarn(Name(), " shfiting intro off of ", r, " to ",
|
|
|
|
|
RouterID(selectedIntro.router));
|
|
|
|
|
m_NextIntro = selectedIntro;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
OutboundContext::HandlePathBuildTimeout(path::Path_ptr p)
|
|
|
|
|
{
|
|
|
|
|
ShiftIntroRouter(p->Endpoint());
|
|
|
|
|
path::Builder::HandlePathBuildTimeout(p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
OutboundContext::HandlePathBuilt(path::Path_ptr p)
|
|
|
|
|
{
|
|
|
|
@ -138,6 +166,10 @@ namespace llarp
|
|
|
|
|
// we now have a path to the next intro, swap intros
|
|
|
|
|
if(p->Endpoint() == m_NextIntro.router)
|
|
|
|
|
SwapIntros();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LogInfo(Name(), " built to non aligned router: ", p->Endpoint());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
@ -241,6 +273,7 @@ namespace llarp
|
|
|
|
|
// we are probably dead af
|
|
|
|
|
if(m_LookupFails > 16 || m_BuildFails > 10)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
// check for expiration
|
|
|
|
|
if(remoteIntro.ExpiresSoon(now))
|
|
|
|
|
{
|
|
|
|
@ -296,9 +329,10 @@ namespace llarp
|
|
|
|
|
{
|
|
|
|
|
if(m_NextIntro.router.IsZero() || prev.count(m_NextIntro.router))
|
|
|
|
|
{
|
|
|
|
|
if(!ShiftIntroduction(false))
|
|
|
|
|
return false;
|
|
|
|
|
ShiftIntroduction(false);
|
|
|
|
|
}
|
|
|
|
|
if(m_NextIntro.router.IsZero())
|
|
|
|
|
return false;
|
|
|
|
|
std::set< RouterID > exclude = prev;
|
|
|
|
|
exclude.insert(m_NextIntro.router);
|
|
|
|
|
for(const auto& snode : m_Endpoint->SnodeBlacklist())
|
|
|
|
@ -337,9 +371,15 @@ namespace llarp
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
OutboundContext::MarkCurrentIntroBad(llarp_time_t now)
|
|
|
|
|
{
|
|
|
|
|
return MarkIntroBad(remoteIntro, now);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
OutboundContext::MarkIntroBad(const Introduction& intro, llarp_time_t now)
|
|
|
|
|
{
|
|
|
|
|
// insert bad intro
|
|
|
|
|
m_BadIntros[remoteIntro] = now;
|
|
|
|
|
m_BadIntros[intro] = now;
|
|
|
|
|
// try shifting intro without rebuild
|
|
|
|
|
if(ShiftIntroduction(false))
|
|
|
|
|
{
|
|
|
|
|