|
|
@ -13,7 +13,6 @@ |
|
|
|
#include "RouterContext.h" |
|
|
|
#include "RouterContext.h" |
|
|
|
#include "Garlic.h" |
|
|
|
#include "Garlic.h" |
|
|
|
#include "NetDb.h" |
|
|
|
#include "NetDb.h" |
|
|
|
#include "Reseed.h" |
|
|
|
|
|
|
|
#include "util.h" |
|
|
|
#include "util.h" |
|
|
|
|
|
|
|
|
|
|
|
using namespace i2p::transport; |
|
|
|
using namespace i2p::transport; |
|
|
@ -72,13 +71,14 @@ namespace data |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
NetDb netdb; |
|
|
|
NetDb netdb; |
|
|
|
|
|
|
|
|
|
|
|
NetDb::NetDb (): m_IsRunning (false), m_Thread (nullptr) |
|
|
|
NetDb::NetDb (): m_IsRunning (false), m_Thread (nullptr), m_Reseeder (nullptr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
NetDb::~NetDb () |
|
|
|
NetDb::~NetDb () |
|
|
|
{ |
|
|
|
{ |
|
|
|
Stop (); |
|
|
|
Stop (); |
|
|
|
|
|
|
|
delete m_Reseeder; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NetDb::Start () |
|
|
|
void NetDb::Start () |
|
|
@ -86,24 +86,20 @@ namespace data |
|
|
|
Load (m_NetDbPath); |
|
|
|
Load (m_NetDbPath); |
|
|
|
if (m_RouterInfos.size () < 50) // reseed if # of router less than 50
|
|
|
|
if (m_RouterInfos.size () < 50) // reseed if # of router less than 50
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Reseeder reseeder; |
|
|
|
|
|
|
|
reseeder.LoadCertificates (); // we need certificates for SU3 verification
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// try SU3 first
|
|
|
|
// try SU3 first
|
|
|
|
int reseedRetries = 0; |
|
|
|
Reseed (); |
|
|
|
while (m_RouterInfos.size () < 50 && reseedRetries < 10) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
reseeder.ReseedNowSU3(); |
|
|
|
|
|
|
|
reseedRetries++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if still not enough download .dat files
|
|
|
|
// deprecated
|
|
|
|
reseedRetries = 0; |
|
|
|
if (m_Reseeder) |
|
|
|
while (m_RouterInfos.size () < 50 && reseedRetries < 10) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
reseeder.reseedNow(); |
|
|
|
// if still not enough download .dat files
|
|
|
|
reseedRetries++; |
|
|
|
int reseedRetries = 0; |
|
|
|
Load (m_NetDbPath); |
|
|
|
while (m_RouterInfos.size () < 50 && reseedRetries < 10) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_Reseeder->reseedNow(); |
|
|
|
|
|
|
|
reseedRetries++; |
|
|
|
|
|
|
|
Load (m_NetDbPath); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
m_IsRunning = true; |
|
|
|
m_IsRunning = true; |
|
|
@ -314,6 +310,20 @@ namespace data |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void NetDb::Reseed () |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!m_Reseeder) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
m_Reseeder = new Reseeder (); |
|
|
|
|
|
|
|
m_Reseeder->LoadCertificates (); // we need certificates for SU3 verification
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int reseedRetries = 0; |
|
|
|
|
|
|
|
while (reseedRetries < 10 && !m_Reseeder->ReseedNowSU3 ()) |
|
|
|
|
|
|
|
reseedRetries++; |
|
|
|
|
|
|
|
if (reseedRetries >= 10) |
|
|
|
|
|
|
|
LogPrint (eLogWarning, "Failed to reseed after 10 attempts"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void NetDb::Load (const char * directory) |
|
|
|
void NetDb::Load (const char * directory) |
|
|
|
{ |
|
|
|
{ |
|
|
|
boost::filesystem::path p (i2p::util::filesystem::GetDataDir()); |
|
|
|
boost::filesystem::path p (i2p::util::filesystem::GetDataDir()); |
|
|
|