send link layer keep alive and track bad intros

pull/15/head
Jeff Becker 6 years ago
parent 1eda28a2da
commit 96716a39ef
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -211,6 +211,10 @@ namespace llarp
void
ShiftIntroduction();
/// mark the current remote intro as bad
void
MarkCurrentIntroBad();
/// tick internal state
/// return true to remove otherwise don't remove
bool
@ -253,6 +257,7 @@ namespace llarp
uint64_t m_UpdateIntrosetTX = 0;
IntroSet currentIntroSet;
std::set< Introduction > m_BadIntros;
};
// passed a sendto context when we have a path established otherwise

@ -562,7 +562,6 @@ namespace llarp
recvMsgOffset = 0;
SendKeepAlive = [&]() -> bool {
/*
if(sendq.size() == 0 && state == eSessionReady)
{
DiscardMessage msg;
@ -575,7 +574,6 @@ namespace llarp
if(!this->QueueWriteBuffers(buf))
return false;
}
*/
return true;
};
gotLIM = false;

@ -954,6 +954,12 @@ namespace llarp
return true;
}
void
Endpoint::OutboundContext::MarkCurrentIntroBad()
{
m_BadIntros.insert(remoteIntro);
}
void
Endpoint::OutboundContext::ShiftIntroduction()
{
@ -961,31 +967,15 @@ namespace llarp
for(const auto& intro : currentIntroSet.I)
{
m_Endpoint->EnsureRouterIsKnown(remoteIntro.router);
if(remoteIntro.expiresAt < intro.expiresAt)
if(m_BadIntros.count(intro) == 0)
{
remoteIntro = intro;
shifted = true;
}
}
if(!shifted)
{
RouterID orig = remoteIntro.router;
remoteIntro.Clear();
for(const auto& intro : currentIntroSet.I)
{
if(remoteIntro.expiresAt < intro.expiresAt && intro.router == orig)
{
remoteIntro = intro;
shifted = true;
break;
}
break;
}
}
if(shifted)
{
llarp::LogInfo("shifted intro to ", remoteIntro);
ManualRebuild(1);
}
}
void
@ -1122,6 +1112,7 @@ namespace llarp
auto path = m_PathSet->GetPathByID(p);
if(path)
{
llarp::LogInfo(m_Endpoint->Name(), " send via ", p);
routing::PathTransferMessage transfer(msg, remoteIntro.pathID);
if(!path->SendRoutingMessage(&transfer, m_Endpoint->Router()))
llarp::LogError("Failed to send frame on path");
@ -1167,9 +1158,14 @@ namespace llarp
{
if(remoteIntro.ExpiresSoon(now))
{
MarkCurrentIntroBad();
ShiftIntroduction();
}
m_Endpoint->EnsureRouterIsKnown(remoteIntro.router);
std::remove_if(m_BadIntros.begin(), m_BadIntros.end(),
[now](const Introduction& intro) -> bool {
return intro.IsExpired(now);
});
// TODO: check for expiration of outbound context
return false;
}

Loading…
Cancel
Save