mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
Merge pull request #668 from l-n-s/addressbook_configurable
Add addressbook options + improved docs
This commit is contained in:
commit
3b467c19cb
@ -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 @@
|
||||
#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<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
|
||||
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<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 (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<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
|
||||
|
@ -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)
|
||||
|
11
Config.cpp
11
Config.cpp
@ -171,12 +171,20 @@ 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")
|
||||
("trust.family", value<std::string>()->default_value(""), "Router Familiy to trust for first hops")
|
||||
("trust.hidden", value<bool>()->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)
|
||||
;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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…
Reference in New Issue
Block a user