mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
cleanup from extra log messages
This commit is contained in:
parent
9639ab7f1e
commit
9896570e32
@ -44,7 +44,6 @@ namespace tunnel
|
|||||||
|
|
||||||
void TransitTunnelParticipant::FlushTunnelDataMsgs ()
|
void TransitTunnelParticipant::FlushTunnelDataMsgs ()
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "TransitTunnel: flush");
|
|
||||||
if (!m_TunnelDataMsgs.empty ())
|
if (!m_TunnelDataMsgs.empty ())
|
||||||
{
|
{
|
||||||
i2p::transport::transports.SendMessages (GetNextIdentHash (), m_TunnelDataMsgs);
|
i2p::transport::transports.SendMessages (GetNextIdentHash (), m_TunnelDataMsgs);
|
||||||
@ -75,7 +74,6 @@ namespace tunnel
|
|||||||
|
|
||||||
void TransitTunnelGateway::FlushTunnelDataMsgs ()
|
void TransitTunnelGateway::FlushTunnelDataMsgs ()
|
||||||
{
|
{
|
||||||
LogPrint (eLogDebug, "TransitTunnel: gateway flush");
|
|
||||||
m_Gateway.SendBuffer ();
|
m_Gateway.SendBuffer ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ namespace tunnel
|
|||||||
uint8_t * zero = (uint8_t *)memchr (decrypted + 4, 0, TUNNEL_DATA_ENCRYPTED_SIZE - 4); // witout 4-byte checksum
|
uint8_t * zero = (uint8_t *)memchr (decrypted + 4, 0, TUNNEL_DATA_ENCRYPTED_SIZE - 4); // witout 4-byte checksum
|
||||||
if (zero)
|
if (zero)
|
||||||
{
|
{
|
||||||
LogPrint ("TunnelMessage: zero found at ", (int)(zero-decrypted));
|
|
||||||
uint8_t * fragment = zero + 1;
|
uint8_t * fragment = zero + 1;
|
||||||
// verify checksum
|
// verify checksum
|
||||||
memcpy (msg->GetPayload () + TUNNEL_DATA_MSG_SIZE, msg->GetPayload () + 4, 16); // copy iv to the end
|
memcpy (msg->GetPayload () + TUNNEL_DATA_MSG_SIZE, msg->GetPayload () + 4, 16); // copy iv to the end
|
||||||
@ -35,7 +34,7 @@ namespace tunnel
|
|||||||
CryptoPP::SHA256().CalculateDigest (hash, fragment, TUNNEL_DATA_MSG_SIZE -(fragment - msg->GetPayload ()) + 16); // payload + iv
|
CryptoPP::SHA256().CalculateDigest (hash, fragment, TUNNEL_DATA_MSG_SIZE -(fragment - msg->GetPayload ()) + 16); // payload + iv
|
||||||
if (memcmp (hash, decrypted, 4))
|
if (memcmp (hash, decrypted, 4))
|
||||||
{
|
{
|
||||||
LogPrint ("TunnelMessage: checksum verification failed");
|
LogPrint (eLogError, "TunnelMessage: checksum verification failed");
|
||||||
i2p::DeleteI2NPMessage (msg);
|
i2p::DeleteI2NPMessage (msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -57,17 +56,14 @@ namespace tunnel
|
|||||||
switch (m.deliveryType)
|
switch (m.deliveryType)
|
||||||
{
|
{
|
||||||
case eDeliveryTypeLocal: // 0
|
case eDeliveryTypeLocal: // 0
|
||||||
LogPrint ("Delivery type local");
|
|
||||||
break;
|
break;
|
||||||
case eDeliveryTypeTunnel: // 1
|
case eDeliveryTypeTunnel: // 1
|
||||||
LogPrint ("Delivery type tunnel");
|
|
||||||
m.tunnelID = bufbe32toh (fragment);
|
m.tunnelID = bufbe32toh (fragment);
|
||||||
fragment += 4; // tunnelID
|
fragment += 4; // tunnelID
|
||||||
m.hash = i2p::data::IdentHash (fragment);
|
m.hash = i2p::data::IdentHash (fragment);
|
||||||
fragment += 32; // hash
|
fragment += 32; // hash
|
||||||
break;
|
break;
|
||||||
case eDeliveryTypeRouter: // 2
|
case eDeliveryTypeRouter: // 2
|
||||||
LogPrint ("Delivery type router");
|
|
||||||
m.hash = i2p::data::IdentHash (fragment);
|
m.hash = i2p::data::IdentHash (fragment);
|
||||||
fragment += 32; // to hash
|
fragment += 32; // to hash
|
||||||
break;
|
break;
|
||||||
@ -81,7 +77,6 @@ namespace tunnel
|
|||||||
// Message ID
|
// Message ID
|
||||||
msgID = bufbe32toh (fragment);
|
msgID = bufbe32toh (fragment);
|
||||||
fragment += 4;
|
fragment += 4;
|
||||||
LogPrint ("Fragmented message ", msgID);
|
|
||||||
isLastFragment = false;
|
isLastFragment = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,12 +87,10 @@ namespace tunnel
|
|||||||
fragment += 4;
|
fragment += 4;
|
||||||
fragmentNum = (flag >> 1) & 0x3F; // 6 bits
|
fragmentNum = (flag >> 1) & 0x3F; // 6 bits
|
||||||
isLastFragment = flag & 0x01;
|
isLastFragment = flag & 0x01;
|
||||||
LogPrint ("Follow on fragment ", fragmentNum, " of message ", msgID, isLastFragment ? " last" : " non-last");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t size = bufbe16toh (fragment);
|
uint16_t size = bufbe16toh (fragment);
|
||||||
fragment += 2;
|
fragment += 2;
|
||||||
LogPrint ("Fragment size=", (int)size);
|
|
||||||
|
|
||||||
msg->offset = fragment - msg->buf;
|
msg->offset = fragment - msg->buf;
|
||||||
msg->len = msg->offset + size;
|
msg->len = msg->offset + size;
|
||||||
@ -131,8 +124,11 @@ namespace tunnel
|
|||||||
HandleFollowOnFragment (msgID, isLastFragment, m);
|
HandleFollowOnFragment (msgID, isLastFragment, m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint ("Message is fragmented, but msgID is not presented");
|
{
|
||||||
|
LogPrint (eLogError, "Message is fragmented, but msgID is not presented");
|
||||||
|
DeleteI2NPMessage (m.data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment += size;
|
fragment += size;
|
||||||
@ -140,7 +136,7 @@ namespace tunnel
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint ("TunnelMessage: zero not found");
|
LogPrint (eLogError, "TunnelMessage: zero not found");
|
||||||
i2p::DeleteI2NPMessage (msg);
|
i2p::DeleteI2NPMessage (msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,7 +169,7 @@ namespace tunnel
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint ("Fragment ", m.nextFragmentNum, " of message ", msgID, "exceeds max I2NP message size. Message dropped");
|
LogPrint (eLogError, "Fragment ", m.nextFragmentNum, " of message ", msgID, "exceeds max I2NP message size. Message dropped");
|
||||||
i2p::DeleteI2NPMessage (msg.data);
|
i2p::DeleteI2NPMessage (msg.data);
|
||||||
m_IncompleteMessages.erase (it);
|
m_IncompleteMessages.erase (it);
|
||||||
}
|
}
|
||||||
@ -181,13 +177,13 @@ namespace tunnel
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint ("Unexpected fragment ", (int)m.nextFragmentNum, " instead ", (int)msg.nextFragmentNum, " of message ", msgID, ". Saved");
|
LogPrint (eLogInfo, "Unexpected fragment ", (int)m.nextFragmentNum, " instead ", (int)msg.nextFragmentNum, " of message ", msgID, ". Saved");
|
||||||
AddOutOfSequenceFragment (msgID, m.nextFragmentNum, isLastFragment, m.data);
|
AddOutOfSequenceFragment (msgID, m.nextFragmentNum, isLastFragment, m.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint ("First fragment of message ", msgID, " not found. Saved");
|
LogPrint (eLogInfo, "First fragment of message ", msgID, " not found. Saved");
|
||||||
AddOutOfSequenceFragment (msgID, m.nextFragmentNum, isLastFragment, m.data);
|
AddOutOfSequenceFragment (msgID, m.nextFragmentNum, isLastFragment, m.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,7 +204,7 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
if (it->second.fragmentNum == msg.nextFragmentNum)
|
if (it->second.fragmentNum == msg.nextFragmentNum)
|
||||||
{
|
{
|
||||||
LogPrint ("Out-of-sequence fragment ", (int)it->second.fragmentNum, " of message ", msgID, " found");
|
LogPrint (eLogInfo, "Out-of-sequence fragment ", (int)it->second.fragmentNum, " of message ", msgID, " found");
|
||||||
auto size = it->second.data->GetLength ();
|
auto size = it->second.data->GetLength ();
|
||||||
memcpy (msg.data->buf + msg.data->len, it->second.data->GetBuffer (), size); // concatenate out-of-sync fragment
|
memcpy (msg.data->buf + msg.data->len, it->second.data->GetBuffer (), size); // concatenate out-of-sync fragment
|
||||||
msg.data->len += size;
|
msg.data->len += size;
|
||||||
@ -228,7 +224,7 @@ namespace tunnel
|
|||||||
|
|
||||||
void TunnelEndpoint::HandleNextMessage (const TunnelMessageBlock& msg)
|
void TunnelEndpoint::HandleNextMessage (const TunnelMessageBlock& msg)
|
||||||
{
|
{
|
||||||
LogPrint ("TunnelMessage: handle fragment of ", msg.data->GetLength ()," bytes. Msg type ", (int)msg.data->GetTypeID ());
|
LogPrint (eLogInfo, "TunnelMessage: handle fragment of ", msg.data->GetLength ()," bytes. Msg type ", (int)msg.data->GetTypeID ());
|
||||||
switch (msg.deliveryType)
|
switch (msg.deliveryType)
|
||||||
{
|
{
|
||||||
case eDeliveryTypeLocal:
|
case eDeliveryTypeLocal:
|
||||||
@ -257,13 +253,16 @@ namespace tunnel
|
|||||||
}
|
}
|
||||||
else // we shouldn't send this message. possible leakage
|
else // we shouldn't send this message. possible leakage
|
||||||
{
|
{
|
||||||
LogPrint ("Message to another router arrived from an inbound tunnel. Dropped");
|
LogPrint (eLogError, "Message to another router arrived from an inbound tunnel. Dropped");
|
||||||
i2p::DeleteI2NPMessage (msg.data);
|
i2p::DeleteI2NPMessage (msg.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogPrint ("TunnelMessage: Unknown delivery type ", (int)msg.deliveryType);
|
{
|
||||||
|
LogPrint (eLogError, "TunnelMessage: Unknown delivery type ", (int)msg.deliveryType);
|
||||||
|
i2p::DeleteI2NPMessage (msg.data);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user