From a26c5f85c37898890ea3003e9d649df51e19472d Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 4 Jan 2016 19:56:46 -0500 Subject: [PATCH] ignore LeaseSets coming from transit tunnels --- I2NPProtocol.cpp | 6 ++++++ I2NPProtocol.h | 3 ++- Tunnel.cpp | 2 +- TunnelEndpoint.cpp | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/I2NPProtocol.cpp b/I2NPProtocol.cpp index cfa1bd15..698475fe 100644 --- a/I2NPProtocol.cpp +++ b/I2NPProtocol.cpp @@ -268,6 +268,12 @@ namespace i2p m->FillI2NPMessageHeader (eI2NPDatabaseStore); return m; } + + bool IsRouterInfoMsg (std::shared_ptr msg) + { + if (!msg || msg->GetTypeID () != eI2NPDatabaseStore) return false; + return !msg->GetPayload ()[DATABASE_STORE_TYPE_OFFSET]; // 0- RouterInfo + } bool HandleBuildRequestRecords (int num, uint8_t * records, uint8_t * clearText) { diff --git a/I2NPProtocol.h b/I2NPProtocol.h index 340aec7f..e6f20558 100644 --- a/I2NPProtocol.h +++ b/I2NPProtocol.h @@ -213,7 +213,8 @@ namespace tunnel std::shared_ptr CreateDatabaseStoreMsg (std::shared_ptr router = nullptr, uint32_t replyToken = 0); std::shared_ptr CreateDatabaseStoreMsg (std::shared_ptr leaseSet, uint32_t replyToken = 0); - + bool IsRouterInfoMsg (std::shared_ptr msg); + bool HandleBuildRequestRecords (int num, uint8_t * records, uint8_t * clearText); void HandleVariableTunnelBuildMsg (uint32_t replyMsgID, uint8_t * buf, size_t len); void HandleVariableTunnelBuildReplyMsg (uint32_t replyMsgID, uint8_t * buf, size_t len); diff --git a/Tunnel.cpp b/Tunnel.cpp index c7d6573e..7a91adca 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -486,7 +486,7 @@ namespace tunnel auto typeID = msg->GetTypeID (); LogPrint (eLogDebug, "TunnelGateway of ", (int)len, " bytes for tunnel ", tunnel->GetTunnelID (), ". Msg type ", (int)typeID); - if (typeID == eI2NPDatabaseStore || typeID == eI2NPDatabaseSearchReply) + if (IsRouterInfoMsg (msg) || typeID == eI2NPDatabaseSearchReply) // transit DatabaseStore my contain new/updated RI // or DatabaseSearchReply with new routers i2p::data::netdb.PostI2NPMsg (msg); diff --git a/TunnelEndpoint.cpp b/TunnelEndpoint.cpp index 73530557..271c115d 100644 --- a/TunnelEndpoint.cpp +++ b/TunnelEndpoint.cpp @@ -248,7 +248,7 @@ namespace tunnel LogPrint (eLogError, "TunnelMessage: Unknown delivery type ", (int)msg.deliveryType); }; // catch RI or reply with new list of routers - if ((typeID == eI2NPDatabaseStore || typeID == eI2NPDatabaseSearchReply) && + if ((IsRouterInfoMsg (msg.data) || typeID == eI2NPDatabaseSearchReply) && !m_IsInbound && msg.deliveryType != eDeliveryTypeLocal) i2p::data::netdb.PostI2NPMsg (msg.data); }