Browse Source

process relay intro

pull/64/head
orignal 11 years ago
parent
commit
76cb75f7c0
  1. 18
      SSU.cpp
  2. 1
      SSU.h

18
SSU.cpp

@ -115,7 +115,7 @@ namespace ssu @@ -115,7 +115,7 @@ namespace ssu
}
case PAYLOAD_TYPE_RELAY_INTRO:
LogPrint ("SSU relay intro received");
// TODO:
ProcessRelayIntro (buf + sizeof (SSUHeader), len - sizeof (SSUHeader));
break;
default:
LogPrint ("Unexpected SSU payload type ", (int)header->GetPayloadType ());
@ -430,6 +430,22 @@ namespace ssu @@ -430,6 +430,22 @@ namespace ssu
}
}
void SSUSession::ProcessRelayIntro (uint8_t * buf, size_t len)
{
uint8_t size = *buf;
if (size == 4)
{
buf++; // size
boost::asio::ip::address_v4 address (be32toh (*(uint32_t* )buf));
buf += 4; // address
uint16_t port = be16toh (*(uint16_t *)buf);
// send hole punch of 1 byte
m_Server.Send (buf, 1, boost::asio::ip::udp::endpoint (address, port));
}
else
LogPrint ("Address size ", size, " is not supported");
}
void SSUSession::FillHeaderAndEncrypt (uint8_t payloadType, uint8_t * buf, size_t len,
const uint8_t * aesKey, const uint8_t * iv, const uint8_t * macKey)
{

1
SSU.h

@ -100,6 +100,7 @@ namespace ssu @@ -100,6 +100,7 @@ namespace ssu
void ProcessSessionConfirmed (uint8_t * buf, size_t len);
void SendSessionConfirmed (const uint8_t * y, const uint8_t * ourAddress, uint32_t relayTag);
void ProcessRelayResponse (uint8_t * buf, size_t len);
void ProcessRelayIntro (uint8_t * buf, size_t len);
void Established ();
void Failed ();
void HandleConnectTimer (const boost::system::error_code& ecode);

Loading…
Cancel
Save