diff --git a/libi2pd/Config.cpp b/libi2pd/Config.cpp index d6532a79..534f874a 100644 --- a/libi2pd/Config.cpp +++ b/libi2pd/Config.cpp @@ -230,6 +230,7 @@ namespace config { options_description addressbook("AddressBook options"); addressbook.add_options() + ("addressbook.enabled", value()->default_value(true), "Enable address book lookups and subscritions (default: enabled)") ("addressbook.defaulturl", value()->default_value( "http://shx5vqsw7usdaunyzr2qmes2fq37oumybpudrd4jjj4e4vk4uusa.b32.i2p/hosts.txt" ), "AddressBook subscription URL for initial setup") diff --git a/libi2pd_client/AddressBook.cpp b/libi2pd_client/AddressBook.cpp index 4f80f4c4..e67e3f06 100644 --- a/libi2pd_client/AddressBook.cpp +++ b/libi2pd_client/AddressBook.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2020, The PurpleI2P Project +* Copyright (c) 2013-2022, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -299,7 +299,8 @@ namespace client } AddressBook::AddressBook (): m_Storage(nullptr), m_IsLoaded (false), m_IsDownloading (false), - m_NumRetries (0), m_DefaultSubscription (nullptr), m_SubscriptionsUpdateTimer (nullptr) + m_NumRetries (0), m_DefaultSubscription (nullptr), m_SubscriptionsUpdateTimer (nullptr), + m_IsEnabled (true) { } @@ -310,12 +311,16 @@ namespace client void AddressBook::Start () { - if (!m_Storage) - m_Storage = new AddressBookFilesystemStorage; - m_Storage->Init(); - LoadHosts (); /* try storage, then hosts.txt, then download */ - StartSubscriptions (); - StartLookups (); + i2p::config::GetOption("addressbook.enabled", m_IsEnabled); + if (m_IsEnabled) + { + if (!m_Storage) + m_Storage = new AddressBookFilesystemStorage; + m_Storage->Init(); + LoadHosts (); /* try storage, then hosts.txt, then download */ + StartSubscriptions (); + StartLookups (); + } } void AddressBook::StartResolvers () @@ -370,6 +375,7 @@ namespace client pos = address.find (".i2p"); if (pos != std::string::npos) { + if (!m_IsEnabled) return nullptr; auto addr = FindAddress (address); if (!addr) LookupAddress (address); // TODO: diff --git a/libi2pd_client/AddressBook.h b/libi2pd_client/AddressBook.h index ded87de5..192c4ebb 100644 --- a/libi2pd_client/AddressBook.h +++ b/libi2pd_client/AddressBook.h @@ -1,5 +1,5 @@ /* -* Copyright (c) 2013-2020, The PurpleI2P Project +* Copyright (c) 2013-2022, The PurpleI2P Project * * This file is part of Purple i2pd project and licensed under BSD3 * @@ -126,6 +126,7 @@ namespace client std::vector > m_Subscriptions; std::shared_ptr m_DefaultSubscription; // in case if we don't know any addresses yet boost::asio::deadline_timer * m_SubscriptionsUpdateTimer; + bool m_IsEnabled; }; class AddressBookSubscription diff --git a/libi2pd_client/ClientContext.cpp b/libi2pd_client/ClientContext.cpp index 41b2a494..3f670f06 100644 --- a/libi2pd_client/ClientContext.cpp +++ b/libi2pd_client/ClientContext.cpp @@ -864,6 +864,8 @@ namespace client uint16_t httpProxyPort; i2p::config::GetOption("httpproxy.port", httpProxyPort); std::string httpOutProxyURL; i2p::config::GetOption("httpproxy.outproxy", httpOutProxyURL); bool httpAddresshelper; i2p::config::GetOption("httpproxy.addresshelper", httpAddresshelper); + if (httpAddresshelper) + i2p::config::GetOption("addressbook.enabled", httpAddresshelper); // addresshelper is not supported without address book i2p::data::SigningKeyType sigType; i2p::config::GetOption("httpproxy.signaturetype", sigType); LogPrint(eLogInfo, "Clients: Starting HTTP Proxy at ", httpProxyAddr, ":", httpProxyPort); if (httpProxyKeys.length () > 0)