Browse Source

extract SSU caps

pull/64/head
orignal 11 years ago
parent
commit
6d42cccadc
  1. 17
      RouterInfo.cpp
  2. 6
      RouterInfo.h
  3. 10
      Transports.cpp

17
RouterInfo.cpp

@ -129,6 +129,8 @@ namespace data @@ -129,6 +129,8 @@ namespace data
address.port = boost::lexical_cast<int>(value);
else if (!strcmp (key, "key"))
Base64ToByteStream (value, strlen (value), address.key, 32);
else if (!strcmp (key, "caps"))
ExtractCaps (value);
else if (key[0] == 'i')
{
// introducers
@ -191,7 +193,6 @@ namespace data @@ -191,7 +193,6 @@ namespace data
void RouterInfo::ExtractCaps (const char * value)
{
m_Caps = 0;
const char * cap = value;
while (*cap)
{
@ -208,6 +209,12 @@ namespace data @@ -208,6 +209,12 @@ namespace data
case 'R':
m_Caps |= Caps::eReachable;
break;
case 'B':
m_Caps |= Caps::eSSUTesting;
break;
case 'C':
m_Caps |= Caps::eSSUIntroducer;
break;
default: ;
}
cap++;
@ -249,7 +256,10 @@ namespace data @@ -249,7 +256,10 @@ namespace data
// caps
WriteString ("caps", 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 << ';';
}
else
@ -344,11 +354,12 @@ namespace data @@ -344,11 +354,12 @@ namespace data
addr.host = boost::asio::ip::address::from_string (host);
addr.port = port;
addr.transportStyle = eTransportSSU;
addr.cost = 10; // NTCP should have prioprity over SSU
addr.cost = 10; // NTCP should have priority over SSU
addr.date = 0;
memcpy (addr.key, key, 32);
m_Addresses.push_back(addr);
m_SupportedTransports |= eSSUV4;
m_Caps |= eSSUTesting; // TODO
}
void RouterInfo::SetProperty (const char * key, const char * value)

6
RouterInfo.h

@ -29,7 +29,9 @@ namespace data @@ -29,7 +29,9 @@ namespace data
{
eFloodfill = 0x01,
eHighBandwidth = 0x02,
eReachable = 0x04
eReachable = 0x04,
eSSUTesting = 0x08,
eSSUIntroducer = 0x10
};
enum TransportStyle
@ -84,6 +86,8 @@ namespace data @@ -84,6 +86,8 @@ namespace data
bool IsSSU (bool v4only = true) const;
bool IsCompatible (const RouterInfo& other) const { return m_SupportedTransports & other.m_SupportedTransports; };
bool UsesIntroducer () const;
bool IsIntroducer () const { return m_Caps & eSSUIntroducer; };
bool IsPeerTesting () const { return m_Caps & eSSUTesting; };
uint8_t GetCaps () const { return m_Caps; };
void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; };

10
Transports.cpp

@ -123,17 +123,17 @@ namespace i2p @@ -123,17 +123,17 @@ namespace i2p
void Transports::Stop ()
{
for (auto session: m_NTCPSessions)
delete session.second;
m_NTCPSessions.clear ();
delete m_NTCPAcceptor;
if (m_SSUServer)
{
m_SSUServer->Stop ();
delete m_SSUServer;
}
for (auto session: m_NTCPSessions)
delete session.second;
m_NTCPSessions.clear ();
delete m_NTCPAcceptor;
m_DHKeysPairSupplier.Stop ();
m_IsRunning = false;
m_Service.stop ();

Loading…
Cancel
Save