mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
SSU2 introducers
This commit is contained in:
parent
45ebfe378b
commit
eb6437050f
|
@ -330,7 +330,7 @@ namespace data
|
||||||
introducer.iPort = boost::lexical_cast<int>(value);
|
introducer.iPort = boost::lexical_cast<int>(value);
|
||||||
else if (!strcmp (key, "itag"))
|
else if (!strcmp (key, "itag"))
|
||||||
introducer.iTag = boost::lexical_cast<uint32_t>(value);
|
introducer.iTag = boost::lexical_cast<uint32_t>(value);
|
||||||
else if (!strcmp (key, "ikey"))
|
else if (!strcmp (key, "ikey") || !strcmp (key, "ih"))
|
||||||
Base64ToByteStream (value, strlen (value), introducer.iKey, 32);
|
Base64ToByteStream (value, strlen (value), introducer.iKey, 32);
|
||||||
else if (!strcmp (key, "iexp"))
|
else if (!strcmp (key, "iexp"))
|
||||||
introducer.iExp = boost::lexical_cast<uint32_t>(value);
|
introducer.iExp = boost::lexical_cast<uint32_t>(value);
|
||||||
|
@ -425,6 +425,9 @@ namespace data
|
||||||
ssu2addr->date = address->date; ssu2addr->caps = address->caps;
|
ssu2addr->date = address->date; ssu2addr->caps = address->caps;
|
||||||
ssu2addr->published = address->published;
|
ssu2addr->published = address->published;
|
||||||
ssu2addr->ssu.reset (new SSUExt ()); ssu2addr->ssu->mtu = address->ssu->mtu;
|
ssu2addr->ssu.reset (new SSUExt ()); ssu2addr->ssu->mtu = address->ssu->mtu;
|
||||||
|
for (const auto& introducer: address->ssu->introducers)
|
||||||
|
if (!introducer.iPort) // SSU2
|
||||||
|
ssu2addr->ssu->introducers.push_back (introducer);
|
||||||
addresses->push_back(ssu2addr);
|
addresses->push_back(ssu2addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1227,7 +1230,14 @@ namespace data
|
||||||
WriteString (address.host.to_string (), properties);
|
WriteString (address.host.to_string (), properties);
|
||||||
properties << ';';
|
properties << ';';
|
||||||
}
|
}
|
||||||
if (address.transportStyle == eTransportSSU)
|
if ((address.IsNTCP2 () && isPublished) || address.IsSSU2 ())
|
||||||
|
{
|
||||||
|
// publish i for NTCP2 or SSU2
|
||||||
|
WriteString ("i", properties); properties << '=';
|
||||||
|
size_t len = address.IsSSU2 () ? 32 : 16;
|
||||||
|
WriteString (address.i.ToBase64 (len), properties); properties << ';';
|
||||||
|
}
|
||||||
|
if (address.transportStyle == eTransportSSU || address.IsSSU2 ())
|
||||||
{
|
{
|
||||||
// write introducers if any
|
// write introducers if any
|
||||||
if (!address.ssu->introducers.empty())
|
if (!address.ssu->introducers.empty())
|
||||||
|
@ -1244,6 +1254,8 @@ namespace data
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (address.transportStyle == eTransportSSU)
|
||||||
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
for (const auto& introducer: address.ssu->introducers)
|
for (const auto& introducer: address.ssu->introducers)
|
||||||
{
|
{
|
||||||
|
@ -1253,9 +1265,13 @@ namespace data
|
||||||
properties << ';';
|
properties << ';';
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
for (const auto& introducer: address.ssu->introducers)
|
for (const auto& introducer: address.ssu->introducers)
|
||||||
{
|
{
|
||||||
|
if (address.IsSSU2 ())
|
||||||
|
WriteString ("ih" + boost::lexical_cast<std::string>(i), properties);
|
||||||
|
else
|
||||||
WriteString ("ikey" + boost::lexical_cast<std::string>(i), properties);
|
WriteString ("ikey" + boost::lexical_cast<std::string>(i), properties);
|
||||||
properties << '=';
|
properties << '=';
|
||||||
char value[64];
|
char value[64];
|
||||||
|
@ -1265,6 +1281,8 @@ namespace data
|
||||||
properties << ';';
|
properties << ';';
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
if (address.transportStyle == eTransportSSU)
|
||||||
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
for (const auto& introducer: address.ssu->introducers)
|
for (const auto& introducer: address.ssu->introducers)
|
||||||
{
|
{
|
||||||
|
@ -1274,6 +1292,7 @@ namespace data
|
||||||
properties << ';';
|
properties << ';';
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
i = 0;
|
i = 0;
|
||||||
for (const auto& introducer: address.ssu->introducers)
|
for (const auto& introducer: address.ssu->introducers)
|
||||||
{
|
{
|
||||||
|
@ -1284,6 +1303,9 @@ namespace data
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (address.transportStyle == eTransportSSU)
|
||||||
|
{
|
||||||
// write intro key
|
// write intro key
|
||||||
WriteString ("key", properties);
|
WriteString ("key", properties);
|
||||||
properties << '=';
|
properties << '=';
|
||||||
|
@ -1292,6 +1314,9 @@ namespace data
|
||||||
value[l] = 0;
|
value[l] = 0;
|
||||||
WriteString (value, properties);
|
WriteString (value, properties);
|
||||||
properties << ';';
|
properties << ';';
|
||||||
|
}
|
||||||
|
if (address.transportStyle == eTransportSSU || address.IsSSU2 ())
|
||||||
|
{
|
||||||
// write mtu
|
// write mtu
|
||||||
if (address.ssu->mtu)
|
if (address.ssu->mtu)
|
||||||
{
|
{
|
||||||
|
@ -1301,15 +1326,6 @@ namespace data
|
||||||
properties << ';';
|
properties << ';';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((address.IsNTCP2 () && isPublished) || address.IsSSU2 ())
|
|
||||||
{
|
|
||||||
// publish i for NTCP2 or SSU2
|
|
||||||
WriteString ("i", properties); properties << '=';
|
|
||||||
size_t len = address.IsSSU2 () ? 32 : 16;
|
|
||||||
WriteString (address.i.ToBase64 (len), properties); properties << ';';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isPublished || (address.ssu && !address.IsSSU2 ()))
|
if (isPublished || (address.ssu && !address.IsSSU2 ()))
|
||||||
{
|
{
|
||||||
WriteString ("port", properties);
|
WriteString ("port", properties);
|
||||||
|
|
|
@ -107,7 +107,7 @@ namespace data
|
||||||
Introducer (): iPort (0), iExp (0) {};
|
Introducer (): iPort (0), iExp (0) {};
|
||||||
boost::asio::ip::address iHost;
|
boost::asio::ip::address iHost;
|
||||||
int iPort;
|
int iPort;
|
||||||
IntroKey iKey;
|
IntroKey iKey; // or ih for SSU2
|
||||||
uint32_t iTag;
|
uint32_t iTag;
|
||||||
uint32_t iExp;
|
uint32_t iExp;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue