mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-24 20:57:37 +01:00
Add addressbook.subscriptions option + delete default subscription constant + improved docs
This commit is contained in:
parent
b1f8f9830b
commit
69f9e0a64f
6 changed files with 37 additions and 23 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
#include "NetDb.h"
|
#include "NetDb.h"
|
||||||
#include "ClientContext.h"
|
#include "ClientContext.h"
|
||||||
#include "AddressBook.h"
|
#include "AddressBook.h"
|
||||||
|
#include "Config.h"
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
|
@ -205,7 +207,7 @@ namespace client
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
AddressBook::AddressBook (): m_Storage(nullptr), m_IsLoaded (false), m_IsDownloading (false),
|
AddressBook::AddressBook (): m_Storage(nullptr), m_IsLoaded (false), m_IsDownloading (false),
|
||||||
m_DefaultSubscription (nullptr), m_SubscriptionsUpdateTimer (nullptr)
|
m_SubscriptionsUpdateTimer (nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +261,6 @@ namespace client
|
||||||
delete m_Storage;
|
delete m_Storage;
|
||||||
m_Storage = nullptr;
|
m_Storage = nullptr;
|
||||||
}
|
}
|
||||||
m_DefaultSubscription = nullptr;
|
|
||||||
m_Subscriptions.clear ();
|
m_Subscriptions.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,9 +405,21 @@ namespace client
|
||||||
m_Subscriptions.push_back (std::make_shared<AddressBookSubscription> (*this, s));
|
m_Subscriptions.push_back (std::make_shared<AddressBookSubscription> (*this, s));
|
||||||
}
|
}
|
||||||
LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions urls loaded");
|
LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions urls loaded");
|
||||||
|
LogPrint (eLogWarning, "Addressbook: subscriptions.txt usage is deprecated, use config file instead");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "Addressbook: subscriptions.txt not found in datadir");
|
{
|
||||||
|
// 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
|
else
|
||||||
LogPrint (eLogError, "Addressbook: subscriptions already loaded");
|
LogPrint (eLogError, "Addressbook: subscriptions already loaded");
|
||||||
|
@ -460,7 +473,6 @@ namespace client
|
||||||
int nextUpdateTimeout = CONTINIOUS_SUBSCRIPTION_RETRY_TIMEOUT;
|
int nextUpdateTimeout = CONTINIOUS_SUBSCRIPTION_RETRY_TIMEOUT;
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
if (m_DefaultSubscription) m_DefaultSubscription = nullptr;
|
|
||||||
if (m_IsLoaded)
|
if (m_IsLoaded)
|
||||||
nextUpdateTimeout = CONTINIOUS_SUBSCRIPTION_UPDATE_TIMEOUT;
|
nextUpdateTimeout = CONTINIOUS_SUBSCRIPTION_UPDATE_TIMEOUT;
|
||||||
else
|
else
|
||||||
|
@ -509,17 +521,7 @@ namespace client
|
||||||
}
|
}
|
||||||
if (!m_IsDownloading && dest->IsReady ())
|
if (!m_IsDownloading && dest->IsReady ())
|
||||||
{
|
{
|
||||||
if (!m_IsLoaded)
|
if (m_IsLoaded && !m_Subscriptions.empty ())
|
||||||
{
|
|
||||||
// download it from http://i2p-projekt.i2p/hosts.txt
|
|
||||||
LogPrint (eLogInfo, "Addressbook: trying to download it from default subscription.");
|
|
||||||
if (!m_DefaultSubscription)
|
|
||||||
m_DefaultSubscription = std::make_shared<AddressBookSubscription>(*this, DEFAULT_SUBSCRIPTION_ADDRESS);
|
|
||||||
m_IsDownloading = true;
|
|
||||||
std::thread load_hosts(std::bind (&AddressBookSubscription::CheckUpdates, m_DefaultSubscription));
|
|
||||||
load_hosts.detach(); // TODO: use join
|
|
||||||
}
|
|
||||||
else if (!m_Subscriptions.empty ())
|
|
||||||
{
|
{
|
||||||
// pick random subscription
|
// pick random subscription
|
||||||
auto ind = rand () % m_Subscriptions.size();
|
auto ind = rand () % m_Subscriptions.size();
|
||||||
|
|
|
@ -18,11 +18,6 @@ namespace i2p
|
||||||
{
|
{
|
||||||
namespace client
|
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_UPDATE_TIMEOUT = 3; // in minutes
|
||||||
const int INITIAL_SUBSCRIPTION_RETRY_TIMEOUT = 1; // in minutes
|
const int INITIAL_SUBSCRIPTION_RETRY_TIMEOUT = 1; // in minutes
|
||||||
const int CONTINIOUS_SUBSCRIPTION_UPDATE_TIMEOUT = 720; // in minutes (12 hours)
|
const int CONTINIOUS_SUBSCRIPTION_UPDATE_TIMEOUT = 720; // in minutes (12 hours)
|
||||||
|
@ -103,7 +98,6 @@ namespace client
|
||||||
AddressBookStorage * m_Storage;
|
AddressBookStorage * m_Storage;
|
||||||
volatile bool m_IsLoaded, m_IsDownloading;
|
volatile bool m_IsLoaded, m_IsDownloading;
|
||||||
std::vector<std::shared_ptr<AddressBookSubscription> > m_Subscriptions;
|
std::vector<std::shared_ptr<AddressBookSubscription> > m_Subscriptions;
|
||||||
std::shared_ptr<AddressBookSubscription> m_DefaultSubscription; // in case if we don't know any addresses yet
|
|
||||||
boost::asio::deadline_timer * m_SubscriptionsUpdateTimer;
|
boost::asio::deadline_timer * m_SubscriptionsUpdateTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,12 @@ namespace config {
|
||||||
("trust.family", value<std::string>()->default_value(""), "Router Familiy to trust for first hops")
|
("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?");
|
("trust.hidden", value<bool>()->default_value(false), "should we hide our router from other routers?");
|
||||||
|
|
||||||
|
options_description addressbook("AddressBook options");
|
||||||
|
addressbook.add_options()
|
||||||
|
("addressbook.subscriptions", value<std::string>()->default_value(
|
||||||
|
"http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt"
|
||||||
|
), "AddressBook subscriptions URLs, separated by comma");
|
||||||
|
|
||||||
m_OptionsDesc
|
m_OptionsDesc
|
||||||
.add(general)
|
.add(general)
|
||||||
.add(limits)
|
.add(limits)
|
||||||
|
@ -190,6 +196,7 @@ namespace config {
|
||||||
.add(precomputation)
|
.add(precomputation)
|
||||||
.add(reseed)
|
.add(reseed)
|
||||||
.add(trust)
|
.add(trust)
|
||||||
|
.add(addressbook)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@ All options below still possible in cmdline, but better write it in config file:
|
||||||
* --precomputation.elgamal= - Use ElGamal precomputated tables. false for x64 and true for other platforms by default
|
* --precomputation.elgamal= - Use ElGamal precomputated tables. false for x64 and true for other platforms by default
|
||||||
* --reseed.file - Full path to SU3 file to reseed from
|
* --reseed.file - Full path to SU3 file to reseed from
|
||||||
* --reseed.urls - Reseed URLs, separated by comma
|
* --reseed.urls - Reseed URLs, separated by comma
|
||||||
|
* --addressbook.subscriptions - AddressBook subscriptions URLs, separated by comma
|
||||||
|
|
||||||
* --limits.transittunnels= - Override maximum number of transit tunnels. 2500 by default
|
* --limits.transittunnels= - Override maximum number of transit tunnels. 2500 by default
|
||||||
|
|
||||||
|
|
|
@ -92,8 +92,16 @@ ipv6 = false
|
||||||
# name = I2Pd
|
# name = I2Pd
|
||||||
|
|
||||||
[reseed]
|
[reseed]
|
||||||
## Path to reseed .su3 file (if )
|
## URLs to request reseed data from, separated by comma
|
||||||
# file =
|
## 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 subscriptions URLs, separated by comma
|
||||||
|
## Default: inr.i2p at "mainline" I2P Network
|
||||||
|
# subscriptions = http://joajgazyztfssty4w2on5oaqksz6tqoxbduy553y34mf4byv6gpq.b32.i2p/export/alive-hosts.txt
|
||||||
|
|
||||||
[http]
|
[http]
|
||||||
## Uncomment and set to 'false' to disable Web Console
|
## Uncomment and set to 'false' to disable Web Console
|
||||||
|
|
|
@ -32,7 +32,9 @@ Contents:
|
||||||
build_requirements
|
build_requirements
|
||||||
build_notes_unix
|
build_notes_unix
|
||||||
build_notes_windows
|
build_notes_windows
|
||||||
|
build_notes_cross
|
||||||
build_notes_android
|
build_notes_android
|
||||||
|
build_notes_ios
|
||||||
configuration
|
configuration
|
||||||
family
|
family
|
||||||
usage
|
usage
|
||||||
|
|
Loading…
Add table
Reference in a new issue