|
|
@ -37,7 +37,7 @@ namespace transport |
|
|
|
uint8_t sharedKey[256]; |
|
|
|
uint8_t sharedKey[256]; |
|
|
|
if (!dh.Agree (sharedKey, m_DHKeysPair->privateKey, pubKey)) |
|
|
|
if (!dh.Agree (sharedKey, m_DHKeysPair->privateKey, pubKey)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Couldn't create shared key"); |
|
|
|
LogPrint (eLogError, "Couldn't create shared key"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -104,14 +104,14 @@ namespace transport |
|
|
|
auto address = i2p::context.GetRouterInfo ().GetSSUAddress (); |
|
|
|
auto address = i2p::context.GetRouterInfo ().GetSSUAddress (); |
|
|
|
if (!address) |
|
|
|
if (!address) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU is not supported"); |
|
|
|
LogPrint (eLogError, "SSU is not supported"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (Validate (buf, len, address->key)) |
|
|
|
if (Validate (buf, len, address->key)) |
|
|
|
Decrypt (buf, len, address->key); |
|
|
|
Decrypt (buf, len, address->key); |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("MAC verification failed ", len, " bytes from ", senderEndpoint); |
|
|
|
LogPrint (eLogError, "MAC verification failed ", len, " bytes from ", senderEndpoint); |
|
|
|
m_Server.DeleteSession (this); |
|
|
|
m_Server.DeleteSession (this); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -128,7 +128,7 @@ namespace transport |
|
|
|
switch (header->GetPayloadType ()) |
|
|
|
switch (header->GetPayloadType ()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case PAYLOAD_TYPE_DATA: |
|
|
|
case PAYLOAD_TYPE_DATA: |
|
|
|
LogPrint ("SSU data received"); |
|
|
|
LogPrint (eLogDebug, "SSU data received"); |
|
|
|
ProcessData (buf + sizeof (SSUHeader), len - sizeof (SSUHeader)); |
|
|
|
ProcessData (buf + sizeof (SSUHeader), len - sizeof (SSUHeader)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case PAYLOAD_TYPE_SESSION_REQUEST: |
|
|
|
case PAYLOAD_TYPE_SESSION_REQUEST: |
|
|
@ -141,12 +141,12 @@ namespace transport |
|
|
|
ProcessSessionConfirmed (buf, len); |
|
|
|
ProcessSessionConfirmed (buf, len); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case PAYLOAD_TYPE_PEER_TEST: |
|
|
|
case PAYLOAD_TYPE_PEER_TEST: |
|
|
|
LogPrint ("SSU peer test received"); |
|
|
|
LogPrint (eLogDebug, "SSU peer test received"); |
|
|
|
ProcessPeerTest (buf + sizeof (SSUHeader), len - sizeof (SSUHeader), senderEndpoint); |
|
|
|
ProcessPeerTest (buf + sizeof (SSUHeader), len - sizeof (SSUHeader), senderEndpoint); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case PAYLOAD_TYPE_SESSION_DESTROYED: |
|
|
|
case PAYLOAD_TYPE_SESSION_DESTROYED: |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU session destroy received"); |
|
|
|
LogPrint (eLogDebug, "SSU session destroy received"); |
|
|
|
m_Server.DeleteSession (this); // delete this
|
|
|
|
m_Server.DeleteSession (this); // delete this
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -156,21 +156,21 @@ namespace transport |
|
|
|
m_Server.DeleteSession (this); |
|
|
|
m_Server.DeleteSession (this); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case PAYLOAD_TYPE_RELAY_REQUEST: |
|
|
|
case PAYLOAD_TYPE_RELAY_REQUEST: |
|
|
|
LogPrint ("SSU relay request received"); |
|
|
|
LogPrint (eLogDebug, "SSU relay request received"); |
|
|
|
ProcessRelayRequest (buf + sizeof (SSUHeader), len - sizeof (SSUHeader), senderEndpoint); |
|
|
|
ProcessRelayRequest (buf + sizeof (SSUHeader), len - sizeof (SSUHeader), senderEndpoint); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case PAYLOAD_TYPE_RELAY_INTRO: |
|
|
|
case PAYLOAD_TYPE_RELAY_INTRO: |
|
|
|
LogPrint ("SSU relay intro received"); |
|
|
|
LogPrint (eLogDebug, "SSU relay intro received"); |
|
|
|
ProcessRelayIntro (buf + sizeof (SSUHeader), len - sizeof (SSUHeader)); |
|
|
|
ProcessRelayIntro (buf + sizeof (SSUHeader), len - sizeof (SSUHeader)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
LogPrint ("Unexpected SSU payload type ", (int)header->GetPayloadType ()); |
|
|
|
LogPrint (eLogWarning, "Unexpected SSU payload type ", (int)header->GetPayloadType ()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSUSession::ProcessSessionRequest (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint) |
|
|
|
void SSUSession::ProcessSessionRequest (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Session request received"); |
|
|
|
LogPrint (eLogDebug, "Session request received"); |
|
|
|
m_RemoteEndpoint = senderEndpoint; |
|
|
|
m_RemoteEndpoint = senderEndpoint; |
|
|
|
if (!m_DHKeysPair) |
|
|
|
if (!m_DHKeysPair) |
|
|
|
m_DHKeysPair = transports.GetNextDHKeysPair (); |
|
|
|
m_DHKeysPair = transports.GetNextDHKeysPair (); |
|
|
@ -182,11 +182,11 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!m_RemoteRouter || !m_DHKeysPair) |
|
|
|
if (!m_RemoteRouter || !m_DHKeysPair) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Unsolicited session created message"); |
|
|
|
LogPrint (eLogWarning, "Unsolicited session created message"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LogPrint ("Session created received"); |
|
|
|
LogPrint (eLogDebug, "Session created received"); |
|
|
|
m_Timer.cancel (); // connect timer
|
|
|
|
m_Timer.cancel (); // connect timer
|
|
|
|
SignedData s; // x,y, our IP, our port, remote IP, remote port, relayTag, signed on time
|
|
|
|
SignedData s; // x,y, our IP, our port, remote IP, remote port, relayTag, signed on time
|
|
|
|
uint8_t * payload = buf + sizeof (SSUHeader); |
|
|
|
uint8_t * payload = buf + sizeof (SSUHeader); |
|
|
@ -215,14 +215,14 @@ namespace transport |
|
|
|
m_SessionKeyDecryption.Decrypt (payload, 48, payload); |
|
|
|
m_SessionKeyDecryption.Decrypt (payload, 48, payload); |
|
|
|
// verify
|
|
|
|
// verify
|
|
|
|
if (!s.Verify (m_RemoteIdentity, payload)) |
|
|
|
if (!s.Verify (m_RemoteIdentity, payload)) |
|
|
|
LogPrint ("SSU signature verification failed"); |
|
|
|
LogPrint (eLogError, "SSU signature verification failed"); |
|
|
|
|
|
|
|
|
|
|
|
SendSessionConfirmed (y, ourAddress); |
|
|
|
SendSessionConfirmed (y, ourAddress); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSUSession::ProcessSessionConfirmed (uint8_t * buf, size_t len) |
|
|
|
void SSUSession::ProcessSessionConfirmed (uint8_t * buf, size_t len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Session confirmed received"); |
|
|
|
LogPrint (eLogDebug, "Session confirmed received"); |
|
|
|
uint8_t * payload = buf + sizeof (SSUHeader); |
|
|
|
uint8_t * payload = buf + sizeof (SSUHeader); |
|
|
|
payload++; // identity fragment info
|
|
|
|
payload++; // identity fragment info
|
|
|
|
uint16_t identitySize = be16toh (*(uint16_t *)payload); |
|
|
|
uint16_t identitySize = be16toh (*(uint16_t *)payload); |
|
|
@ -245,7 +245,7 @@ namespace transport |
|
|
|
auto introKey = GetIntroKey (); |
|
|
|
auto introKey = GetIntroKey (); |
|
|
|
if (!introKey) |
|
|
|
if (!introKey) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU is not supported"); |
|
|
|
LogPrint (eLogError, "SSU is not supported"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -267,7 +267,7 @@ namespace transport |
|
|
|
auto address = i2p::context.GetRouterInfo ().GetSSUAddress (); |
|
|
|
auto address = i2p::context.GetRouterInfo ().GetSSUAddress (); |
|
|
|
if (!address) |
|
|
|
if (!address) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU is not supported"); |
|
|
|
LogPrint (eLogError, "SSU is not supported"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -301,7 +301,7 @@ namespace transport |
|
|
|
auto address = i2p::context.GetRouterInfo ().GetSSUAddress (); |
|
|
|
auto address = i2p::context.GetRouterInfo ().GetSSUAddress (); |
|
|
|
if (!introKey || !address) |
|
|
|
if (!introKey || !address) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU is not supported"); |
|
|
|
LogPrint (eLogError, "SSU is not supported"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); |
|
|
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator (); |
|
|
@ -444,7 +444,7 @@ namespace transport |
|
|
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_RESPONSE, buf, 64, introKey, iv, introKey); |
|
|
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_RESPONSE, buf, 64, introKey, iv, introKey); |
|
|
|
m_Server.Send (buf, 64, from); |
|
|
|
m_Server.Send (buf, 64, from); |
|
|
|
} |
|
|
|
} |
|
|
|
LogPrint ("SSU relay response sent"); |
|
|
|
LogPrint (eLogDebug, "SSU relay response sent"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSUSession::SendRelayIntro (SSUSession * session, const boost::asio::ip::udp::endpoint& from) |
|
|
|
void SSUSession::SendRelayIntro (SSUSession * session, const boost::asio::ip::udp::endpoint& from) |
|
|
@ -464,12 +464,12 @@ namespace transport |
|
|
|
rnd.GenerateBlock (iv, 16); // random iv
|
|
|
|
rnd.GenerateBlock (iv, 16); // random iv
|
|
|
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_INTRO, buf, 48, session->m_SessionKey, iv, session->m_MacKey); |
|
|
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_RELAY_INTRO, buf, 48, session->m_SessionKey, iv, session->m_MacKey); |
|
|
|
m_Server.Send (buf, 48, session->m_RemoteEndpoint); |
|
|
|
m_Server.Send (buf, 48, session->m_RemoteEndpoint); |
|
|
|
LogPrint ("SSU relay intro sent"); |
|
|
|
LogPrint (eLogDebug, "SSU relay intro sent"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSUSession::ProcessRelayResponse (uint8_t * buf, size_t len) |
|
|
|
void SSUSession::ProcessRelayResponse (uint8_t * buf, size_t len) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Relay response received"); |
|
|
|
LogPrint (eLogDebug, "Relay response received"); |
|
|
|
uint8_t * payload = buf + sizeof (SSUHeader); |
|
|
|
uint8_t * payload = buf + sizeof (SSUHeader); |
|
|
|
payload++; // remote size
|
|
|
|
payload++; // remote size
|
|
|
|
//boost::asio::ip::address_v4 remoteIP (be32toh (*(uint32_t* )(payload)));
|
|
|
|
//boost::asio::ip::address_v4 remoteIP (be32toh (*(uint32_t* )(payload)));
|
|
|
@ -498,7 +498,7 @@ namespace transport |
|
|
|
m_Server.Send (buf, 0, boost::asio::ip::udp::endpoint (address, port)); |
|
|
|
m_Server.Send (buf, 0, boost::asio::ip::udp::endpoint (address, port)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint ("Address size ", size, " is not supported"); |
|
|
|
LogPrint (eLogWarning, "Address size ", size, " is not supported"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SSUSession::FillHeaderAndEncrypt (uint8_t payloadType, uint8_t * buf, size_t len, |
|
|
|
void SSUSession::FillHeaderAndEncrypt (uint8_t payloadType, uint8_t * buf, size_t len, |
|
|
@ -506,7 +506,7 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (len < sizeof (SSUHeader)) |
|
|
|
if (len < sizeof (SSUHeader)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Unexpected SSU packet length ", len); |
|
|
|
LogPrint (eLogError, "Unexpected SSU packet length ", len); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
@ -529,7 +529,7 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (len < sizeof (SSUHeader)) |
|
|
|
if (len < sizeof (SSUHeader)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Unexpected SSU packet length ", len); |
|
|
|
LogPrint (eLogError, "Unexpected SSU packet length ", len); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
@ -550,7 +550,7 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (len < sizeof (SSUHeader)) |
|
|
|
if (len < sizeof (SSUHeader)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Unexpected SSU packet length ", len); |
|
|
|
LogPrint (eLogError, "Unexpected SSU packet length ", len); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
@ -566,7 +566,7 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (len < sizeof (SSUHeader)) |
|
|
|
if (len < sizeof (SSUHeader)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Unexpected SSU packet length ", len); |
|
|
|
LogPrint (eLogError, "Unexpected SSU packet length ", len); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
@ -583,7 +583,7 @@ namespace transport |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (len < sizeof (SSUHeader)) |
|
|
|
if (len < sizeof (SSUHeader)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Unexpected SSU packet length ", len); |
|
|
|
LogPrint (eLogError, "Unexpected SSU packet length ", len); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
|
SSUHeader * header = (SSUHeader *)buf; |
|
|
@ -756,7 +756,7 @@ namespace transport |
|
|
|
uint8_t * introKey = buf; |
|
|
|
uint8_t * introKey = buf; |
|
|
|
if (port && !address) |
|
|
|
if (port && !address) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Address of ", size, " bytes not supported"); |
|
|
|
LogPrint (eLogWarning, "Address of ", size, " bytes not supported"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (m_PeerTestNonces.count (nonce) > 0) |
|
|
|
if (m_PeerTestNonces.count (nonce) > 0) |
|
|
@ -764,13 +764,13 @@ namespace transport |
|
|
|
// existing test
|
|
|
|
// existing test
|
|
|
|
if (m_PeerTest) |
|
|
|
if (m_PeerTest) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU peer test from Bob. We are Alice"); |
|
|
|
LogPrint (eLogDebug, "SSU peer test from Bob. We are Alice"); |
|
|
|
m_PeerTestNonces.erase (nonce); |
|
|
|
m_PeerTestNonces.erase (nonce); |
|
|
|
m_PeerTest = false; |
|
|
|
m_PeerTest = false; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (port) |
|
|
|
else if (port) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU peer test from Charlie. We are Bob"); |
|
|
|
LogPrint (eLogDebug, "SSU peer test from Charlie. We are Bob"); |
|
|
|
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) |
|
|
@ -778,7 +778,7 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU peer test from Alice. We are Charlie"); |
|
|
|
LogPrint (eLogDebug, "SSU peer test from Alice. We are Charlie"); |
|
|
|
SendPeerTest (nonce, senderEndpoint.address ().to_v4 ().to_ulong (), |
|
|
|
SendPeerTest (nonce, senderEndpoint.address ().to_v4 ().to_ulong (), |
|
|
|
senderEndpoint.port (), introKey); // to Alice
|
|
|
|
senderEndpoint.port (), introKey); // to Alice
|
|
|
|
} |
|
|
|
} |
|
|
@ -791,13 +791,13 @@ namespace transport |
|
|
|
m_PeerTestNonces.insert (nonce); |
|
|
|
m_PeerTestNonces.insert (nonce); |
|
|
|
if (port) |
|
|
|
if (port) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU peer test from Bob. We are Charlie"); |
|
|
|
LogPrint (eLogDebug, "SSU peer test from Bob. We are Charlie"); |
|
|
|
Send (PAYLOAD_TYPE_PEER_TEST, buf1, len); // back to Bob
|
|
|
|
Send (PAYLOAD_TYPE_PEER_TEST, buf1, len); // back to Bob
|
|
|
|
SendPeerTest (nonce, be32toh (address), be16toh (port), introKey); // to Alice
|
|
|
|
SendPeerTest (nonce, be32toh (address), be16toh (port), introKey); // to Alice
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU peer test from Alice. We are Bob"); |
|
|
|
LogPrint (eLogDebug, "SSU peer test from Alice. We are Bob"); |
|
|
|
auto session = m_Server.GetRandomEstablishedSession (this); // charlie
|
|
|
|
auto session = m_Server.GetRandomEstablishedSession (this); // charlie
|
|
|
|
if (session) |
|
|
|
if (session) |
|
|
|
session->SendPeerTest (nonce, senderEndpoint.address ().to_v4 ().to_ulong (), |
|
|
|
session->SendPeerTest (nonce, senderEndpoint.address ().to_v4 ().to_ulong (), |
|
|
@ -805,7 +805,7 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint ("SSU peer test from Charlie. We are Alice"); |
|
|
|
LogPrint (eLogDebug, "SSU peer test from Charlie. We are Alice"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -852,11 +852,11 @@ namespace transport |
|
|
|
|
|
|
|
|
|
|
|
void SSUSession::SendPeerTest () |
|
|
|
void SSUSession::SendPeerTest () |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU sending peer test"); |
|
|
|
LogPrint (eLogDebug, "SSU sending peer test"); |
|
|
|
auto address = i2p::context.GetRouterInfo ().GetSSUAddress (); |
|
|
|
auto address = i2p::context.GetRouterInfo ().GetSSUAddress (); |
|
|
|
if (!address) |
|
|
|
if (!address) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU is not supported. Can't send peer test"); |
|
|
|
LogPrint (eLogError, "SSU is not supported. Can't send peer test"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
uint32_t nonce = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); |
|
|
|
uint32_t nonce = i2p::context.GetRandomNumberGenerator ().GenerateWord32 (); |
|
|
@ -877,7 +877,7 @@ namespace transport |
|
|
|
// encrypt message with session key
|
|
|
|
// encrypt message with session key
|
|
|
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_DATA, buf, 48); |
|
|
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_DATA, buf, 48); |
|
|
|
Send (buf, 48); |
|
|
|
Send (buf, 48); |
|
|
|
LogPrint ("SSU keep-alive sent"); |
|
|
|
LogPrint (eLogDebug, "SSU keep-alive sent"); |
|
|
|
ScheduleTermination (); |
|
|
|
ScheduleTermination (); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -890,7 +890,7 @@ namespace transport |
|
|
|
// encrypt message with session key
|
|
|
|
// encrypt message with session key
|
|
|
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_SESSION_DESTROYED, buf, 48); |
|
|
|
FillHeaderAndEncrypt (PAYLOAD_TYPE_SESSION_DESTROYED, buf, 48); |
|
|
|
Send (buf, 48); |
|
|
|
Send (buf, 48); |
|
|
|
LogPrint ("SSU session destroyed sent"); |
|
|
|
LogPrint (eLogDebug, "SSU session destroyed sent"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -900,7 +900,7 @@ namespace transport |
|
|
|
size_t msgSize = len + sizeof (SSUHeader); |
|
|
|
size_t msgSize = len + sizeof (SSUHeader); |
|
|
|
if (msgSize > SSU_MTU) |
|
|
|
if (msgSize > SSU_MTU) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU payload size ", msgSize, " exceeds MTU"); |
|
|
|
LogPrint (eLogWarning, "SSU payload size ", msgSize, " exceeds MTU"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
memcpy (buf + sizeof (SSUHeader), payload, len); |
|
|
|
memcpy (buf + sizeof (SSUHeader), payload, len); |
|
|
@ -963,7 +963,7 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
catch (std::exception& ex) |
|
|
|
catch (std::exception& ex) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("SSU server: ", ex.what ()); |
|
|
|
LogPrint (eLogError, "SSU server: ", ex.what ()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1095,7 +1095,7 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Can't connect to unreachable router. No introducers presented"); |
|
|
|
LogPrint (eLogWarning, "Can't connect to unreachable router. No introducers presented"); |
|
|
|
m_Sessions.erase (remoteEndpoint); |
|
|
|
m_Sessions.erase (remoteEndpoint); |
|
|
|
delete session; |
|
|
|
delete session; |
|
|
|
session = nullptr; |
|
|
|
session = nullptr; |
|
|
@ -1104,7 +1104,7 @@ namespace transport |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
LogPrint ("Router ", router->GetIdentHashAbbreviation (), " doesn't have SSU address"); |
|
|
|
LogPrint (eLogWarning, "Router ", router->GetIdentHashAbbreviation (), " doesn't have SSU address"); |
|
|
|
} |
|
|
|
} |
|
|
|
return session; |
|
|
|
return session; |
|
|
|
} |
|
|
|
} |
|
|
|