mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-08 22:57:52 +00:00
use unordered_map for excluded routers. don't request to self
This commit is contained in:
parent
0e41c3fa36
commit
22dabfd79e
@ -801,7 +801,7 @@ namespace client
|
|||||||
|
|
||||||
void LeaseSetDestination::RequestLeaseSet (const i2p::data::IdentHash& dest, RequestComplete requestComplete, std::shared_ptr<const i2p::data::BlindedPublicKey> requestedBlindedKey)
|
void LeaseSetDestination::RequestLeaseSet (const i2p::data::IdentHash& dest, RequestComplete requestComplete, std::shared_ptr<const i2p::data::BlindedPublicKey> requestedBlindedKey)
|
||||||
{
|
{
|
||||||
std::set<i2p::data::IdentHash> excluded;
|
std::unordered_set<i2p::data::IdentHash> excluded;
|
||||||
auto floodfill = i2p::data::netdb.GetClosestFloodfill (dest, excluded);
|
auto floodfill = i2p::data::netdb.GetClosestFloodfill (dest, excluded);
|
||||||
if (floodfill)
|
if (floodfill)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <set>
|
#include <unordered_set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
@ -97,7 +97,7 @@ namespace client
|
|||||||
struct LeaseSetRequest
|
struct LeaseSetRequest
|
||||||
{
|
{
|
||||||
LeaseSetRequest (boost::asio::io_service& service): requestTime (0), requestTimeoutTimer (service) {};
|
LeaseSetRequest (boost::asio::io_service& service): requestTime (0), requestTimeoutTimer (service) {};
|
||||||
std::set<i2p::data::IdentHash> excluded;
|
std::unordered_set<i2p::data::IdentHash> excluded;
|
||||||
uint64_t requestTime;
|
uint64_t requestTime;
|
||||||
boost::asio::deadline_timer requestTimeoutTimer;
|
boost::asio::deadline_timer requestTimeoutTimer;
|
||||||
std::list<RequestComplete> requestComplete;
|
std::list<RequestComplete> requestComplete;
|
||||||
@ -195,7 +195,7 @@ namespace client
|
|||||||
bool m_IsPublic;
|
bool m_IsPublic;
|
||||||
uint32_t m_PublishReplyToken;
|
uint32_t m_PublishReplyToken;
|
||||||
uint64_t m_LastSubmissionTime; // in seconds
|
uint64_t m_LastSubmissionTime; // in seconds
|
||||||
std::set<i2p::data::IdentHash> m_ExcludedFloodfills; // for publishing
|
std::unordered_set<i2p::data::IdentHash> m_ExcludedFloodfills; // for publishing
|
||||||
|
|
||||||
boost::asio::deadline_timer m_PublishConfirmationTimer, m_PublishVerificationTimer,
|
boost::asio::deadline_timer m_PublishConfirmationTimer, m_PublishVerificationTimer,
|
||||||
m_PublishDelayTimer, m_CleanupTimer;
|
m_PublishDelayTimer, m_CleanupTimer;
|
||||||
|
@ -147,7 +147,7 @@ namespace i2p
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<I2NPMessage> CreateRouterInfoDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
|
std::shared_ptr<I2NPMessage> CreateRouterInfoDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
|
||||||
uint32_t replyTunnelID, bool exploratory, std::set<i2p::data::IdentHash> * excludedPeers)
|
uint32_t replyTunnelID, bool exploratory, std::unordered_set<i2p::data::IdentHash> * excludedPeers)
|
||||||
{
|
{
|
||||||
int cnt = excludedPeers ? excludedPeers->size () : 0;
|
int cnt = excludedPeers ? excludedPeers->size () : 0;
|
||||||
auto m = cnt > 7 ? NewI2NPMessage () : NewI2NPShortMessage ();
|
auto m = cnt > 7 ? NewI2NPMessage () : NewI2NPShortMessage ();
|
||||||
@ -192,7 +192,7 @@ namespace i2p
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
||||||
const std::set<i2p::data::IdentHash>& excludedFloodfills,
|
const std::unordered_set<i2p::data::IdentHash>& excludedFloodfills,
|
||||||
std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel, const uint8_t * replyKey,
|
std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel, const uint8_t * replyKey,
|
||||||
const uint8_t * replyTag, bool replyECIES)
|
const uint8_t * replyTag, bool replyECIES)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <set>
|
#include <unordered_set>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
@ -294,9 +294,9 @@ namespace tunnel
|
|||||||
std::shared_ptr<I2NPMessage> CreateTunnelTestMsg (uint32_t msgID);
|
std::shared_ptr<I2NPMessage> CreateTunnelTestMsg (uint32_t msgID);
|
||||||
std::shared_ptr<I2NPMessage> CreateDeliveryStatusMsg (uint32_t msgID);
|
std::shared_ptr<I2NPMessage> CreateDeliveryStatusMsg (uint32_t msgID);
|
||||||
std::shared_ptr<I2NPMessage> CreateRouterInfoDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
|
std::shared_ptr<I2NPMessage> CreateRouterInfoDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
|
||||||
uint32_t replyTunnelID, bool exploratory = false, std::set<i2p::data::IdentHash> * excludedPeers = nullptr);
|
uint32_t replyTunnelID, bool exploratory = false, std::unordered_set<i2p::data::IdentHash> * excludedPeers = nullptr);
|
||||||
std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
std::shared_ptr<I2NPMessage> CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
||||||
const std::set<i2p::data::IdentHash>& excludedFloodfills,
|
const std::unordered_set<i2p::data::IdentHash>& excludedFloodfills,
|
||||||
std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel,
|
std::shared_ptr<const i2p::tunnel::InboundTunnel> replyTunnel,
|
||||||
const uint8_t * replyKey, const uint8_t * replyTag, bool replyECIES = false);
|
const uint8_t * replyKey, const uint8_t * replyTag, bool replyECIES = false);
|
||||||
std::shared_ptr<I2NPMessage> CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, std::vector<i2p::data::IdentHash> routers);
|
std::shared_ptr<I2NPMessage> CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, std::vector<i2p::data::IdentHash> routers);
|
||||||
|
@ -1004,7 +1004,7 @@ namespace data
|
|||||||
auto dest = m_Requests->FindRequest (ident);
|
auto dest = m_Requests->FindRequest (ident);
|
||||||
if (dest && dest->IsActive ())
|
if (dest && dest->IsActive ())
|
||||||
{
|
{
|
||||||
if (!dest->IsExploratory () && (num > 0 || dest->GetNumExcludedPeers () < 3)) // before 3-rd attempt might be just bad luck
|
if (!dest->IsExploratory () && (num > 0 || dest->GetNumAttempts () < 3)) // before 3-rd attempt might be just bad luck
|
||||||
{
|
{
|
||||||
// try to send next requests
|
// try to send next requests
|
||||||
if (!m_Requests->SendNextRequest (dest))
|
if (!m_Requests->SendNextRequest (dest))
|
||||||
@ -1094,7 +1094,7 @@ namespace data
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LogPrint (eLogInfo, "NetDb: Exploratory close to ", key, " ", numExcluded, " excluded");
|
LogPrint (eLogInfo, "NetDb: Exploratory close to ", key, " ", numExcluded, " excluded");
|
||||||
std::set<IdentHash> excludedRouters;
|
std::unordered_set<IdentHash> excludedRouters;
|
||||||
const uint8_t * excluded_ident = excluded;
|
const uint8_t * excluded_ident = excluded;
|
||||||
for (int i = 0; i < numExcluded; i++)
|
for (int i = 0; i < numExcluded; i++)
|
||||||
{
|
{
|
||||||
@ -1146,7 +1146,7 @@ namespace data
|
|||||||
|
|
||||||
if (!replyMsg)
|
if (!replyMsg)
|
||||||
{
|
{
|
||||||
std::set<IdentHash> excludedRouters;
|
std::unordered_set<IdentHash> excludedRouters;
|
||||||
const uint8_t * exclude_ident = excluded;
|
const uint8_t * exclude_ident = excluded;
|
||||||
for (int i = 0; i < numExcluded; i++)
|
for (int i = 0; i < numExcluded; i++)
|
||||||
{
|
{
|
||||||
@ -1265,7 +1265,7 @@ namespace data
|
|||||||
|
|
||||||
void NetDb::Flood (const IdentHash& ident, std::shared_ptr<I2NPMessage> floodMsg)
|
void NetDb::Flood (const IdentHash& ident, std::shared_ptr<I2NPMessage> floodMsg)
|
||||||
{
|
{
|
||||||
std::set<IdentHash> excluded;
|
std::unordered_set<IdentHash> excluded;
|
||||||
excluded.insert (i2p::context.GetIdentHash ()); // don't flood to itself
|
excluded.insert (i2p::context.GetIdentHash ()); // don't flood to itself
|
||||||
excluded.insert (ident); // don't flood back
|
excluded.insert (ident); // don't flood back
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
@ -1306,7 +1306,7 @@ namespace data
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::GetRandomSSU2PeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const
|
std::shared_ptr<const RouterInfo> NetDb::GetRandomSSU2PeerTestRouter (bool v4, const std::unordered_set<IdentHash>& excluded) const
|
||||||
{
|
{
|
||||||
return GetRandomRouter (
|
return GetRandomRouter (
|
||||||
[v4, &excluded](std::shared_ptr<const RouterInfo> router)->bool
|
[v4, &excluded](std::shared_ptr<const RouterInfo> router)->bool
|
||||||
@ -1316,7 +1316,7 @@ namespace data
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::GetRandomSSU2Introducer (bool v4, const std::set<IdentHash>& excluded) const
|
std::shared_ptr<const RouterInfo> NetDb::GetRandomSSU2Introducer (bool v4, const std::unordered_set<IdentHash>& excluded) const
|
||||||
{
|
{
|
||||||
return GetRandomRouter (
|
return GetRandomRouter (
|
||||||
[v4, &excluded](std::shared_ptr<const RouterInfo> router)->bool
|
[v4, &excluded](std::shared_ptr<const RouterInfo> router)->bool
|
||||||
@ -1412,7 +1412,7 @@ namespace data
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::GetClosestFloodfill (const IdentHash& destination,
|
std::shared_ptr<const RouterInfo> NetDb::GetClosestFloodfill (const IdentHash& destination,
|
||||||
const std::set<IdentHash>& excluded) const
|
const std::unordered_set<IdentHash>& excluded) const
|
||||||
{
|
{
|
||||||
IdentHash destKey = CreateRoutingKey (destination);
|
IdentHash destKey = CreateRoutingKey (destination);
|
||||||
std::lock_guard<std::mutex> l(m_FloodfillsMutex);
|
std::lock_guard<std::mutex> l(m_FloodfillsMutex);
|
||||||
@ -1424,7 +1424,7 @@ namespace data
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<IdentHash> NetDb::GetClosestFloodfills (const IdentHash& destination, size_t num,
|
std::vector<IdentHash> NetDb::GetClosestFloodfills (const IdentHash& destination, size_t num,
|
||||||
std::set<IdentHash>& excluded, bool closeThanUsOnly) const
|
std::unordered_set<IdentHash>& excluded, bool closeThanUsOnly) const
|
||||||
{
|
{
|
||||||
std::vector<IdentHash> res;
|
std::vector<IdentHash> res;
|
||||||
IdentHash destKey = CreateRoutingKey (destination);
|
IdentHash destKey = CreateRoutingKey (destination);
|
||||||
@ -1459,7 +1459,7 @@ namespace data
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<IdentHash> NetDb::GetExploratoryNonFloodfill (const IdentHash& destination,
|
std::vector<IdentHash> NetDb::GetExploratoryNonFloodfill (const IdentHash& destination,
|
||||||
size_t num, const std::set<IdentHash>& excluded)
|
size_t num, const std::unordered_set<IdentHash>& excluded)
|
||||||
{
|
{
|
||||||
std::vector<IdentHash> ret;
|
std::vector<IdentHash> ret;
|
||||||
if (!num || m_RouterInfos.empty ()) return ret; // empty list
|
if (!num || m_RouterInfos.empty ()) return ret; // empty list
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#define NETDB_H__
|
#define NETDB_H__
|
||||||
// this file is called NetDb.hpp to resolve conflict with libc's netdb.h on case insensitive fs
|
// this file is called NetDb.hpp to resolve conflict with libc's netdb.h on case insensitive fs
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <set>
|
#include <unordered_set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -95,12 +95,12 @@ namespace data
|
|||||||
std::shared_ptr<const RouterInfo> GetRandomRouter () const;
|
std::shared_ptr<const RouterInfo> GetRandomRouter () const;
|
||||||
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse, bool endpoint) const;
|
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse, bool endpoint) const;
|
||||||
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse, bool endpoint) const;
|
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith, bool reverse, bool endpoint) const;
|
||||||
std::shared_ptr<const RouterInfo> GetRandomSSU2PeerTestRouter (bool v4, const std::set<IdentHash>& excluded) const;
|
std::shared_ptr<const RouterInfo> GetRandomSSU2PeerTestRouter (bool v4, const std::unordered_set<IdentHash>& excluded) const;
|
||||||
std::shared_ptr<const RouterInfo> GetRandomSSU2Introducer (bool v4, const std::set<IdentHash>& excluded) const;
|
std::shared_ptr<const RouterInfo> GetRandomSSU2Introducer (bool v4, const std::unordered_set<IdentHash>& excluded) const;
|
||||||
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
|
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::unordered_set<IdentHash>& excluded) const;
|
||||||
std::vector<IdentHash> GetClosestFloodfills (const IdentHash& destination, size_t num,
|
std::vector<IdentHash> GetClosestFloodfills (const IdentHash& destination, size_t num,
|
||||||
std::set<IdentHash>& excluded, bool closeThanUsOnly = false) const;
|
std::unordered_set<IdentHash>& excluded, bool closeThanUsOnly = false) const;
|
||||||
std::vector<IdentHash> GetExploratoryNonFloodfill (const IdentHash& destination, size_t num, const std::set<IdentHash>& excluded);
|
std::vector<IdentHash> GetExploratoryNonFloodfill (const IdentHash& destination, size_t num, const std::unordered_set<IdentHash>& excluded);
|
||||||
std::shared_ptr<const RouterInfo> GetRandomRouterInFamily (FamilyID fam) const;
|
std::shared_ptr<const RouterInfo> GetRandomRouterInFamily (FamilyID fam) const;
|
||||||
void SetUnreachable (const IdentHash& ident, bool unreachable);
|
void SetUnreachable (const IdentHash& ident, bool unreachable);
|
||||||
void ExcludeReachableTransports (const IdentHash& ident, RouterInfo::CompatibleTransports transports);
|
void ExcludeReachableTransports (const IdentHash& ident, RouterInfo::CompatibleTransports transports);
|
||||||
@ -139,8 +139,6 @@ namespace data
|
|||||||
std::shared_ptr<IdentityEx> NewIdentity (const uint8_t * buf, size_t len) { return m_IdentitiesPool.AcquireSharedMt (buf, len); };
|
std::shared_ptr<IdentityEx> NewIdentity (const uint8_t * buf, size_t len) { return m_IdentitiesPool.AcquireSharedMt (buf, len); };
|
||||||
std::shared_ptr<RouterProfile> NewRouterProfile () { return m_RouterProfilesPool.AcquireSharedMt (); };
|
std::shared_ptr<RouterProfile> NewRouterProfile () { return m_RouterProfilesPool.AcquireSharedMt (); };
|
||||||
|
|
||||||
uint32_t GetPublishReplyToken () const { return m_PublishReplyToken; };
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void Load ();
|
void Load ();
|
||||||
@ -189,9 +187,6 @@ namespace data
|
|||||||
/** router info we are bootstrapping from or nullptr if we are not currently doing that*/
|
/** router info we are bootstrapping from or nullptr if we are not currently doing that*/
|
||||||
std::shared_ptr<RouterInfo> m_FloodfillBootstrap;
|
std::shared_ptr<RouterInfo> m_FloodfillBootstrap;
|
||||||
|
|
||||||
std::set<IdentHash> m_PublishExcluded;
|
|
||||||
uint32_t m_PublishReplyToken = 0;
|
|
||||||
|
|
||||||
std::vector<std::shared_ptr<const RouterInfo> > m_ExploratorySelection;
|
std::vector<std::shared_ptr<const RouterInfo> > m_ExploratorySelection;
|
||||||
uint64_t m_LastExploratorySelectionUpdateTime; // in monotonic seconds
|
uint64_t m_LastExploratorySelectionUpdateTime; // in monotonic seconds
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "NetDb.hpp"
|
#include "NetDb.hpp"
|
||||||
#include "NetDbRequests.h"
|
#include "NetDbRequests.h"
|
||||||
#include "ECIESX25519AEADRatchetSession.h"
|
#include "ECIESX25519AEADRatchetSession.h"
|
||||||
|
#include "RouterContext.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
@ -19,8 +20,10 @@ namespace data
|
|||||||
{
|
{
|
||||||
RequestedDestination::RequestedDestination (const IdentHash& destination, bool isExploratory, bool direct):
|
RequestedDestination::RequestedDestination (const IdentHash& destination, bool isExploratory, bool direct):
|
||||||
m_Destination (destination), m_IsExploratory (isExploratory), m_IsDirect (direct), m_IsActive (true),
|
m_Destination (destination), m_IsExploratory (isExploratory), m_IsDirect (direct), m_IsActive (true),
|
||||||
m_CreationTime (i2p::util::GetSecondsSinceEpoch ()), m_LastRequestTime (0)
|
m_CreationTime (i2p::util::GetSecondsSinceEpoch ()), m_LastRequestTime (0), m_NumAttempts (0)
|
||||||
{
|
{
|
||||||
|
if (i2p::context.IsFloodfill ())
|
||||||
|
m_ExcludedPeers.insert (i2p::context.GetIdentHash ()); // exclude self if floodfill
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestedDestination::~RequestedDestination ()
|
RequestedDestination::~RequestedDestination ()
|
||||||
@ -42,6 +45,7 @@ namespace data
|
|||||||
if(router)
|
if(router)
|
||||||
m_ExcludedPeers.insert (router->GetIdentHash ());
|
m_ExcludedPeers.insert (router->GetIdentHash ());
|
||||||
m_LastRequestTime = i2p::util::GetSecondsSinceEpoch ();
|
m_LastRequestTime = i2p::util::GetSecondsSinceEpoch ();
|
||||||
|
m_NumAttempts++;
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,18 +71,12 @@ namespace data
|
|||||||
m_ExcludedPeers.clear ();
|
m_ExcludedPeers.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<IdentHash> RequestedDestination::GetExcludedPeers () const
|
std::unordered_set<IdentHash> RequestedDestination::GetExcludedPeers () const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> l (m_ExcludedPeersMutex);
|
std::lock_guard<std::mutex> l (m_ExcludedPeersMutex);
|
||||||
return m_ExcludedPeers;
|
return m_ExcludedPeers;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t RequestedDestination::GetNumExcludedPeers () const
|
|
||||||
{
|
|
||||||
std::lock_guard<std::mutex> l (m_ExcludedPeersMutex);
|
|
||||||
return m_ExcludedPeers.size ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RequestedDestination::Success (std::shared_ptr<RouterInfo> r)
|
void RequestedDestination::Success (std::shared_ptr<RouterInfo> r)
|
||||||
{
|
{
|
||||||
if (m_IsActive)
|
if (m_IsActive)
|
||||||
@ -231,7 +229,7 @@ namespace data
|
|||||||
{
|
{
|
||||||
if (!dest || !dest->IsActive ()) return false;
|
if (!dest || !dest->IsActive ()) return false;
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
auto count = dest->GetNumExcludedPeers ();
|
auto count = dest->GetNumAttempts ();
|
||||||
if (!dest->IsExploratory () && count < MAX_NUM_REQUEST_ATTEMPTS)
|
if (!dest->IsExploratory () && count < MAX_NUM_REQUEST_ATTEMPTS)
|
||||||
{
|
{
|
||||||
auto nextFloodfill = netdb.GetClosestFloodfill (dest->GetDestination (), dest->GetExcludedPeers ());
|
auto nextFloodfill = netdb.GetClosestFloodfill (dest->GetDestination (), dest->GetExcludedPeers ());
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <unordered_set>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "RouterInfo.h"
|
#include "RouterInfo.h"
|
||||||
@ -21,7 +21,7 @@ namespace i2p
|
|||||||
{
|
{
|
||||||
namespace data
|
namespace data
|
||||||
{
|
{
|
||||||
const size_t MAX_NUM_REQUEST_ATTEMPTS = 5;
|
const int MAX_NUM_REQUEST_ATTEMPTS = 5;
|
||||||
const uint64_t MANAGE_REQUESTS_INTERVAL = 1; // in seconds
|
const uint64_t MANAGE_REQUESTS_INTERVAL = 1; // in seconds
|
||||||
const uint64_t MIN_REQUEST_TIME = 5; // in seconds
|
const uint64_t MIN_REQUEST_TIME = 5; // in seconds
|
||||||
const uint64_t MAX_REQUEST_TIME = MAX_NUM_REQUEST_ATTEMPTS * (MIN_REQUEST_TIME + MANAGE_REQUESTS_INTERVAL);
|
const uint64_t MAX_REQUEST_TIME = MAX_NUM_REQUEST_ATTEMPTS * (MIN_REQUEST_TIME + MANAGE_REQUESTS_INTERVAL);
|
||||||
@ -39,8 +39,8 @@ namespace data
|
|||||||
~RequestedDestination ();
|
~RequestedDestination ();
|
||||||
|
|
||||||
const IdentHash& GetDestination () const { return m_Destination; };
|
const IdentHash& GetDestination () const { return m_Destination; };
|
||||||
size_t GetNumExcludedPeers () const;
|
std::unordered_set<IdentHash> GetExcludedPeers () const;
|
||||||
std::set<IdentHash> GetExcludedPeers () const;
|
int GetNumAttempts () const { return m_NumAttempts; };
|
||||||
void ClearExcludedPeers ();
|
void ClearExcludedPeers ();
|
||||||
bool IsExploratory () const { return m_IsExploratory; };
|
bool IsExploratory () const { return m_IsExploratory; };
|
||||||
bool IsDirect () const { return m_IsDirect; };
|
bool IsDirect () const { return m_IsDirect; };
|
||||||
@ -62,9 +62,10 @@ namespace data
|
|||||||
IdentHash m_Destination;
|
IdentHash m_Destination;
|
||||||
bool m_IsExploratory, m_IsDirect, m_IsActive;
|
bool m_IsExploratory, m_IsDirect, m_IsActive;
|
||||||
mutable std::mutex m_ExcludedPeersMutex;
|
mutable std::mutex m_ExcludedPeersMutex;
|
||||||
std::set<IdentHash> m_ExcludedPeers;
|
std::unordered_set<IdentHash> m_ExcludedPeers;
|
||||||
uint64_t m_CreationTime, m_LastRequestTime; // in seconds
|
uint64_t m_CreationTime, m_LastRequestTime; // in seconds
|
||||||
RequestComplete m_RequestComplete;
|
RequestComplete m_RequestComplete;
|
||||||
|
int m_NumAttempts;
|
||||||
};
|
};
|
||||||
|
|
||||||
class NetDbRequests: public std::enable_shared_from_this<NetDbRequests>
|
class NetDbRequests: public std::enable_shared_from_this<NetDbRequests>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <unordered_set>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "RouterInfo.h"
|
#include "RouterInfo.h"
|
||||||
@ -255,7 +255,7 @@ namespace garlic
|
|||||||
// publish
|
// publish
|
||||||
std::unique_ptr<RouterService> m_Service;
|
std::unique_ptr<RouterService> m_Service;
|
||||||
std::unique_ptr<boost::asio::deadline_timer> m_PublishTimer, m_CongestionUpdateTimer, m_CleanupTimer;
|
std::unique_ptr<boost::asio::deadline_timer> m_PublishTimer, m_CongestionUpdateTimer, m_CleanupTimer;
|
||||||
std::set<i2p::data::IdentHash> m_PublishExcluded;
|
std::unordered_set<i2p::data::IdentHash> m_PublishExcluded;
|
||||||
uint32_t m_PublishReplyToken;
|
uint32_t m_PublishReplyToken;
|
||||||
bool m_IsHiddenMode; // not publish
|
bool m_IsHiddenMode; // not publish
|
||||||
};
|
};
|
||||||
|
@ -1047,7 +1047,7 @@ namespace transport
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::list<std::shared_ptr<SSU2Session> > SSU2Server::FindIntroducers (int maxNumIntroducers,
|
std::list<std::shared_ptr<SSU2Session> > SSU2Server::FindIntroducers (int maxNumIntroducers,
|
||||||
bool v4, const std::set<i2p::data::IdentHash>& excluded) const
|
bool v4, const std::unordered_set<i2p::data::IdentHash>& excluded) const
|
||||||
{
|
{
|
||||||
std::list<std::shared_ptr<SSU2Session> > ret;
|
std::list<std::shared_ptr<SSU2Session> > ret;
|
||||||
for (const auto& s : m_Sessions)
|
for (const auto& s : m_Sessions)
|
||||||
@ -1078,7 +1078,7 @@ namespace transport
|
|||||||
uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
|
uint32_t ts = i2p::util::GetSecondsSinceEpoch ();
|
||||||
std::list<i2p::data::IdentHash> newList, impliedList;
|
std::list<i2p::data::IdentHash> newList, impliedList;
|
||||||
auto& introducers = v4 ? m_Introducers : m_IntroducersV6;
|
auto& introducers = v4 ? m_Introducers : m_IntroducersV6;
|
||||||
std::set<i2p::data::IdentHash> excluded;
|
std::unordered_set<i2p::data::IdentHash> excluded;
|
||||||
for (const auto& it : introducers)
|
for (const auto& it : introducers)
|
||||||
{
|
{
|
||||||
std::shared_ptr<SSU2Session> session;
|
std::shared_ptr<SSU2Session> session;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#define SSU2_H__
|
#define SSU2_H__
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <unordered_set>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "SSU2Session.h"
|
#include "SSU2Session.h"
|
||||||
@ -127,7 +128,7 @@ namespace transport
|
|||||||
|
|
||||||
void ConnectThroughIntroducer (std::shared_ptr<SSU2Session> session);
|
void ConnectThroughIntroducer (std::shared_ptr<SSU2Session> session);
|
||||||
std::list<std::shared_ptr<SSU2Session> > FindIntroducers (int maxNumIntroducers,
|
std::list<std::shared_ptr<SSU2Session> > FindIntroducers (int maxNumIntroducers,
|
||||||
bool v4, const std::set<i2p::data::IdentHash>& excluded) const;
|
bool v4, const std::unordered_set<i2p::data::IdentHash>& excluded) const;
|
||||||
void UpdateIntroducers (bool v4);
|
void UpdateIntroducers (bool v4);
|
||||||
void ScheduleIntroducersUpdateTimer ();
|
void ScheduleIntroducersUpdateTimer ();
|
||||||
void HandleIntroducersUpdateTimer (const boost::system::error_code& ecode, bool v4);
|
void HandleIntroducersUpdateTimer (const boost::system::error_code& ecode, bool v4);
|
||||||
|
@ -708,7 +708,7 @@ namespace transport
|
|||||||
if (ipv4 && i2p::context.SupportsV4 ())
|
if (ipv4 && i2p::context.SupportsV4 ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Transports: Started peer test IPv4");
|
LogPrint (eLogInfo, "Transports: Started peer test IPv4");
|
||||||
std::set<i2p::data::IdentHash> excluded;
|
std::unordered_set<i2p::data::IdentHash> excluded;
|
||||||
excluded.insert (i2p::context.GetIdentHash ()); // don't pick own router
|
excluded.insert (i2p::context.GetIdentHash ()); // don't pick own router
|
||||||
int testDelay = 0;
|
int testDelay = 0;
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
@ -746,7 +746,7 @@ namespace transport
|
|||||||
if (ipv6 && i2p::context.SupportsV6 ())
|
if (ipv6 && i2p::context.SupportsV6 ())
|
||||||
{
|
{
|
||||||
LogPrint (eLogInfo, "Transports: Started peer test IPv6");
|
LogPrint (eLogInfo, "Transports: Started peer test IPv6");
|
||||||
std::set<i2p::data::IdentHash> excluded;
|
std::unordered_set<i2p::data::IdentHash> excluded;
|
||||||
excluded.insert (i2p::context.GetIdentHash ()); // don't pick own router
|
excluded.insert (i2p::context.GetIdentHash ()); // don't pick own router
|
||||||
int testDelay = 0;
|
int testDelay = 0;
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user