mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-13 01:20:22 +03:00
handle ipv6 address for RelayIntro
This commit is contained in:
parent
ff9ee5873f
commit
ef1dfb153c
@ -716,18 +716,36 @@ namespace transport
|
|||||||
|
|
||||||
void SSUSession::ProcessRelayIntro (const uint8_t * buf, size_t len)
|
void SSUSession::ProcessRelayIntro (const uint8_t * buf, size_t len)
|
||||||
{
|
{
|
||||||
|
if (!len) return;
|
||||||
uint8_t size = *buf;
|
uint8_t size = *buf;
|
||||||
|
if ((int)len < 1 + size + 2) // size + address + port
|
||||||
|
{
|
||||||
|
LogPrint (eLogWarning, "SSU: Relay intro is too short ", len);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
buf++; // size
|
||||||
|
boost::asio::ip::address ip;
|
||||||
if (size == 4)
|
if (size == 4)
|
||||||
{
|
{
|
||||||
buf++; // size
|
boost::asio::ip::address_v4::bytes_type bytes;
|
||||||
boost::asio::ip::address_v4 address (bufbe32toh (buf));
|
memcpy (bytes.data (), buf, 4);
|
||||||
buf += 4; // address
|
ip = boost::asio::ip::address_v4 (bytes);
|
||||||
uint16_t port = bufbe16toh (buf);
|
}
|
||||||
// send hole punch of 0 bytes
|
else if (size == 16)
|
||||||
m_Server.Send (buf, 0, boost::asio::ip::udp::endpoint (address, port));
|
{
|
||||||
|
boost::asio::ip::address_v6::bytes_type bytes;
|
||||||
|
memcpy (bytes.data (), buf, 16);
|
||||||
|
ip = boost::asio::ip::address_v6 (bytes);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
LogPrint (eLogWarning, "SSU: Address size ", size, " is not supported");
|
LogPrint (eLogWarning, "SSU: Address size ", size, " is not supported");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
buf += size;
|
||||||
|
uint16_t port = bufbe16toh (buf);
|
||||||
|
// send hole punch of 0 bytes
|
||||||
|
m_Server.Send (buf, 0, boost::asio::ip::udp::endpoint (ip, port));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SSUSession::FillHeaderAndEncrypt (uint8_t payloadType, uint8_t * buf, size_t len,
|
void SSUSession::FillHeaderAndEncrypt (uint8_t payloadType, uint8_t * buf, size_t len,
|
||||||
|
Loading…
Reference in New Issue
Block a user