From 0487e730ba18cdbace213f4a957b74ae80be7983 Mon Sep 17 00:00:00 2001 From: Darknet Villain Date: Wed, 23 Nov 2016 07:42:38 -0500 Subject: [PATCH] Add possibility to reseed from HTTPS URL --- Config.cpp | 2 +- Reseed.cpp | 14 +++++++++----- Reseed.h | 2 +- docs/i2pd.conf | 4 +++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Config.cpp b/Config.cpp index fb587e61..d8dd6a27 100644 --- a/Config.cpp +++ b/Config.cpp @@ -163,7 +163,7 @@ namespace config { reseed.add_options() ("reseed.verify", value()->default_value(false), "Verify .su3 signature") ("reseed.floodfill", value()->default_value(""), "Path to router info of floodfill to reseed from") - ("reseed.file", value()->default_value(""), "Path to .su3 file") + ("reseed.file", value()->default_value(""), "Path to local .su3 file or HTTPS URL to reseed from") ("reseed.urls", value()->default_value( "https://reseed.i2p-projekt.de/," "https://i2p.mooo.com/netDb/," diff --git a/Reseed.cpp b/Reseed.cpp index 3ea69eff..adba530b 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -41,19 +41,23 @@ namespace data std::string filename; i2p::config::GetOption("reseed.file", filename); if (filename.length() > 0) // reseed file is specified { + if (filename.length() > 8 && filename.substr(0, 8) == "https://") + { + return ReseedFromSU3 (filename); // reseed from https URL + } else { auto num = ProcessSU3File (filename.c_str ()); if (num > 0) return num; // success LogPrint (eLogWarning, "Can't reseed from ", filename, " . Trying from hosts"); + } } auto ind = rand () % httpsReseedHostList.size (); - std::string& reseedHost = httpsReseedHostList[ind]; - return ReseedFromSU3 (reseedHost); + std::string reseedUrl = httpsReseedHostList[ind] + "i2pseeds.su3"; + return ReseedFromSU3 (reseedUrl); } - int Reseeder::ReseedFromSU3 (const std::string& host) + int Reseeder::ReseedFromSU3 (const std::string& url) { - std::string url = host + "i2pseeds.su3"; - LogPrint (eLogInfo, "Reseed: Downloading SU3 from ", host); + LogPrint (eLogInfo, "Reseed: Downloading SU3 from ", url); std::string su3 = HttpsRequest (url); if (su3.length () > 0) { diff --git a/Reseed.h b/Reseed.h index 560a31d3..de47c0b1 100644 --- a/Reseed.h +++ b/Reseed.h @@ -29,7 +29,7 @@ namespace data void LoadCertificate (const std::string& filename); - int ReseedFromSU3 (const std::string& host); + int ReseedFromSU3 (const std::string& url); int ProcessSU3File (const char * filename); int ProcessSU3Stream (std::istream& s); diff --git a/docs/i2pd.conf b/docs/i2pd.conf index 5e2770f6..0cdd0de8 100644 --- a/docs/i2pd.conf +++ b/docs/i2pd.conf @@ -97,8 +97,10 @@ verify = true ## URLs to request reseed data from, separated by comma ## Default: "mainline" I2P Network reseeds # urls = https://reseed.i2p-projekt.de/,https://i2p.mooo.com/netDb/,https://netdb.i2p2.no/ -## Path to reseed data file (.su3) for manual reseeding +## Path to local reseed data file (.su3) for manual reseeding # file = /path/to/i2pseeds.su3 +## or HTTPS URL to reseed from +# file = https://legit-website.com/i2pseeds.su3 [addressbook] ## AddressBook subscription URL for initial setup