mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-07 11:54:16 +00:00
exclude hidden routers from tunnels
This commit is contained in:
parent
ebd64c9337
commit
b95caaf219
@ -633,7 +633,7 @@ namespace data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const RouterInfo * NetDb::GetRandomRouter (const RouterInfo * compatibleWith, uint8_t caps) const
|
const RouterInfo * NetDb::GetRandomRouter (const RouterInfo * compatibleWith) const
|
||||||
{
|
{
|
||||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||||
uint32_t ind = rnd.GenerateWord32 (0, m_RouterInfos.size () - 1);
|
uint32_t ind = rnd.GenerateWord32 (0, m_RouterInfos.size () - 1);
|
||||||
@ -644,9 +644,8 @@ namespace data
|
|||||||
{
|
{
|
||||||
if (i >= ind)
|
if (i >= ind)
|
||||||
{
|
{
|
||||||
if (!it.second->IsUnreachable () &&
|
if (!it.second->IsUnreachable () && !it.second->IsHidden () &&
|
||||||
(!compatibleWith || it.second->IsCompatible (*compatibleWith)) &&
|
(!compatibleWith || it.second->IsCompatible (*compatibleWith)))
|
||||||
(!caps || (it.second->GetCaps () & caps) == caps))
|
|
||||||
return it.second;
|
return it.second;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
2
NetDb.h
2
NetDb.h
@ -76,7 +76,7 @@ namespace data
|
|||||||
void HandleDatabaseStoreMsg (uint8_t * buf, size_t len);
|
void HandleDatabaseStoreMsg (uint8_t * buf, size_t len);
|
||||||
void HandleDatabaseSearchReplyMsg (I2NPMessage * msg);
|
void HandleDatabaseSearchReplyMsg (I2NPMessage * msg);
|
||||||
|
|
||||||
const RouterInfo * GetRandomRouter (const RouterInfo * compatibleWith = nullptr, uint8_t caps = 0) const;
|
const RouterInfo * GetRandomRouter (const RouterInfo * compatibleWith = nullptr) const;
|
||||||
|
|
||||||
void PostI2NPMsg (I2NPMessage * msg);
|
void PostI2NPMsg (I2NPMessage * msg);
|
||||||
|
|
||||||
|
@ -214,7 +214,10 @@ namespace data
|
|||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
m_Caps |= Caps::eSSUIntroducer;
|
m_Caps |= Caps::eSSUIntroducer;
|
||||||
break;
|
break;
|
||||||
|
case 'H':
|
||||||
|
m_Caps |= Caps::eHidden;
|
||||||
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
cap++;
|
cap++;
|
||||||
|
@ -31,7 +31,8 @@ namespace data
|
|||||||
eHighBandwidth = 0x02,
|
eHighBandwidth = 0x02,
|
||||||
eReachable = 0x04,
|
eReachable = 0x04,
|
||||||
eSSUTesting = 0x08,
|
eSSUTesting = 0x08,
|
||||||
eSSUIntroducer = 0x10
|
eSSUIntroducer = 0x10,
|
||||||
|
eHidden = 0x20
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TransportStyle
|
enum TransportStyle
|
||||||
@ -88,6 +89,8 @@ namespace data
|
|||||||
bool UsesIntroducer () const;
|
bool UsesIntroducer () const;
|
||||||
bool IsIntroducer () const { return m_Caps & eSSUIntroducer; };
|
bool IsIntroducer () const { return m_Caps & eSSUIntroducer; };
|
||||||
bool IsPeerTesting () const { return m_Caps & eSSUTesting; };
|
bool IsPeerTesting () const { return m_Caps & eSSUTesting; };
|
||||||
|
bool IsHidden () const { return m_Caps & eHidden; };
|
||||||
|
|
||||||
uint8_t GetCaps () const { return m_Caps; };
|
uint8_t GetCaps () const { return m_Caps; };
|
||||||
|
|
||||||
void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; };
|
void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user