mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 04:04:16 +00:00
drop messages to other router coming down an inbound tunnel
This commit is contained in:
parent
b02c777390
commit
4de9ed80af
@ -67,7 +67,8 @@ namespace tunnel
|
|||||||
TransitTunnelEndpoint (uint32_t receiveTunnelID,
|
TransitTunnelEndpoint (uint32_t receiveTunnelID,
|
||||||
const uint8_t * nextIdent, uint32_t nextTunnelID,
|
const uint8_t * nextIdent, uint32_t nextTunnelID,
|
||||||
const uint8_t * layerKey,const uint8_t * ivKey):
|
const uint8_t * layerKey,const uint8_t * ivKey):
|
||||||
TransitTunnel (receiveTunnelID, nextIdent, nextTunnelID, layerKey, ivKey) {};
|
TransitTunnel (receiveTunnelID, nextIdent, nextTunnelID, layerKey, ivKey),
|
||||||
|
m_Endpoint (false) {}; // transit endpoint is always outbound
|
||||||
|
|
||||||
void HandleTunnelDataMsg (i2p::I2NPMessage * tunnelMsg);
|
void HandleTunnelDataMsg (i2p::I2NPMessage * tunnelMsg);
|
||||||
size_t GetNumTransmittedBytes () const { return m_Endpoint.GetNumReceivedBytes (); }
|
size_t GetNumTransmittedBytes () const { return m_Endpoint.GetNumReceivedBytes (); }
|
||||||
|
2
Tunnel.h
2
Tunnel.h
@ -81,7 +81,7 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
InboundTunnel (TunnelConfig * config): Tunnel (config) {};
|
InboundTunnel (TunnelConfig * config): Tunnel (config), m_Endpoint (true) {};
|
||||||
void HandleTunnelDataMsg (I2NPMessage * msg);
|
void HandleTunnelDataMsg (I2NPMessage * msg);
|
||||||
size_t GetNumReceivedBytes () const { return m_Endpoint.GetNumReceivedBytes (); };
|
size_t GetNumReceivedBytes () const { return m_Endpoint.GetNumReceivedBytes (); };
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include "I2PEndian.h"
|
#include "I2PEndian.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
|
#include "NetDb.h"
|
||||||
#include "I2NPProtocol.h"
|
#include "I2NPProtocol.h"
|
||||||
#include "Transports.h"
|
#include "Transports.h"
|
||||||
|
#include "RouterContext.h"
|
||||||
#include "TunnelEndpoint.h"
|
#include "TunnelEndpoint.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
@ -194,7 +196,28 @@ namespace tunnel
|
|||||||
i2p::transports.SendMessage (msg.hash, i2p::CreateTunnelGatewayMsg (msg.tunnelID, msg.data));
|
i2p::transports.SendMessage (msg.hash, i2p::CreateTunnelGatewayMsg (msg.tunnelID, msg.data));
|
||||||
break;
|
break;
|
||||||
case eDeliveryTypeRouter:
|
case eDeliveryTypeRouter:
|
||||||
i2p::transports.SendMessage (msg.hash, msg.data);
|
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 (msg.data->GetHeader()->typeID == eI2NPDatabaseStore)
|
||||||
|
{
|
||||||
|
// catch RI
|
||||||
|
auto ds = NewI2NPMessage ();
|
||||||
|
*ds = *(msg.data);
|
||||||
|
i2p::data::netdb.PostI2NPMsg (ds);
|
||||||
|
}
|
||||||
|
i2p::transports.SendMessage (msg.hash, msg.data);
|
||||||
|
}
|
||||||
|
else // we shouldn't send this message. possible leakage
|
||||||
|
{
|
||||||
|
LogPrint ("Message to another router arrived from an inbound tunnel. Dropped");
|
||||||
|
i2p::DeleteI2NPMessage (msg.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LogPrint ("TunnelMessage: Unknown delivery type ", (int)msg.deliveryType);
|
LogPrint ("TunnelMessage: Unknown delivery type ", (int)msg.deliveryType);
|
||||||
|
@ -20,7 +20,7 @@ namespace tunnel
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TunnelEndpoint (): m_NumReceivedBytes (0) {};
|
TunnelEndpoint (bool isInbound): m_IsInbound (isInbound), m_NumReceivedBytes (0) {};
|
||||||
~TunnelEndpoint ();
|
~TunnelEndpoint ();
|
||||||
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
|
size_t GetNumReceivedBytes () const { return m_NumReceivedBytes; };
|
||||||
|
|
||||||
@ -34,6 +34,7 @@ namespace tunnel
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
std::map<uint32_t, TunnelMessageBlockEx> m_IncompleteMessages;
|
std::map<uint32_t, TunnelMessageBlockEx> m_IncompleteMessages;
|
||||||
|
bool m_IsInbound;
|
||||||
size_t m_NumReceivedBytes;
|
size_t m_NumReceivedBytes;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user