From 79af7c22d9df07efb63dfec45e80fff9b7bb45f0 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 30 Jan 2015 15:13:09 -0500 Subject: [PATCH] send DatabaseStore reply --- NetDb.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/NetDb.cpp b/NetDb.cpp index 6b0a36d0..29e616db 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -473,7 +473,28 @@ namespace data uint32_t replyToken = bufbe32toh (buf + DATABASE_STORE_REPLY_TOKEN_OFFSET); size_t offset = DATABASE_STORE_HEADER_SIZE; if (replyToken) - offset += 36; + { + auto deliveryStatus = CreateDeliveryStatusMsg (replyToken); + offset += 4; + uint32_t tunnelID = bufbe32toh (buf + offset); + offset += 32; + if (!tunnelID) // send response directly + transports.SendMessage (buf + offset, deliveryStatus); + else + { + auto pool = i2p::tunnel::tunnels.GetExploratoryPool (); + auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr; + if (outbound) + outbound->SendTunnelDataMsg (buf + offset, tunnelID, deliveryStatus); + else + { + LogPrint (eLogError, "No outbound tunnels for DatabaseStore reply found"); + DeleteI2NPMessage (deliveryStatus); + } + } + + // TODO: flood in case of floodfill. replyToken must be set to zero + } if (buf[DATABASE_STORE_TYPE_OFFSET]) // type { LogPrint ("LeaseSet");