Browse Source

try to send database store reply directly to IBGW

pull/2036/head
orignal 9 months ago
parent
commit
3873e60cbb
  1. 20
      libi2pd/NetDb.cpp

20
libi2pd/NetDb.cpp

@ -824,19 +824,33 @@ namespace data
offset += 4; offset += 4;
if (replyToken != 0xFFFFFFFFU) // if not caught on OBEP or IBGW if (replyToken != 0xFFFFFFFFU) // if not caught on OBEP or IBGW
{ {
IdentHash replyIdent(buf + offset);
auto deliveryStatus = CreateDeliveryStatusMsg (replyToken); auto deliveryStatus = CreateDeliveryStatusMsg (replyToken);
if (!tunnelID) // send response directly if (!tunnelID) // send response directly
transports.SendMessage (buf + offset, deliveryStatus); transports.SendMessage (replyIdent, deliveryStatus);
else else
{ {
bool direct = true;
if (!i2p::transport::transports.IsConnected (replyIdent))
{
auto r = FindRouter (replyIdent);
if (r && !r->IsReachableFrom (i2p::context.GetRouterInfo ()))
direct = false;
}
if (direct) // send response directly to IBGW
transports.SendMessage (replyIdent, i2p::CreateTunnelGatewayMsg (tunnelID, deliveryStatus));
else
{
// send response through exploratory tunnel
auto pool = i2p::tunnel::tunnels.GetExploratoryPool (); auto pool = i2p::tunnel::tunnels.GetExploratoryPool ();
auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr; auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr;
if (outbound) if (outbound)
outbound->SendTunnelDataMsgTo (buf + offset, tunnelID, deliveryStatus); outbound->SendTunnelDataMsgTo (replyIdent, tunnelID, deliveryStatus);
else else
LogPrint (eLogWarning, "NetDb: No outbound tunnels for DatabaseStore reply found"); LogPrint (eLogWarning, "NetDb: No outbound tunnels for DatabaseStore reply found");
} }
} }
}
offset += 32; offset += 32;
} }
// we must send reply back before this check // we must send reply back before this check
@ -1115,7 +1129,7 @@ namespace data
LogPrint(eLogWarning, "NetDb: Encrypted reply requested but no tags provided"); LogPrint(eLogWarning, "NetDb: Encrypted reply requested but no tags provided");
} }
bool direct = true; bool direct = true;
if (!i2p::transport::transports.IsConnected (ident)) if (!i2p::transport::transports.IsConnected (replyIdent))
{ {
auto r = FindRouter (replyIdent); auto r = FindRouter (replyIdent);
if (r && !r->IsReachableFrom (i2p::context.GetRouterInfo ())) if (r && !r->IsReachableFrom (i2p::context.GetRouterInfo ()))

Loading…
Cancel
Save