mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 11:04:00 +01:00
some cleanup
This commit is contained in:
parent
912146b1c9
commit
717940d969
67
NetDb.cpp
67
NetDb.cpp
|
@ -29,7 +29,6 @@ namespace data
|
||||||
replyTunnel->GetNextIdentHash (), replyTunnel->GetNextTunnelID (), m_IsExploratory,
|
replyTunnel->GetNextIdentHash (), replyTunnel->GetNextTunnelID (), m_IsExploratory,
|
||||||
&m_ExcludedPeers);
|
&m_ExcludedPeers);
|
||||||
m_ExcludedPeers.insert (router->GetIdentHash ());
|
m_ExcludedPeers.insert (router->GetIdentHash ());
|
||||||
m_LastRouter = router;
|
|
||||||
m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
|
m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +38,6 @@ namespace data
|
||||||
I2NPMessage * msg = i2p::CreateRouterInfoDatabaseLookupMsg (m_Destination,
|
I2NPMessage * msg = i2p::CreateRouterInfoDatabaseLookupMsg (m_Destination,
|
||||||
i2p::context.GetRouterInfo ().GetIdentHash () , 0, false, &m_ExcludedPeers);
|
i2p::context.GetRouterInfo ().GetIdentHash () , 0, false, &m_ExcludedPeers);
|
||||||
m_ExcludedPeers.insert (floodfill);
|
m_ExcludedPeers.insert (floodfill);
|
||||||
m_LastRouter = nullptr;
|
|
||||||
m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
|
m_CreationTime = i2p::util::GetSecondsSinceEpoch ();
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@ -509,50 +507,6 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < num; i++)
|
|
||||||
{
|
|
||||||
uint8_t * router = buf + 33 + i*32;
|
|
||||||
char peerHash[48];
|
|
||||||
int l1 = i2p::data::ByteStreamToBase64 (router, 32, peerHash, 48);
|
|
||||||
peerHash[l1] = 0;
|
|
||||||
LogPrint (i,": ", peerHash);
|
|
||||||
|
|
||||||
if (dest->IsExploratory ())
|
|
||||||
{
|
|
||||||
auto r = FindRouter (router);
|
|
||||||
if (!r || i2p::util::GetMillisecondsSinceEpoch () > r->GetTimestamp () + 3600*1000LL)
|
|
||||||
{
|
|
||||||
// router with ident not found or too old (1 hour)
|
|
||||||
LogPrint ("Found new/outdated router. Requesting RouterInfo ...");
|
|
||||||
if (outbound && inbound && dest->GetLastRouter ())
|
|
||||||
{
|
|
||||||
RequestedDestination * d1 = CreateRequestedDestination (router, false);
|
|
||||||
auto msg = d1->CreateRequestMessage (dest->GetLastRouter (), inbound);
|
|
||||||
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
|
||||||
{
|
|
||||||
i2p::tunnel::eDeliveryTypeRouter,
|
|
||||||
dest->GetLastRouter ()->GetIdentHash (), 0, msg
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
RequestDestination (router);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
LogPrint ("Bayan");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto r = FindRouter (router);
|
|
||||||
// do we have that floodfill router in our database?
|
|
||||||
if (!r)
|
|
||||||
{
|
|
||||||
// request router
|
|
||||||
LogPrint ("Found new floodfill. Request it");
|
|
||||||
RequestDestination (router);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outbound && msgs.size () > 0)
|
if (outbound && msgs.size () > 0)
|
||||||
outbound->SendTunnelDataMsg (msgs);
|
outbound->SendTunnelDataMsg (msgs);
|
||||||
if (deleteDest)
|
if (deleteDest)
|
||||||
|
@ -570,19 +524,28 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
LogPrint ("Requested destination for ", key, " not found");
|
LogPrint ("Requested destination for ", key, " not found");
|
||||||
// it might contain new routers
|
|
||||||
|
// try responses
|
||||||
for (int i = 0; i < num; i++)
|
for (int i = 0; i < num; i++)
|
||||||
{
|
{
|
||||||
IdentHash router (buf + 33 + i*32);
|
uint8_t * router = buf + 33 + i*32;
|
||||||
if (!FindRouter (router))
|
char peerHash[48];
|
||||||
|
int l1 = i2p::data::ByteStreamToBase64 (router, 32, peerHash, 48);
|
||||||
|
peerHash[l1] = 0;
|
||||||
|
LogPrint (i,": ", peerHash);
|
||||||
|
|
||||||
|
auto r = FindRouter (router);
|
||||||
|
if (!r || i2p::util::GetMillisecondsSinceEpoch () > r->GetTimestamp () + 3600*1000LL)
|
||||||
{
|
{
|
||||||
LogPrint ("New router ", router.ToBase64 (), " found. Request it");
|
// router with ident not found or too old (1 hour)
|
||||||
|
LogPrint ("Found new/outdated router. Requesting RouterInfo ...");
|
||||||
RequestDestination (router);
|
RequestDestination (router);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
LogPrint ("Bayan");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
i2p::DeleteI2NPMessage (msg);
|
i2p::DeleteI2NPMessage (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
NetDb.h
2
NetDb.h
|
@ -31,7 +31,6 @@ namespace data
|
||||||
int GetNumExcludedPeers () const { return m_ExcludedPeers.size (); };
|
int GetNumExcludedPeers () const { return m_ExcludedPeers.size (); };
|
||||||
const std::set<IdentHash>& GetExcludedPeers () { return m_ExcludedPeers; };
|
const std::set<IdentHash>& GetExcludedPeers () { return m_ExcludedPeers; };
|
||||||
void ClearExcludedPeers ();
|
void ClearExcludedPeers ();
|
||||||
std::shared_ptr<const RouterInfo> GetLastRouter () const { return m_LastRouter; };
|
|
||||||
bool IsExploratory () const { return m_IsExploratory; };
|
bool IsExploratory () const { return m_IsExploratory; };
|
||||||
bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); };
|
bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); };
|
||||||
uint64_t GetCreationTime () const { return m_CreationTime; };
|
uint64_t GetCreationTime () const { return m_CreationTime; };
|
||||||
|
@ -43,7 +42,6 @@ namespace data
|
||||||
IdentHash m_Destination;
|
IdentHash m_Destination;
|
||||||
bool m_IsExploratory;
|
bool m_IsExploratory;
|
||||||
std::set<IdentHash> m_ExcludedPeers;
|
std::set<IdentHash> m_ExcludedPeers;
|
||||||
std::shared_ptr<const RouterInfo> m_LastRouter;
|
|
||||||
uint64_t m_CreationTime;
|
uint64_t m_CreationTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue