mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
send garlic cloves directly if garlic was received derectly
This commit is contained in:
parent
2be1c10522
commit
8cb3e3418a
37
Garlic.cpp
37
Garlic.cpp
@ -7,6 +7,7 @@
|
|||||||
#include "I2NPProtocol.h"
|
#include "I2NPProtocol.h"
|
||||||
#include "Tunnel.h"
|
#include "Tunnel.h"
|
||||||
#include "TunnelPool.h"
|
#include "TunnelPool.h"
|
||||||
|
#include "Transports.h"
|
||||||
#include "Timestamp.h"
|
#include "Timestamp.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Garlic.h"
|
#include "Garlic.h"
|
||||||
@ -514,22 +515,34 @@ namespace garlic
|
|||||||
buf += 32;
|
buf += 32;
|
||||||
uint32_t gwTunnel = bufbe32toh (buf);
|
uint32_t gwTunnel = bufbe32toh (buf);
|
||||||
buf += 4;
|
buf += 4;
|
||||||
std::shared_ptr<i2p::tunnel::OutboundTunnel> tunnel;
|
auto msg = CreateI2NPMessage (buf, GetI2NPMessageLength (buf), from);
|
||||||
if (from && from->GetTunnelPool ())
|
if (from) // received through an inbound tunnel
|
||||||
tunnel = from->GetTunnelPool ()->GetNextOutboundTunnel ();
|
{
|
||||||
if (tunnel) // we have send it through an outbound tunnel
|
std::shared_ptr<i2p::tunnel::OutboundTunnel> tunnel;
|
||||||
{
|
if (from->GetTunnelPool ())
|
||||||
auto msg = CreateI2NPMessage (buf, GetI2NPMessageLength (buf), from);
|
tunnel = from->GetTunnelPool ()->GetNextOutboundTunnel ();
|
||||||
tunnel->SendTunnelDataMsg (gwHash, gwTunnel, msg);
|
else
|
||||||
}
|
LogPrint (eLogError, "Garlic: Tunnel pool is not set for inbound tunnel");
|
||||||
else
|
if (tunnel) // we have send it through an outbound tunnel
|
||||||
LogPrint (eLogWarning, "Garlic: No outbound tunnels available for garlic clove");
|
tunnel->SendTunnelDataMsg (gwHash, gwTunnel, msg);
|
||||||
|
else
|
||||||
|
LogPrint (eLogWarning, "Garlic: No outbound tunnels available for garlic clove");
|
||||||
|
}
|
||||||
|
else // received directly
|
||||||
|
i2p::transport::transports.SendMessage (gwHash, i2p::CreateTunnelGatewayMsg (gwTunnel, msg)); // send directly
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eGarlicDeliveryTypeRouter:
|
case eGarlicDeliveryTypeRouter:
|
||||||
LogPrint (eLogWarning, "Garlic: type router not supported");
|
{
|
||||||
|
uint8_t * ident = buf;
|
||||||
buf += 32;
|
buf += 32;
|
||||||
break;
|
if (!from) // received directly
|
||||||
|
i2p::transport::transports.SendMessage (ident,
|
||||||
|
CreateI2NPMessage (buf, GetI2NPMessageLength (buf)));
|
||||||
|
else
|
||||||
|
LogPrint (eLogWarning, "Garlic: type router for inbound tunnels not supported");
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
LogPrint (eLogWarning, "Garlic: unknown delivery type ", (int)deliveryType);
|
LogPrint (eLogWarning, "Garlic: unknown delivery type ", (int)deliveryType);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user