Browse Source

configure persist of peer profiles

* If persist.profiles = false, peer profiles not stored on disk
* remove inet_pton for windows
* update configs
pull/1274/head
R4SAS 6 years ago
parent
commit
79c0c11e80
  1. 12
      android/assets/i2pd.conf
  2. 4
      contrib/i2pd.conf
  3. 8
      libi2pd/Config.cpp
  4. 11
      libi2pd/NetDb.cpp
  5. 2
      libi2pd/NetDb.hpp
  6. 1
      libi2pd/Transports.cpp
  7. 6
      libi2pd/util.cpp

12
android/assets/i2pd.conf

@ -37,7 +37,12 @@ port = 7070 @@ -37,7 +37,12 @@ port = 7070
enabled = true
address = 127.0.0.1
port = 4444
# keys = http-proxy-keys.dat
inbound.length = 1
inbound.quantity = 5
outbound.length = 1
outbound.quantity = 5
signaturetype=7
keys = proxy-keys.dat
# addresshelper = true
# outproxy = http://false.i2p
## httpproxy section also accepts I2CP parameters, like "inbound.length" etc.
@ -46,7 +51,7 @@ port = 4444 @@ -46,7 +51,7 @@ port = 4444
enabled = true
address = 127.0.0.1
port = 4447
# keys = socks-proxy-keys.dat
keys = proxy-keys.dat
# outproxy.enabled = false
# outproxy = 127.0.0.1
# outproxyport = 9050
@ -80,3 +85,6 @@ verify = true @@ -80,3 +85,6 @@ verify = true
[limits]
transittunnels = 50
[persist]
profiles = false

4
contrib/i2pd.conf

@ -225,3 +225,7 @@ verify = true @@ -225,3 +225,7 @@ verify = true
# inbound.quantity = 3
# outbound.length = 2
# outbound.quantity = 3
[persist]
## Save peer profiles on disk (default: true)
# profiles = true

8
libi2pd/Config.cpp

@ -237,7 +237,7 @@ namespace config { @@ -237,7 +237,7 @@ namespace config {
options_description ntcp2("NTCP2 Options");
ntcp2.add_options()
("ntcp2.enabled", value<bool>()->default_value(true), "Enable NTCP2 (default: enabled)")
("ntcp2.published", value<bool>()->default_value(false), "Publish NTCP2 (default: disabled)")
("ntcp2.published", value<bool>()->default_value(false), "Publish NTCP2 (default: disabled)")
("ntcp2.port", value<uint16_t>()->default_value(0), "Port to listen for incoming NTCP2 connections (default: auto)")
;
@ -253,6 +253,11 @@ namespace config { @@ -253,6 +253,11 @@ namespace config {
("nettime.ntpsyncinterval", value<int>()->default_value(72), "NTP sync interval in hours (default: 72)")
;
options_description persist("Network information persisting options");
persist.add_options()
("persist.profiles", value<bool>()->default_value(true), "Persist peer profiles (default: true)")
;
m_OptionsDesc
.add(general)
.add(limits)
@ -272,6 +277,7 @@ namespace config { @@ -272,6 +277,7 @@ namespace config {
.add(exploratory)
.add(ntcp2)
.add(nettime)
.add(persist)
;
}

11
libi2pd/NetDb.cpp

@ -44,10 +44,12 @@ namespace data @@ -44,10 +44,12 @@ namespace data
m_Families.LoadCertificates ();
Load ();
uint16_t threshold; i2p::config::GetOption("reseed.threshold", threshold);
uint16_t threshold; i2p::config::GetOption("reseed.threshold", threshold);
if (m_RouterInfos.size () < threshold) // reseed if # of router less than threshold
Reseed ();
i2p::config::GetOption("persist.profiles", m_PersistProfiles);
m_IsRunning = true;
m_Thread = new std::thread (std::bind (&NetDb::Run, this));
}
@ -56,8 +58,9 @@ namespace data @@ -56,8 +58,9 @@ namespace data
{
if (m_IsRunning)
{
for (auto& it: m_RouterInfos)
it.second->SaveProfile ();
if (m_PersistProfiles)
for (auto& it: m_RouterInfos)
it.second->SaveProfile ();
DeleteObsoleteProfiles ();
m_RouterInfos.clear ();
m_Floodfills.clear ();
@ -539,7 +542,7 @@ namespace data @@ -539,7 +542,7 @@ namespace data
{
if (it->second->IsUnreachable ())
{
it->second->SaveProfile ();
if (m_PersistProfiles) it->second->SaveProfile ();
it = m_RouterInfos.erase (it);
continue;
}

2
libi2pd/NetDb.hpp

@ -144,6 +144,8 @@ namespace data @@ -144,6 +144,8 @@ namespace data
friend class NetDbRequests;
NetDbRequests m_Requests;
bool m_PersistProfiles;
/** router info we are bootstrapping from or nullptr if we are not currently doing that*/
std::shared_ptr<RouterInfo> m_FloodfillBootstrap;

1
libi2pd/Transports.cpp

@ -817,7 +817,6 @@ namespace transport @@ -817,7 +817,6 @@ namespace transport
if (profile)
{
profile->TunnelNonReplied();
profile->Save(it->first);
}
std::unique_lock<std::mutex> l(m_PeersMutex);
it = m_Peers.erase (it);

6
libi2pd/util.cpp

@ -21,9 +21,9 @@ @@ -21,9 +21,9 @@
#define MALLOC(x) HeapAlloc(GetProcessHeap(), 0, (x))
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
/* // No more needed. Exists in MinGW.
int inet_pton(int af, const char *src, void *dst)
{ /* This function was written by Petar Korponai?. See
http://stackoverflow.com/questions/15660203/inet-pton-identifier-not-found */
{ // This function was written by Petar Korponai?. See http://stackoverflow.com/questions/15660203/inet-pton-identifier-not-found
struct sockaddr_storage ss;
int size = sizeof (ss);
char src_copy[INET6_ADDRSTRLEN + 1];
@ -45,7 +45,7 @@ http://stackoverflow.com/questions/15660203/inet-pton-identifier-not-found */ @@ -45,7 +45,7 @@ http://stackoverflow.com/questions/15660203/inet-pton-identifier-not-found */
}
}
return 0;
}
}*/
#else /* !WIN32 => UNIX */
#include <sys/types.h>
#include <ifaddrs.h>

Loading…
Cancel
Save