From 470a6f0ab2ba189e034adfd676b23b82bf8543b8 Mon Sep 17 00:00:00 2001 From: l-n-s Date: Wed, 12 Oct 2016 10:23:43 +0000 Subject: [PATCH] Add addressbook options + improved docs --- AddressBook.cpp | 23 +++++++++++++++++++---- AddressBook.h | 5 ----- Config.cpp | 11 ++++++++++- docs/configuration.md | 2 ++ docs/i2pd.conf | 14 ++++++++++++-- docs/index.rst | 2 ++ 6 files changed, 45 insertions(+), 12 deletions(-) diff --git a/AddressBook.cpp b/AddressBook.cpp index b993f456..db424308 100644 --- a/AddressBook.cpp +++ b/AddressBook.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "Base.h" #include "util.h" #include "Identity.h" @@ -15,6 +16,7 @@ #include "NetDb.h" #include "ClientContext.h" #include "AddressBook.h" +#include "Config.h" namespace i2p { @@ -404,9 +406,21 @@ namespace client m_Subscriptions.push_back (std::make_shared (*this, s)); } LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions urls loaded"); + LogPrint (eLogWarning, "Addressbook: subscriptions.txt usage is deprecated, use config file instead"); } - else - LogPrint (eLogWarning, "Addressbook: subscriptions.txt not found in datadir"); + else if (!i2p::config::IsDefault("addressbook.subscriptions")) + { + // using config file items + std::string subscriptionURLs; i2p::config::GetOption("addressbook.subscriptions", subscriptionURLs); + std::vector subsList; + boost::split(subsList, subscriptionURLs, boost::is_any_of(","), boost::token_compress_on); + + for (size_t i = 0; i < subsList.size (); i++) + { + m_Subscriptions.push_back (std::make_shared (*this, subsList[i])); + } + LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions urls loaded"); + } } else LogPrint (eLogError, "Addressbook: subscriptions already loaded"); @@ -511,10 +525,11 @@ namespace client { if (!m_IsLoaded) { - // download it from http://i2p-projekt.i2p/hosts.txt + // download it from default subscription LogPrint (eLogInfo, "Addressbook: trying to download it from default subscription."); + std::string defaultSubURL; i2p::config::GetOption("addressbook.defaulturl", defaultSubURL); if (!m_DefaultSubscription) - m_DefaultSubscription = std::make_shared(*this, DEFAULT_SUBSCRIPTION_ADDRESS); + m_DefaultSubscription = std::make_shared(*this, defaultSubURL); m_IsDownloading = true; std::thread load_hosts(std::bind (&AddressBookSubscription::CheckUpdates, m_DefaultSubscription)); load_hosts.detach(); // TODO: use join diff --git a/AddressBook.h b/AddressBook.h index 7f559cd0..a1cb3def 100644 --- a/AddressBook.h +++ b/AddressBook.h @@ -18,11 +18,6 @@ namespace i2p { namespace client { -#ifdef MESHNET - const char DEFAULT_SUBSCRIPTION_ADDRESS[] = "http://i42ofzetmgicvui5sshinfckpijix2udewbam4sjo6x5fbukltia.b32.i2p/hosts.txt"; -#else - const char DEFAULT_SUBSCRIPTION_ADDRESS[] = "http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt"; -#endif const int INITIAL_SUBSCRIPTION_UPDATE_TIMEOUT = 3; // in minutes const int INITIAL_SUBSCRIPTION_RETRY_TIMEOUT = 1; // in minutes const int CONTINIOUS_SUBSCRIPTION_UPDATE_TIMEOUT = 720; // in minutes (12 hours) diff --git a/Config.cpp b/Config.cpp index 9e981dc3..f7e591be 100644 --- a/Config.cpp +++ b/Config.cpp @@ -171,12 +171,20 @@ namespace config { #endif ; + options_description addressbook("AddressBook options"); + addressbook.add_options() + ("addressbook.defaulturl", value()->default_value( + "http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt" + ), "AddressBook subscription URL for initial setup") + ("addressbook.subscriptions", value()->default_value(""), + "AddressBook subscriptions URLs, separated by comma"); + options_description trust("Trust options"); trust.add_options() ("trust.enabled", value()->default_value(false), "enable explicit trust options") ("trust.family", value()->default_value(""), "Router Familiy to trust for first hops") ("trust.hidden", value()->default_value(false), "should we hide our router from other routers?"); - + m_OptionsDesc .add(general) .add(limits) @@ -190,6 +198,7 @@ namespace config { .add(upnp) .add(precomputation) .add(reseed) + .add(addressbook) .add(trust) ; } diff --git a/docs/configuration.md b/docs/configuration.md index dc27f78d..0a774ab9 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -75,6 +75,8 @@ All options below still possible in cmdline, but better write it in config file: * --reseed.verify= - Request SU3 signature verification * --reseed.file= - Full path to SU3 file to reseed from * --reseed.urls= - Reseed URLs, separated by comma +* --addressbook.defaulturl= - AddressBook subscription URL for initial setup +* --addressbook.subscriptions= - AddressBook subscriptions URLs, separated by comma * --limits.transittunnels= - Override maximum number of transit tunnels. 2500 by default diff --git a/docs/i2pd.conf b/docs/i2pd.conf index 94287bd0..9ade3663 100644 --- a/docs/i2pd.conf +++ b/docs/i2pd.conf @@ -92,8 +92,18 @@ ipv6 = false # name = I2Pd [reseed] -## Path to reseed .su3 file (if ) -# file = +## 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 +# file = /path/to/i2pseeds.su3 + +[addressbook] +## AddressBook subscription URL for initial setup +## Default: inr.i2p at "mainline" I2P Network +# defaulturl = http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt +## Optional subscriptions URLs, separated by comma +# subscriptions = http://inr.i2p/export/alive-hosts.txt,http://stats.i2p/cgi-bin/newhosts.txt,http://rus.i2p/hosts.txt [http] ## Uncomment and set to 'false' to disable Web Console diff --git a/docs/index.rst b/docs/index.rst index 5507b075..8cfddb24 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -32,7 +32,9 @@ Contents: build_requirements build_notes_unix build_notes_windows + build_notes_cross build_notes_android + build_notes_ios configuration family usage