Browse Source

SU3 resseed first

pull/117/head
orignal 10 years ago
parent
commit
6ac846f95d
  1. 17
      NetDb.cpp
  2. 1
      NetDb.h
  3. 5
      Reseed.cpp

17
NetDb.cpp

@ -62,7 +62,7 @@ namespace data @@ -62,7 +62,7 @@ namespace data
#endif
NetDb netdb;
NetDb::NetDb (): m_IsRunning (false), m_ReseedRetries (0), m_Thread (0)
NetDb::NetDb (): m_IsRunning (false), m_Thread (0)
{
}
@ -78,11 +78,22 @@ namespace data @@ -78,11 +78,22 @@ namespace data
void NetDb::Start ()
{
Load (m_NetDbPath);
while (m_RouterInfos.size () < 100 && m_ReseedRetries < 10)
// try SU3 first
int reseedRetries = 0;
while (m_RouterInfos.size () < 100 && reseedRetries < 10)
{
Reseeder reseeder;
reseeder.ReseedNowSU3();
reseedRetries++;
}
// if still not enough download .dat files
reseedRetries = 0;
while (m_RouterInfos.size () < 100 && reseedRetries < 10)
{
Reseeder reseeder;
reseeder.reseedNow();
m_ReseedRetries++;
reseedRetries++;
Load (m_NetDbPath);
}
m_Thread = new std::thread (std::bind (&NetDb::Run, this));

1
NetDb.h

@ -117,7 +117,6 @@ namespace data @@ -117,7 +117,6 @@ namespace data
std::map<IdentHash, RequestedDestination *> m_RequestedDestinations;
bool m_IsRunning;
int m_ReseedRetries;
std::thread * m_Thread;
i2p::util::Queue<I2NPMessage> m_Queue; // of I2NPDatabaseStoreMsg

5
Reseed.cpp

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
#include <sstream>
#include <boost/regex.hpp>
#include <boost/filesystem.hpp>
#include <cryptopp/osrng.h>
#include <cryptopp/zinflate.h>
#include "I2PEndian.h"
#include "Reseed.h"
@ -125,7 +126,9 @@ namespace data @@ -125,7 +126,9 @@ namespace data
int Reseeder::ReseedNowSU3 ()
{
std::string reseedHost = httpReseedHostList[(rand() % httpReseedHostList.size())];
CryptoPP::AutoSeededRandomPool rnd;
auto ind = rnd.GenerateWord32 (0, httpReseedHostList.size() - 1);
std::string reseedHost = httpReseedHostList[ind];
return ReseedFromSU3 (reseedHost);
}

Loading…
Cancel
Save