mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
initial filtration of bad peers
This commit is contained in:
parent
5f199432f0
commit
577ba9b397
|
@ -24,6 +24,8 @@ namespace data
|
||||||
|
|
||||||
void Save ();
|
void Save ();
|
||||||
void Load ();
|
void Load ();
|
||||||
|
|
||||||
|
bool IsBad () const { return !m_NumTunnelsAgreed && m_NumTunnelsDeclined >= 5; };
|
||||||
|
|
||||||
void TunnelBuildResponse (uint8_t ret);
|
void TunnelBuildResponse (uint8_t ret);
|
||||||
|
|
||||||
|
|
|
@ -261,8 +261,13 @@ namespace tunnel
|
||||||
std::shared_ptr<const i2p::data::RouterInfo> TunnelPool::SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop) const
|
std::shared_ptr<const i2p::data::RouterInfo> TunnelPool::SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop) const
|
||||||
{
|
{
|
||||||
bool isExploratory = (m_LocalDestination == &i2p::context); // TODO: implement it better
|
bool isExploratory = (m_LocalDestination == &i2p::context); // TODO: implement it better
|
||||||
auto hop = isExploratory ? i2p::data::netdb.GetRandomRouter (prevHop):
|
auto hop = isExploratory ? i2p::data::netdb.GetRandomRouter (prevHop):
|
||||||
i2p::data::netdb.GetHighBandwidthRandomRouter (prevHop);
|
i2p::data::netdb.GetHighBandwidthRandomRouter (prevHop);
|
||||||
|
if (!isExploratory && hop && hop->GetProfile ()->IsBad ())
|
||||||
|
{
|
||||||
|
LogPrint (eLogInfo, "Selected peer for tunnel has bad profile. Selecting another");
|
||||||
|
hop = i2p::data::netdb.GetHighBandwidthRandomRouter (prevHop);
|
||||||
|
}
|
||||||
|
|
||||||
if (!hop)
|
if (!hop)
|
||||||
hop = i2p::data::netdb.GetRandomRouter ();
|
hop = i2p::data::netdb.GetRandomRouter ();
|
||||||
|
|
Loading…
Reference in a new issue