|
|
@ -882,17 +882,11 @@ namespace transport |
|
|
|
|
|
|
|
|
|
|
|
void SSUSession::ProcessPeerTest (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint) |
|
|
|
void SSUSession::ProcessPeerTest (const uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const uint8_t * buf1 = buf; |
|
|
|
uint32_t nonce = bufbe32toh (buf); // 4 bytes
|
|
|
|
uint32_t nonce = bufbe32toh (buf); |
|
|
|
uint8_t size = buf[4]; // 1 byte
|
|
|
|
buf += 4; // nonce
|
|
|
|
uint32_t address = (size == 4) ? buf32toh(buf + 5) : 0; // big endian, size bytes
|
|
|
|
uint8_t size = *buf; |
|
|
|
uint16_t port = buf16toh(buf + size + 5); // big endian, 2 bytes
|
|
|
|
buf++; // size
|
|
|
|
const uint8_t * introKey = buf + size + 7; |
|
|
|
|
|
|
|
|
|
|
|
uint32_t address = (size == 4) ? buf32toh(buf) : 0; // use it as is
|
|
|
|
|
|
|
|
buf += size; // address
|
|
|
|
|
|
|
|
uint16_t port = buf16toh(buf); // use it as is
|
|
|
|
|
|
|
|
buf += 2; // port
|
|
|
|
|
|
|
|
const uint8_t * introKey = buf; |
|
|
|
|
|
|
|
if (port && !address) |
|
|
|
if (port && !address) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogWarning, "Address of ", size, " bytes not supported"); |
|
|
|
LogPrint (eLogWarning, "Address of ", size, " bytes not supported"); |
|
|
@ -938,7 +932,7 @@ namespace transport |
|
|
|
boost::asio::ip::udp::endpoint ep (boost::asio::ip::address_v4 (be32toh (address)), be16toh (port)); // Alice's address/port
|
|
|
|
boost::asio::ip::udp::endpoint ep (boost::asio::ip::address_v4 (be32toh (address)), be16toh (port)); // Alice's address/port
|
|
|
|
auto session = m_Server.FindSession (ep); // find session with Alice
|
|
|
|
auto session = m_Server.FindSession (ep); // find session with Alice
|
|
|
|
if (session) |
|
|
|
if (session) |
|
|
|
session->Send (PAYLOAD_TYPE_PEER_TEST, buf1, len); // back to Alice
|
|
|
|
session->Send (PAYLOAD_TYPE_PEER_TEST, buf, len); // back to Alice
|
|
|
|
m_Server.RemovePeerTest (nonce); // nonce has been used
|
|
|
|
m_Server.RemovePeerTest (nonce); // nonce has been used
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -960,7 +954,7 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogDebug, "SSU peer test from Bob. We are Charlie"); |
|
|
|
LogPrint (eLogDebug, "SSU peer test from Bob. We are Charlie"); |
|
|
|
m_Server.NewPeerTest (nonce, ePeerTestParticipantCharlie); |
|
|
|
m_Server.NewPeerTest (nonce, ePeerTestParticipantCharlie); |
|
|
|
Send (PAYLOAD_TYPE_PEER_TEST, buf1, len); // back to Bob
|
|
|
|
Send (PAYLOAD_TYPE_PEER_TEST, buf, len); // back to Bob
|
|
|
|
SendPeerTest (nonce, be32toh (address), be16toh (port), introKey); // to Alice with her address received from Bob
|
|
|
|
SendPeerTest (nonce, be32toh (address), be16toh (port), introKey); // to Alice with her address received from Bob
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|