From 8e795cc2aa8404afa9f35324e1750e3110bb9a34 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 20 Feb 2015 15:11:00 -0500 Subject: [PATCH] include https hosts to reseeder's list --- Reseed.cpp | 14 ++++++++------ Reseed.h | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Reseed.cpp b/Reseed.cpp index ea26f3fc..540d0ebc 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -40,10 +40,11 @@ namespace data "https://netdb.i2p2.no/", // Only SU3 (v2) support "https://reseed.i2p-projekt.de/", // Only HTTPS "https://cowpuncher.drollette.com/netdb/", // Only HTTPS and SU3 (v2) support -- will move to a new location - "https://i2p.mooo.com/netDb/", + // following hosts are fine but don't support AES256 + /*"https://i2p.mooo.com/netDb/", "https://link.mx24.eu/", // Only HTTPS and SU3 (v2) support "https://i2pseed.zarrenspry.info/", // Only HTTPS and SU3 (v2) support - "https://ieb9oopo.mooo.com/" // Only HTTPS and SU3 (v2) support + "https://ieb9oopo.mooo.com/" // Only HTTPS and SU3 (v2) support*/ }; Reseeder::Reseeder() @@ -119,16 +120,17 @@ namespace data int Reseeder::ReseedNowSU3 () { CryptoPP::AutoSeededRandomPool rnd; - auto ind = rnd.GenerateWord32 (0, httpReseedHostList.size() - 1); - std::string reseedHost = httpReseedHostList[ind]; + auto ind = rnd.GenerateWord32 (0, httpReseedHostList.size() - 1 + httpsReseedHostList.size () - 1); + std::string reseedHost = (ind < httpReseedHostList.size()) ? httpReseedHostList[ind] : + httpsReseedHostList[ind - httpReseedHostList.size()]; return ReseedFromSU3 (reseedHost); } - int Reseeder::ReseedFromSU3 (const std::string& host) + int Reseeder::ReseedFromSU3 (const std::string& host, bool https) { std::string url = host + "i2pseeds.su3"; LogPrint (eLogInfo, "Dowloading SU3 from ", host); - std::string su3 = i2p::util::http::httpRequest (url); + std::string su3 = https ? HttpsRequest (url) : i2p::util::http::httpRequest (url); if (su3.length () > 0) { std::stringstream s(su3); diff --git a/Reseed.h b/Reseed.h index 07ef9dea..d43227a5 100644 --- a/Reseed.h +++ b/Reseed.h @@ -28,20 +28,20 @@ namespace data int ReseedNowSU3 (); void LoadCertificates (); - - std::string HttpsRequest (const std::string& address); // TODO: move to private section private: void LoadCertificate (const std::string& filename); std::string LoadCertificate (CryptoPP::ByteQueue& queue); // returns issuer's name - int ReseedFromSU3 (const std::string& host); + int ReseedFromSU3 (const std::string& host, bool https = false); int ProcessSU3File (const char * filename); int ProcessSU3Stream (std::istream& s); bool FindZipDataDescriptor (std::istream& s); + std::string HttpsRequest (const std::string& address); + private: std::map m_SigningKeys;