mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-23 05:47:17 +01:00
different log levels
This commit is contained in:
parent
11a0bbc368
commit
1f69d1b890
82
SSU.cpp
82
SSU.cpp
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
24
SSUData.cpp
24
SSUData.cpp
|
@ -47,7 +47,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint ("Unexpected MTU ", ssuAddress->mtu);
|
LogPrint (eLogWarning, "Unexpected MTU ", ssuAddress->mtu);
|
||||||
m_PacketSize = SSU_MAX_PACKET_SIZE;
|
m_PacketSize = SSU_MAX_PACKET_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ namespace transport
|
||||||
uint16_t fragmentSize = fragmentInfo & 0x1FFF; // bits 0 - 13
|
uint16_t fragmentSize = fragmentInfo & 0x1FFF; // bits 0 - 13
|
||||||
bool isLast = fragmentInfo & 0x010000; // bit 16
|
bool isLast = fragmentInfo & 0x010000; // bit 16
|
||||||
uint8_t fragmentNum = fragmentInfo >> 17; // bits 23 - 17
|
uint8_t fragmentNum = fragmentInfo >> 17; // bits 23 - 17
|
||||||
LogPrint ("SSU data fragment ", (int)fragmentNum, " of message ", msgID, " size=", (int)fragmentSize, isLast ? " last" : " non-last");
|
LogPrint (eLogDebug, "SSU data fragment ", (int)fragmentNum, " of message ", msgID, " size=", (int)fragmentSize, isLast ? " last" : " non-last");
|
||||||
|
|
||||||
// find message with msgID
|
// find message with msgID
|
||||||
I2NPMessage * msg = nullptr;
|
I2NPMessage * msg = nullptr;
|
||||||
|
@ -190,22 +190,22 @@ namespace transport
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isLast)
|
if (isLast)
|
||||||
LogPrint ("Message ", msgID, " complete");
|
LogPrint (eLogDebug, "Message ", msgID, " complete");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fragmentNum < incompleteMessage->nextFragmentNum)
|
if (fragmentNum < incompleteMessage->nextFragmentNum)
|
||||||
// duplicate fragment
|
// duplicate fragment
|
||||||
LogPrint ("Duplicate fragment ", (int)fragmentNum, " of message ", msgID, ". Ignored");
|
LogPrint (eLogWarning, "Duplicate fragment ", (int)fragmentNum, " of message ", msgID, ". Ignored");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// missing fragment
|
// missing fragment
|
||||||
LogPrint ("Missing fragments from ", (int)incompleteMessage->nextFragmentNum, " to ", fragmentNum - 1, " of message ", msgID);
|
LogPrint (eLogWarning, "Missing fragments from ", (int)incompleteMessage->nextFragmentNum, " to ", fragmentNum - 1, " of message ", msgID);
|
||||||
auto savedFragment = new Fragment (fragmentNum, buf, fragmentSize, isLast);
|
auto savedFragment = new Fragment (fragmentNum, buf, fragmentSize, isLast);
|
||||||
if (!incompleteMessage->savedFragments.insert (savedFragment).second)
|
if (!incompleteMessage->savedFragments.insert (savedFragment).second)
|
||||||
{
|
{
|
||||||
LogPrint ("Fragment ", (int)fragmentNum, " of message ", msgID, " already saved");
|
LogPrint (eLogWarning, "Fragment ", (int)fragmentNum, " of message ", msgID, " already saved");
|
||||||
delete savedFragment;
|
delete savedFragment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ namespace transport
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint ("SSU message ", msgID, " already received");
|
LogPrint (eLogWarning, "SSU message ", msgID, " already received");
|
||||||
i2p::DeleteI2NPMessage (msg);
|
i2p::DeleteI2NPMessage (msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ namespace transport
|
||||||
m_Session.Established ();
|
m_Session.Established ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint ("SSU unexpected message ", (int)msg->GetHeader ()->typeID);
|
LogPrint (eLogError, "SSU unexpected message ", (int)msg->GetHeader ()->typeID);
|
||||||
DeleteI2NPMessage (msg);
|
DeleteI2NPMessage (msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ namespace transport
|
||||||
//uint8_t * start = buf;
|
//uint8_t * start = buf;
|
||||||
uint8_t flag = *buf;
|
uint8_t flag = *buf;
|
||||||
buf++;
|
buf++;
|
||||||
LogPrint ("Process SSU data flags=", (int)flag);
|
LogPrint (eLogDebug, "Process SSU data flags=", (int)flag);
|
||||||
// process acks if presented
|
// process acks if presented
|
||||||
if (flag & (DATA_FLAG_ACK_BITFIELDS_INCLUDED | DATA_FLAG_EXPLICIT_ACKS_INCLUDED))
|
if (flag & (DATA_FLAG_ACK_BITFIELDS_INCLUDED | DATA_FLAG_EXPLICIT_ACKS_INCLUDED))
|
||||||
ProcessAcks (buf, flag);
|
ProcessAcks (buf, flag);
|
||||||
|
@ -267,7 +267,7 @@ namespace transport
|
||||||
{
|
{
|
||||||
uint8_t extendedDataSize = *buf;
|
uint8_t extendedDataSize = *buf;
|
||||||
buf++; // size
|
buf++; // size
|
||||||
LogPrint ("SSU extended data of ", extendedDataSize, " bytes presented");
|
LogPrint (eLogDebug, "SSU extended data of ", extendedDataSize, " bytes presented");
|
||||||
buf += extendedDataSize;
|
buf += extendedDataSize;
|
||||||
}
|
}
|
||||||
// process data
|
// process data
|
||||||
|
@ -279,7 +279,7 @@ namespace transport
|
||||||
uint32_t msgID = msg->ToSSU ();
|
uint32_t msgID = msg->ToSSU ();
|
||||||
if (m_SentMessages.count (msgID) > 0)
|
if (m_SentMessages.count (msgID) > 0)
|
||||||
{
|
{
|
||||||
LogPrint ("SSU message ", msgID, " already sent");
|
LogPrint (eLogWarning, "SSU message ", msgID, " already sent");
|
||||||
DeleteI2NPMessage (msg);
|
DeleteI2NPMessage (msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -363,7 +363,7 @@ namespace transport
|
||||||
{
|
{
|
||||||
if (fragmentNum > 64)
|
if (fragmentNum > 64)
|
||||||
{
|
{
|
||||||
LogPrint ("Fragment number ", fragmentNum, " exceeds 64");
|
LogPrint (eLogWarning, "Fragment number ", fragmentNum, " exceeds 64");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t buf[64 + 18];
|
uint8_t buf[64 + 18];
|
||||||
|
|
Loading…
Reference in a new issue