recognize SSU2 addresses

This commit is contained in:
orignal 2022-03-11 16:17:44 -05:00
parent 7faa732f38
commit 68d015763e
6 changed files with 75 additions and 22 deletions

View file

@ -221,9 +221,9 @@ namespace data
ReadString (transportStyle, 6, s);
if (!strncmp (transportStyle, "NTCP", 4)) // NTCP or NTCP2
address->transportStyle = eTransportNTCP;
else if (!strcmp (transportStyle, "SSU"))
else if (!strncmp (transportStyle, "SSU", 3)) // SSU or SSU2
{
address->transportStyle = eTransportSSU;
address->transportStyle = (transportStyle[3] == '2') ? eTransportSSU2 : eTransportSSU;
address->ssu.reset (new SSUExt ());
address->ssu->mtu = 0;
}
@ -266,12 +266,12 @@ namespace data
}
else if (!strcmp (key, "caps"))
address->caps = ExtractAddressCaps (value);
else if (!strcmp (key, "s")) // ntcp2 static key
else if (!strcmp (key, "s")) // ntcp2 or ssu2 static key
{
Base64ToByteStream (value, strlen (value), address->s, 32);
isStaticKey = true;
}
else if (!strcmp (key, "i")) // ntcp2 iv
else if (!strcmp (key, "i")) // ntcp2 iv or ssu2 intro
{
Base64ToByteStream (value, strlen (value), address->i, 16);
address->published = true; // presence if "i" means "published"
@ -378,6 +378,10 @@ namespace data
}
}
}
else if (address->transportStyle == eTransportSSU2)
{
// TODO:
}
if (supportedTransports)
{
if (!(m_SupportedTransports & supportedTransports)) // avoid duplicates
@ -1104,6 +1108,19 @@ namespace data
WriteString (caps, properties);
properties << ';';
}
else if (address.transportStyle == eTransportSSU2)
{
WriteString ("SSU2", s);
// caps
WriteString ("caps", properties);
properties << '=';
std::string caps;
if (address.IsV4 ()) caps += CAPS_FLAG_V4;
if (address.IsV6 ()) caps += CAPS_FLAG_V6;
if (caps.empty ()) caps += CAPS_FLAG_V4;
WriteString (caps, properties);
properties << ';';
}
else
WriteString ("", s);
@ -1203,9 +1220,9 @@ namespace data
WriteString (boost::lexical_cast<std::string>(address.port), properties);
properties << ';';
}
if (address.IsNTCP2 ())
if (address.IsNTCP2 () || address.IsSSU2 ())
{
// publish s and v for NTCP2
// publish s and v for NTCP2 or SSU2
WriteString ("s", properties); properties << '=';
WriteString (address.s.ToBase64 (), properties); properties << ';';
WriteString ("v", properties); properties << '=';