Skip to content

Commit

Permalink
send floodfill in DatabaseSerachReply
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Jul 25, 2014
1 parent 3961fdc commit 3d669c9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
18 changes: 14 additions & 4 deletions I2NPProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,24 @@ namespace i2p
return m;
}

I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident)
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident,
const i2p::data::RouterInfo * floodfill)
{
I2NPMessage * m = NewI2NPMessage ();
uint8_t * buf = m->GetPayload ();
size_t len = 0;
memcpy (buf, ident, 32);
buf[32] = 0; // TODO:
memcpy (buf + 33, i2p::context.GetRouterInfo ().GetIdentHash (), 32);
m->len += 65;
len += 32;
buf[len] = floodfill ? 1 : 0; // 1 router for now
len++;
if (floodfill)
{
memcpy (buf + len, floodfill->GetIdentHash (), 32);
len += 32;
}
memcpy (buf + len, i2p::context.GetRouterInfo ().GetIdentHash (), 32);
len += 32;
m->len += len;
FillI2NPMessageHeader (m, eI2NPDatabaseSearchReply);
return m;
}
Expand Down
2 changes: 1 addition & 1 deletion I2NPProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace tunnel
I2NPMessage * CreateDatabaseLookupMsg (const uint8_t * key, const uint8_t * from,
uint32_t replyTunnelID, bool exploratory = false,
std::set<i2p::data::IdentHash> * excludedPeers = nullptr, bool encryption = false);
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident);
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, const i2p::data::RouterInfo * floodfill);

I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::RouterInfo * router = nullptr);

Expand Down
5 changes: 4 additions & 1 deletion NetDb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,10 @@ namespace data
replyMsg = CreateDatabaseStoreMsg (router);
}
else
replyMsg = CreateDatabaseSearchReply (buf);
{
std::set<IdentHash> excluded; // empty for now
replyMsg = CreateDatabaseSearchReply (buf, GetClosestFloodfill (buf, excluded));
}
if (replyMsg)
{
if (replyTunnelID)
Expand Down

0 comments on commit 3d669c9

Please sign in to comment.