Browse Source

don't attach our RouterInfo to router's request

pull/1556/head
orignal 4 years ago
parent
commit
8483464aab
  1. 4
      libi2pd/Destination.cpp
  2. 38
      libi2pd/NetDb.cpp
  3. 2
      libi2pd/NetDb.hpp

4
libi2pd/Destination.cpp

@ -469,8 +469,8 @@ namespace client
i2p::data::IdentHash peerHash (buf + 33 + i*32); i2p::data::IdentHash peerHash (buf + 33 + i*32);
if (!request->excluded.count (peerHash) && !i2p::data::netdb.FindRouter (peerHash)) if (!request->excluded.count (peerHash) && !i2p::data::netdb.FindRouter (peerHash))
{ {
LogPrint (eLogInfo, "Destination: Found new floodfill, request it"); // TODO: recheck this message LogPrint (eLogInfo, "Destination: Found new floodfill, request it");
i2p::data::netdb.RequestDestination (peerHash); i2p::data::netdb.RequestDestination (peerHash, nullptr, false); // through exploratory
} }
} }

38
libi2pd/NetDb.cpp

@ -610,7 +610,7 @@ namespace data
} }
} }
void NetDb::RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete) void NetDb::RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete, bool direct)
{ {
auto dest = m_Requests.CreateRequest (destination, false, requestComplete); // non-exploratory auto dest = m_Requests.CreateRequest (destination, false, requestComplete); // non-exploratory
if (!dest) if (!dest)
@ -621,8 +621,24 @@ namespace data
auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ()); auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ());
if (floodfill) if (floodfill)
{
if (direct)
transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ())); transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
else else
{
auto pool = i2p::tunnel::tunnels.GetExploratoryPool ();
auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr;
auto inbound = pool ? pool->GetNextInboundTunnel () : nullptr;
if (outbound && inbound)
outbound->SendTunnelDataMsg (floodfill->GetIdentHash (), 0, dest->CreateRequestMessage (floodfill, inbound));
else
{
LogPrint (eLogError, "NetDb: ", destination.ToBase64(), " destination requested, but no tunnels found");
m_Requests.RequestComplete (destination, nullptr);
}
}
}
else
{ {
LogPrint (eLogError, "NetDb: ", destination.ToBase64(), " destination requested, but no floodfills found"); LogPrint (eLogError, "NetDb: ", destination.ToBase64(), " destination requested, but no floodfills found");
m_Requests.RequestComplete (destination, nullptr); m_Requests.RequestComplete (destination, nullptr);
@ -775,37 +791,21 @@ namespace data
// reply to our destination. Try other floodfills // reply to our destination. Try other floodfills
if (outbound && inbound) if (outbound && inbound)
{ {
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
auto count = dest->GetExcludedPeers ().size (); auto count = dest->GetExcludedPeers ().size ();
if (count < 7) if (count < 7)
{ {
auto nextFloodfill = GetClosestFloodfill (dest->GetDestination (), dest->GetExcludedPeers ()); auto nextFloodfill = GetClosestFloodfill (dest->GetDestination (), dest->GetExcludedPeers ());
if (nextFloodfill) if (nextFloodfill)
{ {
// tell floodfill about us
msgs.push_back (i2p::tunnel::TunnelMessageBlock
{
i2p::tunnel::eDeliveryTypeRouter,
nextFloodfill->GetIdentHash (), 0,
CreateDatabaseStoreMsg ()
});
// request destination // request destination
LogPrint (eLogDebug, "NetDb: Try ", key, " at ", count, " floodfill ", nextFloodfill->GetIdentHash ().ToBase64 ()); LogPrint (eLogDebug, "NetDb: Try ", key, " at ", count, " floodfill ", nextFloodfill->GetIdentHash ().ToBase64 ());
auto msg = dest->CreateRequestMessage (nextFloodfill, inbound); outbound->SendTunnelDataMsg (nextFloodfill->GetIdentHash (), 0,
msgs.push_back (i2p::tunnel::TunnelMessageBlock dest->CreateRequestMessage (nextFloodfill, inbound));
{
i2p::tunnel::eDeliveryTypeRouter,
nextFloodfill->GetIdentHash (), 0, msg
});
deleteDest = false; deleteDest = false;
} }
} }
else else
LogPrint (eLogWarning, "NetDb: ", key, " was not found on ", count, " floodfills"); LogPrint (eLogWarning, "NetDb: ", key, " was not found on ", count, " floodfills");
if (msgs.size () > 0)
outbound->SendTunnelDataMsg (msgs);
} }
} }

2
libi2pd/NetDb.hpp

@ -70,7 +70,7 @@ namespace data
std::shared_ptr<LeaseSet> FindLeaseSet (const IdentHash& destination) const; std::shared_ptr<LeaseSet> FindLeaseSet (const IdentHash& destination) const;
std::shared_ptr<RouterProfile> FindRouterProfile (const IdentHash& ident) const; std::shared_ptr<RouterProfile> FindRouterProfile (const IdentHash& ident) const;
void RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete = nullptr); void RequestDestination (const IdentHash& destination, RequestedDestination::RequestComplete requestComplete = nullptr, bool direct = true);
void RequestDestinationFrom (const IdentHash& destination, const IdentHash & from, bool exploritory, RequestedDestination::RequestComplete requestComplete = nullptr); void RequestDestinationFrom (const IdentHash& destination, const IdentHash & from, bool exploritory, RequestedDestination::RequestComplete requestComplete = nullptr);
void HandleDatabaseStoreMsg (std::shared_ptr<const I2NPMessage> msg); void HandleDatabaseStoreMsg (std::shared_ptr<const I2NPMessage> msg);

Loading…
Cancel
Save