mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-23 17:36:37 +02:00
don't use unreachable RI after 1 hour
This commit is contained in:
parent
7995385a19
commit
4c2f403740
3 changed files with 11 additions and 4 deletions
|
@ -259,6 +259,7 @@ namespace data
|
||||||
m_Floodfills.clear ();
|
m_Floodfills.clear ();
|
||||||
|
|
||||||
// load routers now
|
// load routers now
|
||||||
|
uint64_t ts = i2p::util::GetMillisecondsSinceEpoch ();
|
||||||
int numRouters = 0;
|
int numRouters = 0;
|
||||||
boost::filesystem::directory_iterator end;
|
boost::filesystem::directory_iterator end;
|
||||||
for (boost::filesystem::directory_iterator it (p); it != end; ++it)
|
for (boost::filesystem::directory_iterator it (p); it != end; ++it)
|
||||||
|
@ -273,7 +274,7 @@ namespace data
|
||||||
const std::string& fullPath = it1->path();
|
const std::string& fullPath = it1->path();
|
||||||
#endif
|
#endif
|
||||||
RouterInfo * r = new RouterInfo(fullPath);
|
RouterInfo * r = new RouterInfo(fullPath);
|
||||||
if (!r->IsUnreachable ())
|
if (!r->IsUnreachable () && (!r->UsesIntroducer () || ts < r->GetTimestamp () + 3600*1000LL)) // 1 hour
|
||||||
{
|
{
|
||||||
r->DeleteBuffer ();
|
r->DeleteBuffer ();
|
||||||
m_RouterInfos[r->GetIdentHash ()] = r;
|
m_RouterInfos[r->GetIdentHash ()] = r;
|
||||||
|
@ -329,8 +330,10 @@ namespace data
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// RouterInfo expires after 1 hour if uses introducer
|
||||||
|
if ((it.second->UsesIntroducer () && ts > it.second->GetTimestamp () + 3600*1000LL) // 1 hour
|
||||||
// RouterInfo expires in 72 hours if more than 300
|
// RouterInfo expires in 72 hours if more than 300
|
||||||
if (total > 300 && ts > it.second->GetTimestamp () + 3*24*3600*1000LL) // 3 days
|
|| (total > 300 && ts > it.second->GetTimestamp () + 3*24*3600*1000LL)) // 3 days
|
||||||
{
|
{
|
||||||
total--;
|
total--;
|
||||||
it.second->SetUnreachable (true);
|
it.second->SetUnreachable (true);
|
||||||
|
|
|
@ -257,6 +257,9 @@ namespace data
|
||||||
case 'H':
|
case 'H':
|
||||||
m_Caps |= Caps::eHidden;
|
m_Caps |= Caps::eHidden;
|
||||||
break;
|
break;
|
||||||
|
case 'U':
|
||||||
|
m_Caps |= Caps::eUnreachable;
|
||||||
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
cap++;
|
cap++;
|
||||||
|
@ -465,7 +468,7 @@ namespace data
|
||||||
|
|
||||||
bool RouterInfo::UsesIntroducer () const
|
bool RouterInfo::UsesIntroducer () const
|
||||||
{
|
{
|
||||||
return !(m_Caps & Caps::eReachable); // non-reachable
|
return m_Caps & Caps::eUnreachable; // non-reachable
|
||||||
}
|
}
|
||||||
|
|
||||||
const RouterInfo::Address * RouterInfo::GetNTCPAddress (bool v4only) const
|
const RouterInfo::Address * RouterInfo::GetNTCPAddress (bool v4only) const
|
||||||
|
|
|
@ -33,7 +33,8 @@ namespace data
|
||||||
eReachable = 0x04,
|
eReachable = 0x04,
|
||||||
eSSUTesting = 0x08,
|
eSSUTesting = 0x08,
|
||||||
eSSUIntroducer = 0x10,
|
eSSUIntroducer = 0x10,
|
||||||
eHidden = 0x20
|
eHidden = 0x20,
|
||||||
|
eUnreachable = 0x40
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TransportStyle
|
enum TransportStyle
|
||||||
|
|
Loading…
Add table
Reference in a new issue