Browse Source

pick compatible tunnels

pull/1705/head
orignal 3 years ago
parent
commit
f8c390cdd3
  1. 2
      libi2pd/Destination.cpp
  2. 8
      libi2pd/NetDb.cpp
  3. 30
      libi2pd/TunnelPool.cpp

2
libi2pd/Destination.cpp

@ -562,7 +562,6 @@ namespace client @@ -562,7 +562,6 @@ namespace client
m_ExcludedFloodfills.clear ();
return;
}
m_ExcludedFloodfills.insert (floodfill->GetIdentHash ());
auto outbound = m_Pool->GetNextOutboundTunnel (nullptr, floodfill->GetCompatibleTransports (false));
if (!outbound)
{
@ -575,6 +574,7 @@ namespace client @@ -575,6 +574,7 @@ namespace client
LogPrint (eLogError, "Destination: Can't publish LeaseSet. No inbound tunnels");
return;
}
m_ExcludedFloodfills.insert (floodfill->GetIdentHash ());
LogPrint (eLogDebug, "Destination: Publish LeaseSet of ", GetIdentHash ().ToBase32 ());
RAND_bytes ((uint8_t *)&m_PublishReplyToken, 4);
auto msg = WrapMessageForRouter (floodfill, i2p::CreateDatabaseStoreMsg (leaseSet, m_PublishReplyToken, inbound));

8
libi2pd/NetDb.cpp

@ -681,8 +681,8 @@ namespace data @@ -681,8 +681,8 @@ namespace data
else
{
auto pool = i2p::tunnel::tunnels.GetExploratoryPool ();
auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr;
auto inbound = pool ? pool->GetNextInboundTunnel () : nullptr;
auto outbound = pool ? pool->GetNextOutboundTunnel (nullptr, floodfill->GetCompatibleTransports (false)) : nullptr;
auto inbound = pool ? pool->GetNextInboundTunnel (nullptr, floodfill->GetCompatibleTransports (true)) : nullptr;
if (outbound && inbound)
outbound->SendTunnelDataMsg (floodfill->GetIdentHash (), 0, dest->CreateRequestMessage (floodfill, inbound));
else
@ -1129,8 +1129,8 @@ namespace data @@ -1129,8 +1129,8 @@ namespace data
{
// otherwise through exploratory
auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool ();
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : nullptr;
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : nullptr;
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel (nullptr, floodfill->GetCompatibleTransports (false)) : nullptr;
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel (nullptr, floodfill->GetCompatibleTransports (true)) : nullptr;
if (inbound && outbound)
outbound->SendTunnelDataMsg (floodfill->GetIdentHash (), 0,
CreateDatabaseStoreMsg (i2p::context.GetSharedRouterInfo (), replyToken, inbound));

30
libi2pd/TunnelPool.cpp

@ -498,9 +498,8 @@ namespace tunnel @@ -498,9 +498,8 @@ namespace tunnel
}
prevHop = hop;
path.Add (hop);
if (i == numHops - 1)
path.farEndTransports = hop->GetCompatibleTransports (inbound);
}
path.farEndTransports = prevHop->GetCompatibleTransports (inbound); // last hop
return true;
}
@ -555,13 +554,13 @@ namespace tunnel @@ -555,13 +554,13 @@ namespace tunnel
void TunnelPool::CreateInboundTunnel ()
{
auto outboundTunnel = GetNextOutboundTunnel ();
if (!outboundTunnel)
outboundTunnel = tunnels.GetNextOutboundTunnel ();
LogPrint (eLogDebug, "Tunnels: Creating destination inbound tunnel...");
Path path;
if (SelectPeers (path, true))
{
auto outboundTunnel = GetNextOutboundTunnel (nullptr, path.farEndTransports);
if (!outboundTunnel)
outboundTunnel = tunnels.GetNextOutboundTunnel ();
std::shared_ptr<TunnelConfig> config;
if (m_NumInboundHops > 0)
{
@ -583,7 +582,7 @@ namespace tunnel @@ -583,7 +582,7 @@ namespace tunnel
CreateInboundTunnel ();
return;
}
auto outboundTunnel = GetNextOutboundTunnel ();
auto outboundTunnel = GetNextOutboundTunnel (nullptr, tunnel->GetFarEndTransports ());
if (!outboundTunnel)
outboundTunnel = tunnels.GetNextOutboundTunnel ();
LogPrint (eLogDebug, "Tunnels: Re-creating destination inbound tunnel...");
@ -603,16 +602,20 @@ namespace tunnel @@ -603,16 +602,20 @@ namespace tunnel
}
void TunnelPool::CreateOutboundTunnel ()
{
auto inboundTunnel = GetNextInboundTunnel ();
if (!inboundTunnel)
inboundTunnel = tunnels.GetNextInboundTunnel ();
if (inboundTunnel)
{
LogPrint (eLogDebug, "Tunnels: Creating destination outbound tunnel...");
Path path;
if (SelectPeers (path, false))
{
auto inboundTunnel = GetNextInboundTunnel (nullptr, path.farEndTransports);
if (!inboundTunnel)
inboundTunnel = tunnels.GetNextInboundTunnel ();
if (!inboundTunnel)
{
LogPrint (eLogError, "Tunnels: Can't create outbound tunnel, no inbound tunnels found");
return;
}
if (m_LocalDestination && !m_LocalDestination->SupportsEncryptionType (i2p::data::CRYPTO_KEY_TYPE_ECIES_X25519_AEAD))
path.isShort = false; // because can't handle ECIES encrypted reply
@ -636,9 +639,6 @@ namespace tunnel @@ -636,9 +639,6 @@ namespace tunnel
else
LogPrint (eLogError, "Tunnels: Can't create outbound tunnel, no peers available");
}
else
LogPrint (eLogError, "Tunnels: Can't create outbound tunnel, no inbound tunnels found");
}
void TunnelPool::RecreateOutboundTunnel (std::shared_ptr<OutboundTunnel> tunnel)
{
@ -647,7 +647,7 @@ namespace tunnel @@ -647,7 +647,7 @@ namespace tunnel
CreateOutboundTunnel ();
return;
}
auto inboundTunnel = GetNextInboundTunnel ();
auto inboundTunnel = GetNextInboundTunnel (nullptr, tunnel->GetFarEndTransports ());
if (!inboundTunnel)
inboundTunnel = tunnels.GetNextInboundTunnel ();
if (inboundTunnel)

Loading…
Cancel
Save