mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01: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,
|
I2NPMessage * CreateDatabaseSearchReply (const i2p::data::IdentHash& ident,
|
||||||
const i2p::data::RouterInfo * floodfill)
|
std::vector<i2p::data::IdentHash> routers)
|
||||||
{
|
{
|
||||||
I2NPMessage * m = NewI2NPShortMessage ();
|
I2NPMessage * m = NewI2NPShortMessage ();
|
||||||
uint8_t * buf = m->GetPayload ();
|
uint8_t * buf = m->GetPayload ();
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
memcpy (buf, ident, 32);
|
memcpy (buf, ident, 32);
|
||||||
len += 32;
|
len += 32;
|
||||||
buf[len] = floodfill ? 1 : 0; // 1 router for now
|
buf[len] = routers.size ();
|
||||||
len++;
|
len++;
|
||||||
if (floodfill)
|
for (auto it: routers)
|
||||||
{
|
{
|
||||||
memcpy (buf + len, floodfill->GetIdentHash (), 32);
|
memcpy (buf + len, it, 32);
|
||||||
len += 32;
|
len += 32;
|
||||||
}
|
}
|
||||||
memcpy (buf + len, i2p::context.GetRouterInfo ().GetIdentHash (), 32);
|
memcpy (buf + len, i2p::context.GetRouterInfo ().GetIdentHash (), 32);
|
||||||
|
|
|
@ -194,7 +194,7 @@ namespace tunnel
|
||||||
I2NPMessage * CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
I2NPMessage * CreateLeaseSetDatabaseLookupMsg (const i2p::data::IdentHash& dest,
|
||||||
const std::set<i2p::data::IdentHash>& excludedFloodfills,
|
const std::set<i2p::data::IdentHash>& excludedFloodfills,
|
||||||
const i2p::tunnel::InboundTunnel * replyTunnel, const uint8_t * replyKey, const uint8_t * replyTag);
|
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::RouterInfo * router = nullptr, uint32_t replyToken = 0);
|
||||||
I2NPMessage * CreateDatabaseStoreMsg (const i2p::data::LeaseSet * leaseSet, 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;
|
I2NPMessage * replyMsg = nullptr;
|
||||||
|
|
||||||
|
auto router = FindRouter (buf);
|
||||||
|
if (router)
|
||||||
{
|
{
|
||||||
auto router = FindRouter (buf);
|
LogPrint ("Requested RouterInfo ", key, " found");
|
||||||
if (router)
|
router->LoadBuffer ();
|
||||||
{
|
if (router->GetBuffer ())
|
||||||
LogPrint ("Requested RouterInfo ", key, " found");
|
replyMsg = CreateDatabaseStoreMsg (router.get ());
|
||||||
router->LoadBuffer ();
|
|
||||||
if (router->GetBuffer ())
|
|
||||||
replyMsg = CreateDatabaseStoreMsg (router.get ());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!replyMsg)
|
if (!replyMsg)
|
||||||
{
|
{
|
||||||
auto leaseSet = FindLeaseSet (buf);
|
auto leaseSet = FindLeaseSet (buf);
|
||||||
|
@ -693,7 +692,14 @@ namespace data
|
||||||
excludedRouters.insert (excluded);
|
excludedRouters.insert (excluded);
|
||||||
excluded += 32;
|
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
|
else
|
||||||
excluded += numExcluded*32; // we don't care about exluded
|
excluded += numExcluded*32; // we don't care about exluded
|
||||||
|
|
Loading…
Reference in a new issue