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. 10
      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
enabled = true enabled = true
address = 127.0.0.1 address = 127.0.0.1
port = 4444 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 # addresshelper = true
# outproxy = http://false.i2p # outproxy = http://false.i2p
## httpproxy section also accepts I2CP parameters, like "inbound.length" etc. ## httpproxy section also accepts I2CP parameters, like "inbound.length" etc.
@ -46,7 +51,7 @@ port = 4444
enabled = true enabled = true
address = 127.0.0.1 address = 127.0.0.1
port = 4447 port = 4447
# keys = socks-proxy-keys.dat keys = proxy-keys.dat
# outproxy.enabled = false # outproxy.enabled = false
# outproxy = 127.0.0.1 # outproxy = 127.0.0.1
# outproxyport = 9050 # outproxyport = 9050
@ -80,3 +85,6 @@ verify = true
[limits] [limits]
transittunnels = 50 transittunnels = 50
[persist]
profiles = false

4
contrib/i2pd.conf

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

10
libi2pd/Config.cpp

@ -237,7 +237,7 @@ namespace config {
options_description ntcp2("NTCP2 Options"); options_description ntcp2("NTCP2 Options");
ntcp2.add_options() ntcp2.add_options()
("ntcp2.enabled", value<bool>()->default_value(true), "Enable NTCP2 (default: enabled)") ("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)") ("ntcp2.port", value<uint16_t>()->default_value(0), "Port to listen for incoming NTCP2 connections (default: auto)")
; ;
@ -249,10 +249,15 @@ namespace config {
"1.pool.ntp.org," "1.pool.ntp.org,"
"2.pool.ntp.org," "2.pool.ntp.org,"
"3.pool.ntp.org" "3.pool.ntp.org"
), "Comma separated list of NTCP servers") ), "Comma separated list of NTCP servers")
("nettime.ntpsyncinterval", value<int>()->default_value(72), "NTP sync interval in hours (default: 72)") ("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 m_OptionsDesc
.add(general) .add(general)
.add(limits) .add(limits)
@ -272,6 +277,7 @@ namespace config {
.add(exploratory) .add(exploratory)
.add(ntcp2) .add(ntcp2)
.add(nettime) .add(nettime)
.add(persist)
; ;
} }

11
libi2pd/NetDb.cpp

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

2
libi2pd/NetDb.hpp

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

1
libi2pd/Transports.cpp

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

6
libi2pd/util.cpp

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

Loading…
Cancel
Save