|
|
|
@ -13,7 +13,6 @@
@@ -13,7 +13,6 @@
|
|
|
|
|
#include "RouterContext.h" |
|
|
|
|
#include "Garlic.h" |
|
|
|
|
#include "NetDb.h" |
|
|
|
|
#include "Reseed.h" |
|
|
|
|
#include "util.h" |
|
|
|
|
|
|
|
|
|
using namespace i2p::transport; |
|
|
|
@ -72,13 +71,14 @@ namespace data
@@ -72,13 +71,14 @@ namespace data
|
|
|
|
|
#endif |
|
|
|
|
NetDb netdb; |
|
|
|
|
|
|
|
|
|
NetDb::NetDb (): m_IsRunning (false), m_Thread (nullptr) |
|
|
|
|
NetDb::NetDb (): m_IsRunning (false), m_Thread (nullptr), m_Reseeder (nullptr) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
NetDb::~NetDb () |
|
|
|
|
{ |
|
|
|
|
Stop (); |
|
|
|
|
delete m_Reseeder; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void NetDb::Start () |
|
|
|
@ -86,26 +86,22 @@ namespace data
@@ -86,26 +86,22 @@ namespace data
|
|
|
|
|
Load (m_NetDbPath); |
|
|
|
|
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
|
|
|
|
|
int reseedRetries = 0; |
|
|
|
|
while (m_RouterInfos.size () < 50 && reseedRetries < 10) |
|
|
|
|
{ |
|
|
|
|
reseeder.ReseedNowSU3(); |
|
|
|
|
reseedRetries++; |
|
|
|
|
} |
|
|
|
|
Reseed (); |
|
|
|
|
|
|
|
|
|
// deprecated
|
|
|
|
|
if (m_Reseeder) |
|
|
|
|
{ |
|
|
|
|
// if still not enough download .dat files
|
|
|
|
|
reseedRetries = 0; |
|
|
|
|
int reseedRetries = 0; |
|
|
|
|
while (m_RouterInfos.size () < 50 && reseedRetries < 10) |
|
|
|
|
{ |
|
|
|
|
reseeder.reseedNow(); |
|
|
|
|
m_Reseeder->reseedNow(); |
|
|
|
|
reseedRetries++; |
|
|
|
|
Load (m_NetDbPath); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
m_IsRunning = true; |
|
|
|
|
m_Thread = new std::thread (std::bind (&NetDb::Run, this)); |
|
|
|
|
} |
|
|
|
@ -314,6 +310,20 @@ namespace data
@@ -314,6 +310,20 @@ namespace data
|
|
|
|
|
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) |
|
|
|
|
{ |
|
|
|
|
boost::filesystem::path p (i2p::util::filesystem::GetDataDir()); |
|
|
|
|