|
|
@ -643,22 +643,32 @@ namespace llarp
|
|
|
|
Address addr;
|
|
|
|
Address addr;
|
|
|
|
introset.A.CalculateAddress(addr.data());
|
|
|
|
introset.A.CalculateAddress(addr.data());
|
|
|
|
|
|
|
|
|
|
|
|
// only add new session if it's not there
|
|
|
|
if(m_RemoteSessions.count(addr) >= MAX_OUTBOUND_CONTEXT_COUNT)
|
|
|
|
if(m_RemoteSessions.find(addr) == m_RemoteSessions.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OutboundContext* ctx = new OutboundContext(introset, this);
|
|
|
|
auto itr = m_RemoteSessions.find(addr);
|
|
|
|
m_RemoteSessions.insert(
|
|
|
|
|
|
|
|
std::make_pair(addr, std::unique_ptr< OutboundContext >(ctx)));
|
|
|
|
auto i = m_PendingServiceLookups.find(addr);
|
|
|
|
llarp::LogInfo("Created New outbound context for ", addr.ToString());
|
|
|
|
if(i != m_PendingServiceLookups.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto f = i->second;
|
|
|
|
|
|
|
|
m_PendingServiceLookups.erase(i);
|
|
|
|
|
|
|
|
f(addr, itr->second.get());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OutboundContext* ctx = new OutboundContext(introset, this);
|
|
|
|
|
|
|
|
m_RemoteSessions.insert(
|
|
|
|
|
|
|
|
std::make_pair(addr, std::unique_ptr< OutboundContext >(ctx)));
|
|
|
|
|
|
|
|
llarp::LogInfo("Created New outbound context for ", addr.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
// inform pending
|
|
|
|
// inform pending
|
|
|
|
auto itr = m_PendingServiceLookups.find(addr);
|
|
|
|
auto itr = m_PendingServiceLookups.find(addr);
|
|
|
|
if(itr != m_PendingServiceLookups.end())
|
|
|
|
if(itr != m_PendingServiceLookups.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto f = itr->second;
|
|
|
|
auto f = itr->second;
|
|
|
|
m_PendingServiceLookups.erase(itr);
|
|
|
|
m_PendingServiceLookups.erase(itr);
|
|
|
|
f(itr->first, m_RemoteSessions.at(addr).get());
|
|
|
|
f(addr, ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -917,10 +927,17 @@ namespace llarp
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
|
|
|
Endpoint::OutboundContext::ReadyToSend() const
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return GetPathByRouter(remoteIntro.router) != nullptr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
Endpoint::SendToOrQueue(const Address& remote, llarp_buffer_t data,
|
|
|
|
Endpoint::SendToOrQueue(const Address& remote, llarp_buffer_t data,
|
|
|
|
ProtocolType t)
|
|
|
|
ProtocolType t)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
// inbound converstation
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto itr = m_AddressToService.find(remote);
|
|
|
|
auto itr = m_AddressToService.find(remote);
|
|
|
|
if(itr != m_AddressToService.end())
|
|
|
|
if(itr != m_AddressToService.end())
|
|
|
@ -974,20 +991,31 @@ namespace llarp
|
|
|
|
llarp::LogError("failed to encrypt and sign");
|
|
|
|
llarp::LogError("failed to encrypt and sign");
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
llarp::LogDebug(Name(), " send ", data.sz, " via ", remoteIntro);
|
|
|
|
llarp::LogDebug(Name(), " send ", data.sz, " via ",
|
|
|
|
|
|
|
|
remoteIntro.router);
|
|
|
|
return p->SendRoutingMessage(&transfer, Router());
|
|
|
|
return p->SendRoutingMessage(&transfer, Router());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// outbound converstation
|
|
|
|
if(HasPathToService(remote))
|
|
|
|
if(HasPathToService(remote))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
llarp::LogDebug(Name(), " has session to ", remote, " sending ",
|
|
|
|
auto range = m_RemoteSessions.equal_range(remote);
|
|
|
|
data.sz, " bytes");
|
|
|
|
auto itr = range.first;
|
|
|
|
auto itr = m_RemoteSessions.find(remote);
|
|
|
|
while(itr != range.second)
|
|
|
|
itr->second->AsyncEncryptAndSendTo(data, t);
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
if(itr->second->ReadyToSend())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
itr->second->AsyncEncryptAndSendTo(data, t);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
++itr;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// all paths are not ready?
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// no converstation
|
|
|
|
auto itr = m_PendingTraffic.find(remote);
|
|
|
|
auto itr = m_PendingTraffic.find(remote);
|
|
|
|
if(itr == m_PendingTraffic.end())
|
|
|
|
if(itr == m_PendingTraffic.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1227,8 +1255,8 @@ namespace llarp
|
|
|
|
routing::PathTransferMessage transfer(msg, remoteIntro.pathID);
|
|
|
|
routing::PathTransferMessage transfer(msg, remoteIntro.pathID);
|
|
|
|
if(path->SendRoutingMessage(&transfer, m_Endpoint->Router()))
|
|
|
|
if(path->SendRoutingMessage(&transfer, m_Endpoint->Router()))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
llarp::LogInfo("sent data to ", remoteIntro.pathID, " on ",
|
|
|
|
llarp::LogDebug("sent data to ", remoteIntro.pathID, " on ",
|
|
|
|
remoteIntro.router);
|
|
|
|
remoteIntro.router);
|
|
|
|
lastGoodSend = now;
|
|
|
|
lastGoodSend = now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|