|
|
@ -645,30 +645,16 @@ namespace transport |
|
|
|
void SSUSession::ProcessRelayResponse (const uint8_t * buf, size_t len) |
|
|
|
void SSUSession::ProcessRelayResponse (const uint8_t * buf, size_t len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogDebug, "SSU message: Relay response received"); |
|
|
|
LogPrint (eLogDebug, "SSU message: Relay response received"); |
|
|
|
uint8_t remoteSize = *buf; |
|
|
|
boost::asio::ip::address remoteIP; |
|
|
|
buf++; // remote size
|
|
|
|
uint16_t remotePort = 0; |
|
|
|
boost::asio::ip::address_v4 remoteIP (bufbe32toh (buf)); |
|
|
|
auto remoteSize = ExtractIPAddressAndPort (buf, len, remoteIP, remotePort); |
|
|
|
buf += remoteSize; // remote address
|
|
|
|
if (!remoteSize) return; |
|
|
|
uint16_t remotePort = bufbe16toh (buf); |
|
|
|
buf += remoteSize; len -= remoteSize; |
|
|
|
buf += 2; // remote port
|
|
|
|
|
|
|
|
uint8_t ourSize = *buf; |
|
|
|
|
|
|
|
buf++; // our size
|
|
|
|
|
|
|
|
boost::asio::ip::address ourIP; |
|
|
|
boost::asio::ip::address ourIP; |
|
|
|
if (ourSize == 4) |
|
|
|
uint16_t ourPort = 0; |
|
|
|
{ |
|
|
|
auto ourSize = ExtractIPAddressAndPort (buf, len, ourIP, ourPort); |
|
|
|
boost::asio::ip::address_v4::bytes_type bytes; |
|
|
|
if (!ourSize) return; |
|
|
|
memcpy (bytes.data (), buf, 4); |
|
|
|
buf += ourSize; len -= ourSize; |
|
|
|
ourIP = boost::asio::ip::address_v4 (bytes); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
boost::asio::ip::address_v6::bytes_type bytes; |
|
|
|
|
|
|
|
memcpy (bytes.data (), buf, 16); |
|
|
|
|
|
|
|
ourIP = boost::asio::ip::address_v6 (bytes); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
buf += ourSize; // our address
|
|
|
|
|
|
|
|
uint16_t ourPort = bufbe16toh (buf); |
|
|
|
|
|
|
|
buf += 2; // our port
|
|
|
|
|
|
|
|
LogPrint (eLogInfo, "SSU: Our external address is ", ourIP.to_string (), ":", ourPort); |
|
|
|
LogPrint (eLogInfo, "SSU: Our external address is ", ourIP.to_string (), ":", ourPort); |
|
|
|
i2p::context.UpdateAddress (ourIP); |
|
|
|
i2p::context.UpdateAddress (ourIP); |
|
|
|
if (ourPort != m_Server.GetPort ()) |
|
|
|
if (ourPort != m_Server.GetPort ()) |
|
|
|