mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
extract SSU caps
This commit is contained in:
parent
8de75a2a90
commit
6d42cccadc
@ -129,6 +129,8 @@ namespace data
|
|||||||
address.port = boost::lexical_cast<int>(value);
|
address.port = boost::lexical_cast<int>(value);
|
||||||
else if (!strcmp (key, "key"))
|
else if (!strcmp (key, "key"))
|
||||||
Base64ToByteStream (value, strlen (value), address.key, 32);
|
Base64ToByteStream (value, strlen (value), address.key, 32);
|
||||||
|
else if (!strcmp (key, "caps"))
|
||||||
|
ExtractCaps (value);
|
||||||
else if (key[0] == 'i')
|
else if (key[0] == 'i')
|
||||||
{
|
{
|
||||||
// introducers
|
// introducers
|
||||||
@ -191,7 +193,6 @@ namespace data
|
|||||||
|
|
||||||
void RouterInfo::ExtractCaps (const char * value)
|
void RouterInfo::ExtractCaps (const char * value)
|
||||||
{
|
{
|
||||||
m_Caps = 0;
|
|
||||||
const char * cap = value;
|
const char * cap = value;
|
||||||
while (*cap)
|
while (*cap)
|
||||||
{
|
{
|
||||||
@ -208,6 +209,12 @@ namespace data
|
|||||||
case 'R':
|
case 'R':
|
||||||
m_Caps |= Caps::eReachable;
|
m_Caps |= Caps::eReachable;
|
||||||
break;
|
break;
|
||||||
|
case 'B':
|
||||||
|
m_Caps |= Caps::eSSUTesting;
|
||||||
|
break;
|
||||||
|
case 'C':
|
||||||
|
m_Caps |= Caps::eSSUIntroducer;
|
||||||
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
cap++;
|
cap++;
|
||||||
@ -249,7 +256,10 @@ namespace data
|
|||||||
// caps
|
// caps
|
||||||
WriteString ("caps", properties);
|
WriteString ("caps", properties);
|
||||||
properties << '=';
|
properties << '=';
|
||||||
WriteString ("B", properties); // TODO: should be 'BC' for introducers
|
std::string caps;
|
||||||
|
if (IsPeerTesting ()) caps += 'B';
|
||||||
|
if (IsIntroducer ()) caps += 'C';
|
||||||
|
WriteString (caps, properties);
|
||||||
properties << ';';
|
properties << ';';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -344,11 +354,12 @@ namespace data
|
|||||||
addr.host = boost::asio::ip::address::from_string (host);
|
addr.host = boost::asio::ip::address::from_string (host);
|
||||||
addr.port = port;
|
addr.port = port;
|
||||||
addr.transportStyle = eTransportSSU;
|
addr.transportStyle = eTransportSSU;
|
||||||
addr.cost = 10; // NTCP should have prioprity over SSU
|
addr.cost = 10; // NTCP should have priority over SSU
|
||||||
addr.date = 0;
|
addr.date = 0;
|
||||||
memcpy (addr.key, key, 32);
|
memcpy (addr.key, key, 32);
|
||||||
m_Addresses.push_back(addr);
|
m_Addresses.push_back(addr);
|
||||||
m_SupportedTransports |= eSSUV4;
|
m_SupportedTransports |= eSSUV4;
|
||||||
|
m_Caps |= eSSUTesting; // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void RouterInfo::SetProperty (const char * key, const char * value)
|
void RouterInfo::SetProperty (const char * key, const char * value)
|
||||||
|
@ -29,7 +29,9 @@ namespace data
|
|||||||
{
|
{
|
||||||
eFloodfill = 0x01,
|
eFloodfill = 0x01,
|
||||||
eHighBandwidth = 0x02,
|
eHighBandwidth = 0x02,
|
||||||
eReachable = 0x04
|
eReachable = 0x04,
|
||||||
|
eSSUTesting = 0x08,
|
||||||
|
eSSUIntroducer = 0x10
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TransportStyle
|
enum TransportStyle
|
||||||
@ -84,6 +86,8 @@ namespace data
|
|||||||
bool IsSSU (bool v4only = true) const;
|
bool IsSSU (bool v4only = true) const;
|
||||||
bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; };
|
bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; };
|
||||||
bool UsesIntroducer () const;
|
bool UsesIntroducer () const;
|
||||||
|
bool IsIntroducer () const { return m_Caps & eSSUIntroducer; };
|
||||||
|
bool IsPeerTesting () const { return m_Caps & eSSUTesting; };
|
||||||
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; };
|
||||||
|
@ -123,16 +123,16 @@ namespace i2p
|
|||||||
|
|
||||||
void Transports::Stop ()
|
void Transports::Stop ()
|
||||||
{
|
{
|
||||||
for (auto session: m_NTCPSessions)
|
|
||||||
delete session.second;
|
|
||||||
m_NTCPSessions.clear ();
|
|
||||||
delete m_NTCPAcceptor;
|
|
||||||
|
|
||||||
if (m_SSUServer)
|
if (m_SSUServer)
|
||||||
{
|
{
|
||||||
m_SSUServer->Stop ();
|
m_SSUServer->Stop ();
|
||||||
delete m_SSUServer;
|
delete m_SSUServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto session: m_NTCPSessions)
|
||||||
|
delete session.second;
|
||||||
|
m_NTCPSessions.clear ();
|
||||||
|
delete m_NTCPAcceptor;
|
||||||
|
|
||||||
m_DHKeysPairSupplier.Stop ();
|
m_DHKeysPairSupplier.Stop ();
|
||||||
m_IsRunning = false;
|
m_IsRunning = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user