mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
send 3 closest floodfills
This commit is contained in:
parent
b46c3036d8
commit
8ad9f2681c
@ -184,18 +184,18 @@ namespace i2p
|
||||
|
||||
|
||||
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident,
|
||||
const i2p::data::RouterInfo * floodfill)
|
||||
std::vector<i2p::data::IdentHash> routers)
|
||||
{
|
||||
I2NPMessage * m = NewI2NPShortMessage ();
|
||||
uint8_t * buf = m->GetPayload ();
|
||||
size_t len = 0;
|
||||
memcpy (buf, ident, 32);
|
||||
len += 32;
|
||||
buf[len] = floodfill ? 1 : 0; // 1 router for now
|
||||
buf[len] = routers.size ();
|
||||
len++;
|
||||
if (floodfill)
|
||||
for (auto it: routers)
|
||||
{
|
||||
memcpy (buf + len, floodfill->GetIdentHash (), 32);
|
||||
memcpy (buf + len, it, 32);
|
||||
len += 32;
|
||||
}
|
||||
memcpy (buf + len, i2p::context.GetRouterInfo ().GetIdentHash (), 32);
|
||||
|
@ -194,7 +194,7 @@ namespace tunnel
|
||||
I2NPMessage * CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
||||
const std::set<i2p::data::IdentHash>& excludedFloodfills,
|
||||
const i2p::tunnel::InboundTunnel * replyTunnel, const uint8_t * replyKey, const uint8_t * replyTag);
|
||||
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, const i2p::data::RouterInfo * floodfill);
|
||||
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident, std::vector<i2p::data::IdentHash> routers);
|
||||
|
||||
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::RouterInfo * router = nullptr, uint32_t replyToken = 0);
|
||||
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::LeaseSet * leaseSet, uint32_t replyToken = 0);
|
||||
|
24
NetDb.cpp
24
NetDb.cpp
@ -664,16 +664,15 @@ namespace data
|
||||
|
||||
I2NPMessage * replyMsg = nullptr;
|
||||
|
||||
auto router = FindRouter (buf);
|
||||
if (router)
|
||||
{
|
||||
auto router = FindRouter (buf);
|
||||
if (router)
|
||||
{
|
||||
LogPrint ("Requested RouterInfo ", key, " found");
|
||||
router->LoadBuffer ();
|
||||
if (router->GetBuffer ())
|
||||
replyMsg = CreateDatabaseStoreMsg (router.get ());
|
||||
}
|
||||
LogPrint ("Requested RouterInfo ", key, " found");
|
||||
router->LoadBuffer ();
|
||||
if (router->GetBuffer ())
|
||||
replyMsg = CreateDatabaseStoreMsg (router.get ());
|
||||
}
|
||||
|
||||
if (!replyMsg)
|
||||
{
|
||||
auto leaseSet = FindLeaseSet (buf);
|
||||
@ -693,7 +692,14 @@ namespace data
|
||||
excludedRouters.insert (excluded);
|
||||
excluded += 32;
|
||||
}
|
||||
replyMsg = CreateDatabaseSearchReply (buf, GetClosestFloodfill (buf, excludedRouters).get ());
|
||||
std::vector<IdentHash> routers;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
auto floodfill = GetClosestFloodfill (buf, excludedRouters);
|
||||
if (floodfill)
|
||||
routers.push_back (floodfill->GetIdentHash ());
|
||||
}
|
||||
replyMsg = CreateDatabaseSearchReply (buf, routers);
|
||||
}
|
||||
else
|
||||
excluded += numExcluded*32; // we don't care about exluded
|
||||
|
Loading…
Reference in New Issue
Block a user