|
|
@ -225,36 +225,32 @@ namespace tunnel |
|
|
|
|
|
|
|
|
|
|
|
void TunnelEndpoint::HandleNextMessage (const TunnelMessageBlock& msg) |
|
|
|
void TunnelEndpoint::HandleNextMessage (const TunnelMessageBlock& msg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint (eLogInfo, "TunnelMessage: handle fragment of ", msg.data->GetLength ()," bytes. Msg type ", (int)msg.data->GetTypeID ()); |
|
|
|
auto typeID = msg.data->GetTypeID (); |
|
|
|
|
|
|
|
LogPrint (eLogInfo, "TunnelMessage: handle fragment of ", msg.data->GetLength ()," bytes. Msg type ", (int)typeID); |
|
|
|
switch (msg.deliveryType) |
|
|
|
switch (msg.deliveryType) |
|
|
|
{ |
|
|
|
{ |
|
|
|
case eDeliveryTypeLocal: |
|
|
|
case eDeliveryTypeLocal: |
|
|
|
i2p::HandleI2NPMessage (msg.data); |
|
|
|
i2p::HandleI2NPMessage (msg.data); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case eDeliveryTypeTunnel: |
|
|
|
case eDeliveryTypeTunnel: |
|
|
|
|
|
|
|
if (!m_IsInbound) // outbound transit tunnel
|
|
|
|
i2p::transport::transports.SendMessage (msg.hash, i2p::CreateTunnelGatewayMsg (msg.tunnelID, msg.data)); |
|
|
|
i2p::transport::transports.SendMessage (msg.hash, i2p::CreateTunnelGatewayMsg (msg.tunnelID, msg.data)); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
LogPrint (eLogError, "Delivery type tunnel arrived from an inbound tunnel. Dropped"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case eDeliveryTypeRouter: |
|
|
|
case eDeliveryTypeRouter: |
|
|
|
if (msg.hash == i2p::context.GetRouterInfo ().GetIdentHash ()) // check if message is sent to us
|
|
|
|
|
|
|
|
i2p::HandleI2NPMessage (msg.data); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// to somebody else
|
|
|
|
|
|
|
|
if (!m_IsInbound) // outbound transit tunnel
|
|
|
|
if (!m_IsInbound) // outbound transit tunnel
|
|
|
|
{ |
|
|
|
|
|
|
|
/* auto typeID = msg.data->GetTypeID ();
|
|
|
|
|
|
|
|
if (typeID == eI2NPDatabaseStore || typeID == eI2NPDatabaseSearchReply ) |
|
|
|
|
|
|
|
// catch RI or reply with new list of routers
|
|
|
|
|
|
|
|
i2p::data::netdb.PostI2NPMsg (msg.data);*/ |
|
|
|
|
|
|
|
i2p::transport::transports.SendMessage (msg.hash, msg.data); |
|
|
|
i2p::transport::transports.SendMessage (msg.hash, msg.data); |
|
|
|
} |
|
|
|
|
|
|
|
else // we shouldn't send this message. possible leakage
|
|
|
|
else // we shouldn't send this message. possible leakage
|
|
|
|
LogPrint (eLogError, "Message to another router arrived from an inbound tunnel. Dropped"); |
|
|
|
LogPrint (eLogError, "Delivery type router arrived from an inbound tunnel. Dropped"); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
LogPrint (eLogError, "TunnelMessage: Unknown delivery type ", (int)msg.deliveryType); |
|
|
|
LogPrint (eLogError, "TunnelMessage: Unknown delivery type ", (int)msg.deliveryType); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
// catch RI or reply with new list of routers
|
|
|
|
|
|
|
|
if ((typeID == eI2NPDatabaseStore || typeID == eI2NPDatabaseSearchReply) && |
|
|
|
|
|
|
|
!m_IsInbound && msg.deliveryType != eDeliveryTypeLocal) |
|
|
|
|
|
|
|
i2p::data::netdb.PostI2NPMsg (msg.data); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|