Browse Source

find router with specified caps

pull/48/head
orignal 11 years ago
parent
commit
59d195c6da
  1. 4
      NetDb.cpp
  2. 2
      NetDb.h
  3. 4
      RouterInfo.cpp
  4. 5
      RouterInfo.h

4
NetDb.cpp

@ -601,7 +601,7 @@ namespace data @@ -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 @@ -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

@ -74,7 +74,7 @@ namespace data @@ -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);

4
RouterInfo.cpp

@ -200,8 +200,10 @@ namespace data @@ -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;

5
RouterInfo.h

@ -28,7 +28,7 @@ namespace data @@ -28,7 +28,7 @@ namespace data
enum Caps
{
eFloodfill = 0x01,
eHighBanwidth = 0x02,
eHighBandwidth = 0x02,
eReachable = 0x04
};
@ -84,7 +84,8 @@ namespace data @@ -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…
Cancel
Save