|
|
|
@ -491,6 +491,28 @@ namespace llarp
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Endpoint::PutReplyIntroFor(const ConvoTag& tag, const Introduction& intro)
|
|
|
|
|
{
|
|
|
|
|
auto itr = m_Sessions.find(tag);
|
|
|
|
|
if(itr == m_Sessions.end())
|
|
|
|
|
{
|
|
|
|
|
itr = m_Sessions.emplace(tag, Session{}).first;
|
|
|
|
|
}
|
|
|
|
|
itr->second.replyIntro = intro;
|
|
|
|
|
itr->second.lastUsed = Now();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
Endpoint::GetReplyIntroFor(const ConvoTag& tag, Introduction& intro) const
|
|
|
|
|
{
|
|
|
|
|
auto itr = m_Sessions.find(tag);
|
|
|
|
|
if(itr == m_Sessions.end())
|
|
|
|
|
return false;
|
|
|
|
|
intro = itr->second.replyIntro;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
Endpoint::GetConvoTagsForService(const ServiceInfo& info,
|
|
|
|
|
std::set< ConvoTag >& tags) const
|
|
|
|
@ -898,11 +920,10 @@ namespace llarp
|
|
|
|
|
Endpoint::HandleDataMessage(const PathID_t& src, ProtocolMessage* msg)
|
|
|
|
|
{
|
|
|
|
|
auto path = GetPathByID(src);
|
|
|
|
|
if(path == nullptr)
|
|
|
|
|
return false;
|
|
|
|
|
if(path)
|
|
|
|
|
PutReplyIntroFor(msg->tag, path->intro);
|
|
|
|
|
msg->sender.UpdateAddr();
|
|
|
|
|
PutIntroFor(msg->tag, msg->introReply);
|
|
|
|
|
PutSenderFor(msg->tag, path->intro);
|
|
|
|
|
EnsureReplyPath(msg->sender);
|
|
|
|
|
return ProcessDataMessage(msg);
|
|
|
|
|
}
|
|
|
|
@ -1277,7 +1298,8 @@ namespace llarp
|
|
|
|
|
ProtocolMessage m(f.T);
|
|
|
|
|
m.proto = t;
|
|
|
|
|
m.introReply = p->intro;
|
|
|
|
|
m.sender = m_Identity.pub;
|
|
|
|
|
PutReplyIntroFor(f.T, m.introReply);
|
|
|
|
|
m.sender = m_Identity.pub;
|
|
|
|
|
m.PutBuffer(data);
|
|
|
|
|
f.N.Randomize();
|
|
|
|
|
f.S = GetSeqNoForConvo(f.T);
|
|
|
|
@ -1611,11 +1633,12 @@ namespace llarp
|
|
|
|
|
|
|
|
|
|
ex->msg.PutBuffer(payload);
|
|
|
|
|
ex->msg.introReply = path->intro;
|
|
|
|
|
m_DataHandler->PutReplyIntroFor(currentConvoTag, path->intro);
|
|
|
|
|
llarp_threadpool_queue_job(m_Endpoint->Worker(),
|
|
|
|
|
{ex, &AsyncKeyExchange::Encrypt});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
bool
|
|
|
|
|
Endpoint::SendContext::Send(ProtocolFrame& msg)
|
|
|
|
|
{
|
|
|
|
|
auto path = m_PathSet->GetPathByRouter(remoteIntro.router);
|
|
|
|
@ -1630,6 +1653,7 @@ namespace llarp
|
|
|
|
|
remoteIntro.router);
|
|
|
|
|
lastGoodSend = m_Endpoint->Now();
|
|
|
|
|
++sequenceNo;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
llarp::LogError("Failed to send frame on path");
|
|
|
|
@ -1637,6 +1661,7 @@ namespace llarp
|
|
|
|
|
else
|
|
|
|
|
llarp::LogError("cannot send because we have no path to ",
|
|
|
|
|
remoteIntro.router);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string
|
|
|
|
@ -1843,8 +1868,12 @@ namespace llarp
|
|
|
|
|
if(m_DataHandler->GetCachedSessionKeyFor(f.T, shared))
|
|
|
|
|
{
|
|
|
|
|
ProtocolMessage m;
|
|
|
|
|
m.proto = t;
|
|
|
|
|
m.introReply = path->intro;
|
|
|
|
|
m.proto = t;
|
|
|
|
|
if(!m_DataHandler->GetReplyIntroFor(f.T, m.introReply))
|
|
|
|
|
{
|
|
|
|
|
m_DataHandler->PutReplyIntroFor(f.T, path->intro);
|
|
|
|
|
m.introReply = path->intro;
|
|
|
|
|
}
|
|
|
|
|
m_DataHandler->PutIntroFor(f.T, remoteIntro);
|
|
|
|
|
m.sender = m_Endpoint->m_Identity.pub;
|
|
|
|
|
m.PutBuffer(payload);
|
|
|
|
@ -1864,11 +1893,11 @@ namespace llarp
|
|
|
|
|
|
|
|
|
|
msg.P = remoteIntro.pathID;
|
|
|
|
|
msg.Y.Randomize();
|
|
|
|
|
++sequenceNo;
|
|
|
|
|
if(path->SendRoutingMessage(&msg, m_Endpoint->Router()))
|
|
|
|
|
{
|
|
|
|
|
llarp::LogDebug("sent message via ", remoteIntro.pathID, " on ",
|
|
|
|
|
remoteIntro.router);
|
|
|
|
|
++sequenceNo;
|
|
|
|
|
lastGoodSend = now;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|