Browse Source

Merge pull request #668 from l-n-s/addressbook_configurable

Add addressbook options + improved docs
pull/669/head
orignal 8 years ago committed by GitHub
parent
commit
3b467c19cb
  1. 23
      AddressBook.cpp
  2. 5
      AddressBook.h
  3. 9
      Config.cpp
  4. 2
      docs/configuration.md
  5. 14
      docs/i2pd.conf
  6. 2
      docs/index.rst

23
AddressBook.cpp

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include <chrono>
#include <condition_variable>
#include <openssl/rand.h>
#include <boost/algorithm/string.hpp>
#include "Base.h"
#include "util.h"
#include "Identity.h"
@ -15,6 +16,7 @@ @@ -15,6 +16,7 @@
#include "NetDb.h"
#include "ClientContext.h"
#include "AddressBook.h"
#include "Config.h"
namespace i2p
{
@ -404,9 +406,21 @@ namespace client @@ -404,9 +406,21 @@ namespace client
m_Subscriptions.push_back (std::make_shared<AddressBookSubscription> (*this, s));
}
LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions urls loaded");
LogPrint (eLogWarning, "Addressbook: subscriptions.txt usage is deprecated, use config file instead");
}
else if (!i2p::config::IsDefault("addressbook.subscriptions"))
{
// using config file items
std::string subscriptionURLs; i2p::config::GetOption("addressbook.subscriptions", subscriptionURLs);
std::vector<std::string> 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<AddressBookSubscription> (*this, subsList[i]));
}
LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions urls loaded");
}
else
LogPrint (eLogWarning, "Addressbook: subscriptions.txt not found in datadir");
}
else
LogPrint (eLogError, "Addressbook: subscriptions already loaded");
@ -511,10 +525,11 @@ namespace client @@ -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<AddressBookSubscription>(*this, DEFAULT_SUBSCRIPTION_ADDRESS);
m_DefaultSubscription = std::make_shared<AddressBookSubscription>(*this, defaultSubURL);
m_IsDownloading = true;
std::thread load_hosts(std::bind (&AddressBookSubscription::CheckUpdates, m_DefaultSubscription));
load_hosts.detach(); // TODO: use join

5
AddressBook.h

@ -18,11 +18,6 @@ namespace i2p @@ -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)

9
Config.cpp

@ -171,6 +171,14 @@ namespace config { @@ -171,6 +171,14 @@ namespace config {
#endif
;
options_description addressbook("AddressBook options");
addressbook.add_options()
("addressbook.defaulturl", value<std::string>()->default_value(
"http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt"
), "AddressBook subscription URL for initial setup")
("addressbook.subscriptions", value<std::string>()->default_value(""),
"AddressBook subscriptions URLs, separated by comma");
options_description trust("Trust options");
trust.add_options()
("trust.enabled", value<bool>()->default_value(false), "enable explicit trust options")
@ -190,6 +198,7 @@ namespace config { @@ -190,6 +198,7 @@ namespace config {
.add(upnp)
.add(precomputation)
.add(reseed)
.add(addressbook)
.add(trust)
;
}

2
docs/configuration.md

@ -75,6 +75,8 @@ All options below still possible in cmdline, but better write it in config file: @@ -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

14
docs/i2pd.conf

@ -92,8 +92,18 @@ ipv6 = false @@ -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

2
docs/index.rst

@ -32,7 +32,9 @@ Contents: @@ -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

Loading…
Cancel
Save