mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-10 01:01:02 +00:00
fill caps property based on flags
This commit is contained in:
parent
d86e970876
commit
44dcf73300
@ -35,7 +35,7 @@ namespace i2p
|
|||||||
port = m_Rnd.GenerateWord32 (9111, 30777); // I2P network ports range
|
port = m_Rnd.GenerateWord32 (9111, 30777); // I2P network ports range
|
||||||
routerInfo.AddSSUAddress (i2p::util::config::GetCharArg("-host", "127.0.0.1"), port, routerInfo.GetIdentHash ());
|
routerInfo.AddSSUAddress (i2p::util::config::GetCharArg("-host", "127.0.0.1"), port, routerInfo.GetIdentHash ());
|
||||||
routerInfo.AddNTCPAddress (i2p::util::config::GetCharArg("-host", "127.0.0.1"), port);
|
routerInfo.AddNTCPAddress (i2p::util::config::GetCharArg("-host", "127.0.0.1"), port);
|
||||||
routerInfo.SetProperty ("caps", "LR");
|
routerInfo.SetCaps (i2p::data::RouterInfo::eReachable); // LR
|
||||||
routerInfo.SetProperty ("coreVersion", I2P_VERSION);
|
routerInfo.SetProperty ("coreVersion", I2P_VERSION);
|
||||||
routerInfo.SetProperty ("netId", "2");
|
routerInfo.SetProperty ("netId", "2");
|
||||||
routerInfo.SetProperty ("router.version", I2P_VERSION);
|
routerInfo.SetProperty ("router.version", I2P_VERSION);
|
||||||
|
@ -237,35 +237,47 @@ namespace data
|
|||||||
{
|
{
|
||||||
switch (*cap)
|
switch (*cap)
|
||||||
{
|
{
|
||||||
case 'f':
|
case CAPS_FLAG_FLOODFILL:
|
||||||
m_Caps |= Caps::eFloodfill;
|
m_Caps |= Caps::eFloodfill;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case CAPS_FLAG_HIGH_BANDWIDTH1:
|
||||||
case 'N':
|
case CAPS_FLAG_HIGH_BANDWIDTH2:
|
||||||
case 'O':
|
case CAPS_FLAG_HIGH_BANDWIDTH3:
|
||||||
m_Caps |= Caps::eHighBandwidth;
|
m_Caps |= Caps::eHighBandwidth;
|
||||||
break;
|
break;
|
||||||
case 'R':
|
case CAPS_FLAG_HIDDEN:
|
||||||
m_Caps |= Caps::eReachable;
|
|
||||||
break;
|
|
||||||
case 'B':
|
|
||||||
m_Caps |= Caps::eSSUTesting;
|
|
||||||
break;
|
|
||||||
case 'C':
|
|
||||||
m_Caps |= Caps::eSSUIntroducer;
|
|
||||||
break;
|
|
||||||
case 'H':
|
|
||||||
m_Caps |= Caps::eHidden;
|
m_Caps |= Caps::eHidden;
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case CAPS_FLAG_REACHABLE:
|
||||||
|
m_Caps |= Caps::eReachable;
|
||||||
|
break;
|
||||||
|
case CAPS_FLAG_UNREACHABLE:
|
||||||
m_Caps |= Caps::eUnreachable;
|
m_Caps |= Caps::eUnreachable;
|
||||||
break;
|
break;
|
||||||
|
case CAPS_FLAG_SSU_TESTING:
|
||||||
|
m_Caps |= Caps::eSSUTesting;
|
||||||
|
break;
|
||||||
|
case CAPS_FLAG_SSU_INTRODUCER:
|
||||||
|
m_Caps |= Caps::eSSUIntroducer;
|
||||||
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
cap++;
|
cap++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RouterInfo::UpdateCapsProperty ()
|
||||||
|
{
|
||||||
|
std::string caps;
|
||||||
|
caps += (m_Caps & eHighBandwidth) ? CAPS_FLAG_HIGH_BANDWIDTH1 : CAPS_FLAG_LOW_BANDWIDTH2; // bandwidth
|
||||||
|
if (m_Caps & eFloodfill) caps += CAPS_FLAG_FLOODFILL; // floodfill
|
||||||
|
if (m_Caps & eHidden) caps += CAPS_FLAG_HIDDEN; // hidden
|
||||||
|
if (m_Caps & eReachable) caps += CAPS_FLAG_REACHABLE; // reachable
|
||||||
|
if (m_Caps & eUnreachable) caps += CAPS_FLAG_UNREACHABLE; // unreachable
|
||||||
|
|
||||||
|
SetProperty ("caps", caps.c_str ());
|
||||||
|
}
|
||||||
|
|
||||||
void RouterInfo::UpdateIdentHashBase64 ()
|
void RouterInfo::UpdateIdentHashBase64 ()
|
||||||
{
|
{
|
||||||
size_t l = i2p::data::ByteStreamToBase64 (m_IdentHash, 32, m_IdentHashBase64, 48);
|
size_t l = i2p::data::ByteStreamToBase64 (m_IdentHash, 32, m_IdentHashBase64, 48);
|
||||||
@ -302,8 +314,8 @@ namespace data
|
|||||||
WriteString ("caps", properties);
|
WriteString ("caps", properties);
|
||||||
properties << '=';
|
properties << '=';
|
||||||
std::string caps;
|
std::string caps;
|
||||||
if (IsPeerTesting ()) caps += 'B';
|
if (IsPeerTesting ()) caps += CAPS_FLAG_SSU_TESTING;
|
||||||
if (IsIntroducer ()) caps += 'C';
|
if (IsIntroducer ()) caps += CAPS_FLAG_SSU_INTRODUCER;
|
||||||
WriteString (caps, properties);
|
WriteString (caps, properties);
|
||||||
properties << ';';
|
properties << ';';
|
||||||
}
|
}
|
||||||
@ -511,6 +523,12 @@ namespace data
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RouterInfo::SetCaps (uint8_t caps)
|
||||||
|
{
|
||||||
|
m_Caps = caps;
|
||||||
|
UpdateCapsProperty ();
|
||||||
|
}
|
||||||
|
|
||||||
void RouterInfo::SetCaps (const char * caps)
|
void RouterInfo::SetCaps (const char * caps)
|
||||||
{
|
{
|
||||||
|
19
RouterInfo.h
19
RouterInfo.h
@ -12,7 +12,20 @@
|
|||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
namespace data
|
namespace data
|
||||||
{
|
{
|
||||||
|
const char CAPS_FLAG_FLOODFILL = 'f';
|
||||||
|
const char CAPS_FLAG_HIDDEN = 'H';
|
||||||
|
const char CAPS_FLAG_REACHABLE = 'R';
|
||||||
|
const char CAPS_FLAG_UNREACHABLE = 'U';
|
||||||
|
const char CAPS_FLAG_LOW_BANDWIDTH1 = 'K';
|
||||||
|
const char CAPS_FLAG_LOW_BANDWIDTH2 = 'L';
|
||||||
|
const char CAPS_FLAG_HIGH_BANDWIDTH1 = 'M';
|
||||||
|
const char CAPS_FLAG_HIGH_BANDWIDTH2 = 'N';
|
||||||
|
const char CAPS_FLAG_HIGH_BANDWIDTH3 = 'O';
|
||||||
|
|
||||||
|
const char CAPS_FLAG_SSU_TESTING = 'B';
|
||||||
|
const char CAPS_FLAG_SSU_INTRODUCER = 'C';
|
||||||
|
|
||||||
const int MAX_RI_BUFFER_SIZE = 2048;
|
const int MAX_RI_BUFFER_SIZE = 2048;
|
||||||
class RouterInfo: public RoutingDestination
|
class RouterInfo: public RoutingDestination
|
||||||
{
|
{
|
||||||
@ -97,6 +110,7 @@ namespace data
|
|||||||
bool IsHidden () const { return m_Caps & eHidden; };
|
bool IsHidden () const { return m_Caps & eHidden; };
|
||||||
|
|
||||||
uint8_t GetCaps () const { return m_Caps; };
|
uint8_t GetCaps () const { return m_Caps; };
|
||||||
|
void SetCaps (uint8_t caps);
|
||||||
void SetCaps (const char * caps);
|
void SetCaps (const char * caps);
|
||||||
|
|
||||||
void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; };
|
void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; };
|
||||||
@ -134,7 +148,8 @@ namespace data
|
|||||||
void ExtractCaps (const char * value);
|
void ExtractCaps (const char * value);
|
||||||
void UpdateIdentHashBase64 ();
|
void UpdateIdentHashBase64 ();
|
||||||
const Address * GetAddress (TransportStyle s, bool v4only) const;
|
const Address * GetAddress (TransportStyle s, bool v4only) const;
|
||||||
|
void UpdateCapsProperty ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string m_FullPath;
|
std::string m_FullPath;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user