Browse Source

Add possibility to reseed from HTTPS URL

pull/718/head
Darknet Villain 8 years ago
parent
commit
0487e730ba
  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 { @@ -163,7 +163,7 @@ namespace config {
reseed.add_options()
("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.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(
"https://reseed.i2p-projekt.de/,"
"https://i2p.mooo.com/netDb/,"

14
Reseed.cpp

@ -41,19 +41,23 @@ namespace data @@ -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)
{

2
Reseed.h

@ -29,7 +29,7 @@ namespace data @@ -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);

4
docs/i2pd.conf

@ -97,8 +97,10 @@ verify = true @@ -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

Loading…
Cancel
Save