mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-28 18:24:14 +00:00
don't load non-reachable routers
This commit is contained in:
parent
d512c90193
commit
3961fdc2e1
24
NetDb.cpp
24
NetDb.cpp
@ -267,15 +267,25 @@ namespace data
|
|||||||
for (boost::filesystem::directory_iterator it1 (it->path ()); it1 != end; ++it1)
|
for (boost::filesystem::directory_iterator it1 (it->path ()); it1 != end; ++it1)
|
||||||
{
|
{
|
||||||
#if BOOST_VERSION > 10500
|
#if BOOST_VERSION > 10500
|
||||||
RouterInfo * r = new RouterInfo (it1->path().string());
|
const std::string& fullPath = it1->path().string();
|
||||||
#else
|
#else
|
||||||
RouterInfo * r = new RouterInfo(it1->path());
|
const std::string& fullPath = it1->path();
|
||||||
#endif
|
#endif
|
||||||
r->DeleteBuffer ();
|
RouterInfo * r = new RouterInfo(fullPath);
|
||||||
m_RouterInfos[r->GetIdentHash ()] = r;
|
if (!r->IsUnreachable ())
|
||||||
if (r->IsFloodfill ())
|
{
|
||||||
m_Floodfills.push_back (r);
|
r->DeleteBuffer ();
|
||||||
numRouters++;
|
m_RouterInfos[r->GetIdentHash ()] = r;
|
||||||
|
if (r->IsFloodfill ())
|
||||||
|
m_Floodfills.push_back (r);
|
||||||
|
numRouters++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (boost::filesystem::exists (fullPath))
|
||||||
|
boost::filesystem::remove (fullPath);
|
||||||
|
delete r;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,8 +118,10 @@ namespace data
|
|||||||
// read addresses
|
// read addresses
|
||||||
uint8_t numAddresses;
|
uint8_t numAddresses;
|
||||||
s.read ((char *)&numAddresses, sizeof (numAddresses));
|
s.read ((char *)&numAddresses, sizeof (numAddresses));
|
||||||
|
bool introducers = false;
|
||||||
for (int i = 0; i < numAddresses; i++)
|
for (int i = 0; i < numAddresses; i++)
|
||||||
{
|
{
|
||||||
|
bool isValidAddress = true;
|
||||||
Address address;
|
Address address;
|
||||||
s.read ((char *)&address.cost, sizeof (address.cost));
|
s.read ((char *)&address.cost, sizeof (address.cost));
|
||||||
s.read ((char *)&address.date, sizeof (address.date));
|
s.read ((char *)&address.date, sizeof (address.date));
|
||||||
@ -149,7 +151,7 @@ namespace data
|
|||||||
{
|
{
|
||||||
// TODO: we should try to resolve address here
|
// TODO: we should try to resolve address here
|
||||||
LogPrint ("Unexpected address ", value);
|
LogPrint ("Unexpected address ", value);
|
||||||
SetUnreachable (true);
|
isValidAddress = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -169,6 +171,7 @@ namespace data
|
|||||||
else if (key[0] == 'i')
|
else if (key[0] == 'i')
|
||||||
{
|
{
|
||||||
// introducers
|
// introducers
|
||||||
|
introducers = true;
|
||||||
size_t l = strlen(key);
|
size_t l = strlen(key);
|
||||||
unsigned char index = key[l-1] - '0'; // TODO:
|
unsigned char index = key[l-1] - '0'; // TODO:
|
||||||
key[l-1] = 0;
|
key[l-1] = 0;
|
||||||
@ -188,7 +191,8 @@ namespace data
|
|||||||
Base64ToByteStream (value, strlen (value), introducer.iKey, 32);
|
Base64ToByteStream (value, strlen (value), introducer.iKey, 32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_Addresses.push_back(address);
|
if (isValidAddress)
|
||||||
|
m_Addresses.push_back(address);
|
||||||
}
|
}
|
||||||
// read peers
|
// read peers
|
||||||
uint8_t numPeers;
|
uint8_t numPeers;
|
||||||
@ -222,7 +226,7 @@ namespace data
|
|||||||
UpdateIdentHashBase64 ();
|
UpdateIdentHashBase64 ();
|
||||||
UpdateRoutingKey ();
|
UpdateRoutingKey ();
|
||||||
|
|
||||||
if (!m_SupportedTransports)
|
if (!m_SupportedTransports || !m_Addresses.size() || (UsesIntroducer () && !introducers))
|
||||||
SetUnreachable (true);
|
SetUnreachable (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user