mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
take tunnels from exploratory pool only
This commit is contained in:
parent
da01ea997d
commit
86a7f96a46
31
NetDb.cpp
31
NetDb.cpp
@ -26,7 +26,7 @@ namespace data
|
|||||||
{
|
{
|
||||||
I2NPMessage * msg = i2p::CreateDatabaseLookupMsg (m_Destination,
|
I2NPMessage * msg = i2p::CreateDatabaseLookupMsg (m_Destination,
|
||||||
replyTunnel->GetNextIdentHash (), replyTunnel->GetNextTunnelID (), m_IsExploratory,
|
replyTunnel->GetNextIdentHash (), replyTunnel->GetNextTunnelID (), m_IsExploratory,
|
||||||
&m_ExcludedPeers, false, m_Pool);
|
&m_ExcludedPeers);
|
||||||
m_ExcludedPeers.insert (router->GetIdentHash ());
|
m_ExcludedPeers.insert (router->GetIdentHash ());
|
||||||
m_LastRouter = router;
|
m_LastRouter = router;
|
||||||
m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
|
m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
|
||||||
@ -406,10 +406,10 @@ namespace data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetDb::RequestDestination (const IdentHash& destination, i2p::tunnel::TunnelPool * pool)
|
void NetDb::RequestDestination (const IdentHash& destination)
|
||||||
{
|
{
|
||||||
// request RouterInfo directly
|
// request RouterInfo directly
|
||||||
RequestedDestination * dest = CreateRequestedDestination (destination, false, pool);
|
RequestedDestination * dest = CreateRequestedDestination (destination, false);
|
||||||
auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ());
|
auto floodfill = GetClosestFloodfill (destination, dest->GetExcludedPeers ());
|
||||||
if (floodfill)
|
if (floodfill)
|
||||||
transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
|
transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
|
||||||
@ -469,9 +469,9 @@ namespace data
|
|||||||
bool deleteDest = true;
|
bool deleteDest = true;
|
||||||
if (num > 0)
|
if (num > 0)
|
||||||
{
|
{
|
||||||
auto pool = dest ? dest->GetTunnelPool () : nullptr;
|
auto pool = i2p::tunnel::tunnels.GetExploratoryPool ();
|
||||||
auto outbound = pool ? pool->GetNextOutboundTunnel () : i2p::tunnel::tunnels.GetNextOutboundTunnel ();
|
auto outbound = pool->GetNextOutboundTunnel ();
|
||||||
auto inbound = pool ? pool->GetNextInboundTunnel () : i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
auto inbound = pool->GetNextInboundTunnel ();
|
||||||
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
|
||||||
if (!dest->IsExploratory ())
|
if (!dest->IsExploratory ())
|
||||||
{
|
{
|
||||||
@ -525,7 +525,7 @@ namespace data
|
|||||||
LogPrint ("Found new/outdated router. Requesting RouterInfo ...");
|
LogPrint ("Found new/outdated router. Requesting RouterInfo ...");
|
||||||
if (outbound && inbound && dest->GetLastRouter ())
|
if (outbound && inbound && dest->GetLastRouter ())
|
||||||
{
|
{
|
||||||
RequestedDestination * d1 = CreateRequestedDestination (router, false, pool);
|
RequestedDestination * d1 = CreateRequestedDestination (router, false);
|
||||||
auto msg = d1->CreateRequestMessage (dest->GetLastRouter (), inbound);
|
auto msg = d1->CreateRequestMessage (dest->GetLastRouter (), inbound);
|
||||||
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||||
{
|
{
|
||||||
@ -534,7 +534,7 @@ namespace data
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
RequestDestination (router, pool);
|
RequestDestination (router);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint ("Bayan");
|
LogPrint ("Bayan");
|
||||||
@ -547,7 +547,7 @@ namespace data
|
|||||||
{
|
{
|
||||||
// request router
|
// request router
|
||||||
LogPrint ("Found new floodfill. Request it");
|
LogPrint ("Found new floodfill. Request it");
|
||||||
RequestDestination (router, pool);
|
RequestDestination (router);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -689,7 +689,7 @@ namespace data
|
|||||||
for (int i = 0; i < numDestinations; i++)
|
for (int i = 0; i < numDestinations; i++)
|
||||||
{
|
{
|
||||||
rnd.GenerateBlock (randomHash, 32);
|
rnd.GenerateBlock (randomHash, 32);
|
||||||
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), true, exploratoryPool);
|
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), true);
|
||||||
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ());
|
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ());
|
||||||
if (floodfill && !floodfills.count (floodfill.get ())) // request floodfill only once
|
if (floodfill && !floodfills.count (floodfill.get ())) // request floodfill only once
|
||||||
{
|
{
|
||||||
@ -734,14 +734,13 @@ namespace data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestedDestination * NetDb::CreateRequestedDestination (const IdentHash& dest,
|
RequestedDestination * NetDb::CreateRequestedDestination (const IdentHash& dest, bool isExploratory)
|
||||||
bool isExploratory, i2p::tunnel::TunnelPool * pool)
|
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
std::unique_lock<std::mutex> l(m_RequestedDestinationsMutex);
|
||||||
auto it = m_RequestedDestinations.find (dest);
|
auto it = m_RequestedDestinations.find (dest);
|
||||||
if (it == m_RequestedDestinations.end ()) // not exist yet
|
if (it == m_RequestedDestinations.end ()) // not exist yet
|
||||||
{
|
{
|
||||||
RequestedDestination * d = new RequestedDestination (dest, isExploratory, pool);
|
RequestedDestination * d = new RequestedDestination (dest, isExploratory);
|
||||||
m_RequestedDestinations[dest] = d;
|
m_RequestedDestinations[dest] = d;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
@ -883,9 +882,9 @@ namespace data
|
|||||||
auto count = dest->GetExcludedPeers ().size ();
|
auto count = dest->GetExcludedPeers ().size ();
|
||||||
if (count < 7)
|
if (count < 7)
|
||||||
{
|
{
|
||||||
auto pool = dest->GetTunnelPool ();
|
auto pool = i2p::tunnel::tunnels.GetExploratoryPool ();
|
||||||
auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr;
|
auto outbound = pool->GetNextOutboundTunnel ();
|
||||||
auto inbound = pool ? pool->GetNextInboundTunnel () : nullptr;
|
auto inbound = pool->GetNextInboundTunnel ();
|
||||||
auto nextFloodfill = GetClosestFloodfill (dest->GetDestination (), dest->GetExcludedPeers ());
|
auto nextFloodfill = GetClosestFloodfill (dest->GetDestination (), dest->GetExcludedPeers ());
|
||||||
if (nextFloodfill && outbound && inbound)
|
if (nextFloodfill && outbound && inbound)
|
||||||
outbound->SendTunnelDataMsg (nextFloodfill->GetIdentHash (), 0,
|
outbound->SendTunnelDataMsg (nextFloodfill->GetIdentHash (), 0,
|
||||||
|
13
NetDb.h
13
NetDb.h
@ -24,17 +24,14 @@ namespace data
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RequestedDestination (const IdentHash& destination, bool isExploratory = false,
|
RequestedDestination (const IdentHash& destination, bool isExploratory = false):
|
||||||
i2p::tunnel::TunnelPool * pool = nullptr):
|
m_Destination (destination), m_IsExploratory (isExploratory), m_CreationTime (0) {};
|
||||||
m_Destination (destination), m_IsExploratory (isExploratory),
|
|
||||||
m_Pool (pool), m_CreationTime (0) {};
|
|
||||||
|
|
||||||
const IdentHash& GetDestination () const { return m_Destination; };
|
const IdentHash& GetDestination () const { return m_Destination; };
|
||||||
int GetNumExcludedPeers () const { return m_ExcludedPeers.size (); };
|
int GetNumExcludedPeers () const { return m_ExcludedPeers.size (); };
|
||||||
const std::set<IdentHash>& GetExcludedPeers () { return m_ExcludedPeers; };
|
const std::set<IdentHash>& GetExcludedPeers () { return m_ExcludedPeers; };
|
||||||
void ClearExcludedPeers ();
|
void ClearExcludedPeers ();
|
||||||
std::shared_ptr<const RouterInfo> GetLastRouter () const { return m_LastRouter; };
|
std::shared_ptr<const RouterInfo> GetLastRouter () const { return m_LastRouter; };
|
||||||
i2p::tunnel::TunnelPool * GetTunnelPool () { return m_Pool; };
|
|
||||||
bool IsExploratory () const { return m_IsExploratory; };
|
bool IsExploratory () const { return m_IsExploratory; };
|
||||||
bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); };
|
bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); };
|
||||||
uint64_t GetCreationTime () const { return m_CreationTime; };
|
uint64_t GetCreationTime () const { return m_CreationTime; };
|
||||||
@ -45,7 +42,6 @@ namespace data
|
|||||||
|
|
||||||
IdentHash m_Destination;
|
IdentHash m_Destination;
|
||||||
bool m_IsExploratory;
|
bool m_IsExploratory;
|
||||||
i2p::tunnel::TunnelPool * m_Pool;
|
|
||||||
std::set<IdentHash> m_ExcludedPeers;
|
std::set<IdentHash> m_ExcludedPeers;
|
||||||
std::shared_ptr<const RouterInfo> m_LastRouter;
|
std::shared_ptr<const RouterInfo> m_LastRouter;
|
||||||
uint64_t m_CreationTime;
|
uint64_t m_CreationTime;
|
||||||
@ -67,7 +63,7 @@ namespace data
|
|||||||
std::shared_ptr<RouterInfo> FindRouter (const IdentHash& ident) const;
|
std::shared_ptr<RouterInfo> FindRouter (const IdentHash& ident) const;
|
||||||
LeaseSet * FindLeaseSet (const IdentHash& destination) const;
|
LeaseSet * FindLeaseSet (const IdentHash& destination) const;
|
||||||
|
|
||||||
void RequestDestination (const IdentHash& destination, i2p::tunnel::TunnelPool * pool = nullptr);
|
void RequestDestination (const IdentHash& destination);
|
||||||
|
|
||||||
void HandleDatabaseStoreMsg (I2NPMessage * msg);
|
void HandleDatabaseStoreMsg (I2NPMessage * msg);
|
||||||
void HandleDatabaseSearchReplyMsg (I2NPMessage * msg);
|
void HandleDatabaseSearchReplyMsg (I2NPMessage * msg);
|
||||||
@ -97,8 +93,7 @@ namespace data
|
|||||||
void ManageLeaseSets ();
|
void ManageLeaseSets ();
|
||||||
void ManageRequests ();
|
void ManageRequests ();
|
||||||
|
|
||||||
RequestedDestination * CreateRequestedDestination (const IdentHash& dest,
|
RequestedDestination * CreateRequestedDestination (const IdentHash& dest, bool isExploratory = false);
|
||||||
bool isExploratory = false, i2p::tunnel::TunnelPool * pool = nullptr);
|
|
||||||
bool DeleteRequestedDestination (const IdentHash& dest); // returns true if found
|
bool DeleteRequestedDestination (const IdentHash& dest); // returns true if found
|
||||||
void DeleteRequestedDestination (RequestedDestination * dest);
|
void DeleteRequestedDestination (RequestedDestination * dest);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user