Browse Source

Merge pull request #718 from l-n-s/my_fixes

Add possibility to reseed from HTTPS URL
pull/719/head
orignal 8 years ago committed by GitHub
parent
commit
e4fe18e435
  1. 2
      Config.cpp
  2. 14
      Reseed.cpp
  3. 2
      Reseed.h
  4. 4
      docs/i2pd.conf

2
Config.cpp

@ -163,7 +163,7 @@ namespace config {
reseed.add_options() reseed.add_options()
("reseed.verify", value<bool>()->default_value(false), "Verify .su3 signature") ("reseed.verify", value<bool>()->default_value(false), "Verify .su3 signature")
("reseed.floodfill", value<std::string>()->default_value(""), "Path to router info of floodfill to reseed from") ("reseed.floodfill", value<std::string>()->default_value(""), "Path to router info of floodfill to reseed from")
("reseed.file", value<std::string>()->default_value(""), "Path to .su3 file") ("reseed.file", value<std::string>()->default_value(""), "Path to local .su3 file or HTTPS URL to reseed from")
("reseed.urls", value<std::string>()->default_value( ("reseed.urls", value<std::string>()->default_value(
"https://reseed.i2p-projekt.de/," "https://reseed.i2p-projekt.de/,"
"https://i2p.mooo.com/netDb/," "https://i2p.mooo.com/netDb/,"

14
Reseed.cpp

@ -41,19 +41,23 @@ namespace data
std::string filename; i2p::config::GetOption("reseed.file", filename); std::string filename; i2p::config::GetOption("reseed.file", filename);
if (filename.length() > 0) // reseed file is specified 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 ()); auto num = ProcessSU3File (filename.c_str ());
if (num > 0) return num; // success if (num > 0) return num; // success
LogPrint (eLogWarning, "Can't reseed from ", filename, " . Trying from hosts"); LogPrint (eLogWarning, "Can't reseed from ", filename, " . Trying from hosts");
}
} }
auto ind = rand () % httpsReseedHostList.size (); auto ind = rand () % httpsReseedHostList.size ();
std::string& reseedHost = httpsReseedHostList[ind]; std::string reseedUrl = httpsReseedHostList[ind] + "i2pseeds.su3";
return ReseedFromSU3 (reseedHost); 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 ", url);
LogPrint (eLogInfo, "Reseed: Downloading SU3 from ", host);
std::string su3 = HttpsRequest (url); std::string su3 = HttpsRequest (url);
if (su3.length () > 0) if (su3.length () > 0)
{ {

2
Reseed.h

@ -29,7 +29,7 @@ namespace data
void LoadCertificate (const std::string& filename); void LoadCertificate (const std::string& filename);
int ReseedFromSU3 (const std::string& host); int ReseedFromSU3 (const std::string& url);
int ProcessSU3File (const char * filename); int ProcessSU3File (const char * filename);
int ProcessSU3Stream (std::istream& s); int ProcessSU3Stream (std::istream& s);

4
docs/i2pd.conf

@ -97,8 +97,10 @@ verify = true
## URLs to request reseed data from, separated by comma ## URLs to request reseed data from, separated by comma
## Default: "mainline" I2P Network reseeds ## Default: "mainline" I2P Network reseeds
# urls = https://reseed.i2p-projekt.de/,https://i2p.mooo.com/netDb/,https://netdb.i2p2.no/ # 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 # file = /path/to/i2pseeds.su3
## or HTTPS URL to reseed from
# file = https://legit-website.com/i2pseeds.su3
[addressbook] [addressbook]
## AddressBook subscription URL for initial setup ## AddressBook subscription URL for initial setup

Loading…
Cancel
Save