Browse Source

try to send database store reply directly to IBGW

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

28
libi2pd/NetDb.cpp

@ -824,17 +824,31 @@ 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
{ {
auto pool = i2p::tunnel::tunnels.GetExploratoryPool (); bool direct = true;
auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr; if (!i2p::transport::transports.IsConnected (replyIdent))
if (outbound) {
outbound->SendTunnelDataMsgTo (buf + offset, tunnelID, deliveryStatus); 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 else
LogPrint (eLogWarning, "NetDb: No outbound tunnels for DatabaseStore reply found"); {
// send response through exploratory tunnel
auto pool = i2p::tunnel::tunnels.GetExploratoryPool ();
auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr;
if (outbound)
outbound->SendTunnelDataMsgTo (replyIdent, tunnelID, deliveryStatus);
else
LogPrint (eLogWarning, "NetDb: No outbound tunnels for DatabaseStore reply found");
}
} }
} }
offset += 32; offset += 32;
@ -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