mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-12 06:07:54 +00:00
find router with specified caps
This commit is contained in:
parent
fb9d351600
commit
59d195c6da
@ -601,7 +601,7 @@ namespace data
|
||||
}
|
||||
}
|
||||
|
||||
const RouterInfo * NetDb::GetRandomRouter (const RouterInfo * compatibleWith, bool floodfillOnly) const
|
||||
const RouterInfo * NetDb::GetRandomRouter (const RouterInfo * compatibleWith, uint8_t caps) const
|
||||
{
|
||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||
uint32_t ind = rnd.GenerateWord32 (0, m_RouterInfos.size () - 1);
|
||||
@ -614,7 +614,7 @@ namespace data
|
||||
{
|
||||
if (!it.second->IsUnreachable () &&
|
||||
(!compatibleWith || it.second->IsCompatible (*compatibleWith)) &&
|
||||
(!floodfillOnly || it.second->IsFloodfill ()))
|
||||
(!caps || (it.second->GetCaps () & caps) == caps))
|
||||
return it.second;
|
||||
}
|
||||
else
|
||||
|
2
NetDb.h
2
NetDb.h
@ -74,7 +74,7 @@ namespace data
|
||||
void HandleDatabaseStoreMsg (uint8_t * buf, size_t len);
|
||||
void HandleDatabaseSearchReplyMsg (I2NPMessage * msg);
|
||||
|
||||
const RouterInfo * GetRandomRouter (const RouterInfo * compatibleWith = nullptr, bool floodfillOnly = false) const;
|
||||
const RouterInfo * GetRandomRouter (const RouterInfo * compatibleWith = nullptr, uint8_t caps = 0) const;
|
||||
|
||||
void PostI2NPMsg (I2NPMessage * msg);
|
||||
|
||||
|
@ -200,8 +200,10 @@ namespace data
|
||||
case 'f':
|
||||
m_Caps |= Caps::eFloodfill;
|
||||
break;
|
||||
case 'M':
|
||||
case 'N':
|
||||
case 'O':
|
||||
m_Caps |= Caps::eHighBanwidth;
|
||||
m_Caps |= Caps::eHighBandwidth;
|
||||
break;
|
||||
case 'R':
|
||||
m_Caps |= Caps::eReachable;
|
||||
|
@ -28,7 +28,7 @@ namespace data
|
||||
enum Caps
|
||||
{
|
||||
eFloodfill = 0x01,
|
||||
eHighBanwidth = 0x02,
|
||||
eHighBandwidth = 0x02,
|
||||
eReachable = 0x04
|
||||
};
|
||||
|
||||
@ -84,7 +84,8 @@ namespace data
|
||||
bool IsSSU (bool v4only = true) const;
|
||||
bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; };
|
||||
bool UsesIntroducer () const;
|
||||
|
||||
uint8_t GetCaps () const { return m_Caps; };
|
||||
|
||||
void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; };
|
||||
bool IsUnreachable () const { return m_IsUnreachable; };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user