mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
exclude addresses with wrong keys
This commit is contained in:
parent
c98926abf2
commit
c454685605
@ -217,7 +217,7 @@ namespace data
|
|||||||
uint8_t cost; // ignore
|
uint8_t cost; // ignore
|
||||||
s.read ((char *)&cost, sizeof (cost));
|
s.read ((char *)&cost, sizeof (cost));
|
||||||
s.read ((char *)&address->date, sizeof (address->date));
|
s.read ((char *)&address->date, sizeof (address->date));
|
||||||
bool isHost = false, isStaticKey = false, isV2 = false;
|
bool isHost = false, isStaticKey = false, isV2 = false, isIntroKey = false;
|
||||||
char transportStyle[6];
|
char transportStyle[6];
|
||||||
ReadString (transportStyle, 6, s);
|
ReadString (transportStyle, 6, s);
|
||||||
if (!strncmp (transportStyle, "NTCP", 4)) // NTCP or NTCP2
|
if (!strncmp (transportStyle, "NTCP", 4)) // NTCP or NTCP2
|
||||||
@ -294,26 +294,38 @@ namespace data
|
|||||||
address->caps = ExtractAddressCaps (value);
|
address->caps = ExtractAddressCaps (value);
|
||||||
else if (!strcmp (key, "s")) // ntcp2 or ssu2 static key
|
else if (!strcmp (key, "s")) // ntcp2 or ssu2 static key
|
||||||
{
|
{
|
||||||
Base64ToByteStream (value, strlen (value), address->s, 32);
|
if (Base64ToByteStream (value, strlen (value), address->s, 32) == 32 &&
|
||||||
if (!(address->s[31] & 0x80)) // check if x25519 public key
|
!(address->s[31] & 0x80)) // check if x25519 public key
|
||||||
isStaticKey = true;
|
isStaticKey = true;
|
||||||
|
else
|
||||||
|
address->transportStyle = eTransportUnknown; // invalid address
|
||||||
}
|
}
|
||||||
else if (!strcmp (key, "i")) // ntcp2 iv or ssu2 intro
|
else if (!strcmp (key, "i")) // ntcp2 iv or ssu2 intro
|
||||||
{
|
{
|
||||||
if (address->IsNTCP2 ())
|
if (address->IsNTCP2 ())
|
||||||
{
|
{
|
||||||
Base64ToByteStream (value, strlen (value), address->i, 16);
|
if (Base64ToByteStream (value, strlen (value), address->i, 16) == 16)
|
||||||
address->published = true; // presence of "i" means "published" NTCP2
|
address->published = true; // presence of "i" means "published" NTCP2
|
||||||
|
else
|
||||||
|
address->transportStyle = eTransportUnknown; // invalid address
|
||||||
}
|
}
|
||||||
else if (address->IsSSU2 ())
|
else if (address->IsSSU2 ())
|
||||||
Base64ToByteStream (value, strlen (value), address->i, 32);
|
{
|
||||||
|
if (Base64ToByteStream (value, strlen (value), address->i, 32) == 32)
|
||||||
|
isIntroKey = true;
|
||||||
|
else
|
||||||
|
address->transportStyle = eTransportUnknown; // invalid address
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!strcmp (key, "v"))
|
else if (!strcmp (key, "v"))
|
||||||
{
|
{
|
||||||
if (!strcmp (value, "2"))
|
if (!strcmp (value, "2"))
|
||||||
isV2 = true;
|
isV2 = true;
|
||||||
else
|
else
|
||||||
|
{
|
||||||
LogPrint (eLogWarning, "RouterInfo: Unexpected value ", value, " for v");
|
LogPrint (eLogWarning, "RouterInfo: Unexpected value ", value, " for v");
|
||||||
|
address->transportStyle = eTransportUnknown; // invalid address
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (key[0] == 'i')
|
else if (key[0] == 'i')
|
||||||
{
|
{
|
||||||
@ -391,7 +403,7 @@ namespace data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (address->transportStyle == eTransportSSU2 && isV2 && isStaticKey)
|
else if (address->transportStyle == eTransportSSU2 && isV2 && isStaticKey && isIntroKey)
|
||||||
{
|
{
|
||||||
if (address->IsV4 ()) supportedTransports |= eSSU2V4;
|
if (address->IsV4 ()) supportedTransports |= eSSU2V4;
|
||||||
if (address->IsV6 ()) supportedTransports |= eSSU2V6;
|
if (address->IsV6 ()) supportedTransports |= eSSU2V6;
|
||||||
|
Loading…
Reference in New Issue
Block a user