BIP155 (addrv2)
Tor v3 + i2p
This commit is contained in:
77
src/init.cpp
77
src/init.cpp
@@ -246,14 +246,22 @@ void Shutdown()
|
||||
if (pcoinsTip != NULL) {
|
||||
FlushStateToDisk();
|
||||
}
|
||||
delete pcoinsTip;
|
||||
pcoinsTip = NULL;
|
||||
delete pcoinscatcher;
|
||||
pcoinscatcher = NULL;
|
||||
delete pcoinsdbview;
|
||||
pcoinsdbview = NULL;
|
||||
delete pblocktree;
|
||||
pblocktree = NULL;
|
||||
if (pcoinsTip != NULL) {
|
||||
delete pcoinsTip;
|
||||
pcoinsTip = NULL;
|
||||
}
|
||||
if (pcoinscatcher != NULL) {
|
||||
delete pcoinscatcher;
|
||||
pcoinscatcher = NULL;
|
||||
}
|
||||
if (pcoinsdbview != NULL) {
|
||||
delete pcoinsdbview;
|
||||
pcoinsdbview = NULL;
|
||||
}
|
||||
if (pblocktree != NULL) {
|
||||
delete pblocktree;
|
||||
pblocktree = NULL;
|
||||
}
|
||||
}
|
||||
#ifdef ENABLE_WALLET
|
||||
if (pwalletMain)
|
||||
@@ -274,7 +282,7 @@ void Shutdown()
|
||||
#endif
|
||||
globalVerifyHandle.reset();
|
||||
ECC_Stop();
|
||||
CNode::NetCleanup();
|
||||
// CNode::NetCleanup();
|
||||
LogPrintf("%s: done\n", __func__);
|
||||
}
|
||||
|
||||
@@ -325,7 +333,7 @@ bool static InitWarning(const std::string &str)
|
||||
}
|
||||
|
||||
bool static Bind(const CService &addr, unsigned int flags) {
|
||||
if (!(flags & BF_EXPLICIT) && IsLimited(addr))
|
||||
if (!(flags & BF_EXPLICIT) && !IsReachable(addr))
|
||||
return false;
|
||||
std::string strError;
|
||||
if (!BindListenPort(addr, strError, (flags & BF_ALLOWLIST) != 0)) {
|
||||
@@ -416,7 +424,14 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-maxreceivebuffer=<n>", strprintf(_("Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)"), 5000));
|
||||
strUsage += HelpMessageOpt("-maxsendbuffer=<n>", strprintf(_("Maximum per-connection send buffer, <n>*1000 bytes (default: %u)"), 1000));
|
||||
strUsage += HelpMessageOpt("-onion=<ip:port>", strprintf(_("Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)"), "-proxy"));
|
||||
strUsage += HelpMessageOpt("-onlynet=<net>", _("Only connect to nodes in network <net> (ipv4, ipv6 or onion)"));
|
||||
strUsage += HelpMessageOpt("-nspv_msg", strprintf(_("Enable NSPV messages processing (default: true when -ac_private=1, otherwise false)")));
|
||||
|
||||
strUsage += HelpMessageOpt("-i2psam=<ip:port>", strprintf(_("I2P SAM proxy to reach I2P peers and accept I2P connections (default: none)")));
|
||||
strUsage += HelpMessageOpt("-i2pacceptincoming", strprintf(_("If set and -i2psam is also set then incoming I2P connections are accepted via the SAM proxy. If this is not set but -i2psam is set then only outgoing connections will be made to the I2P network. Ignored if -i2psam is not set. Listening for incoming I2P connections is done through the SAM proxy, not by binding to a local address and port (default: 1)")));
|
||||
strUsage += HelpMessageOpt("-onlynet=<net>", _("Only connect to nodes in network <net> (ipv4, ipv6, onion or i2p)"));
|
||||
strUsage += HelpMessageOpt("-disableipv4", _("Disable Ipv4 network connections") + " " + _("(default: 0)"));
|
||||
strUsage += HelpMessageOpt("-disableipv6", _("Disable Ipv6 network connections") + " " + _("(default: 0)"));
|
||||
|
||||
strUsage += HelpMessageOpt("-permitbaremultisig", strprintf(_("Relay non-P2SH multisig (default: %u)"), 1));
|
||||
strUsage += HelpMessageOpt("-peerbloomfilters", strprintf(_("Support filtering of blocks and transaction with Bloom filters (default: %u)"), 1));
|
||||
if (showDebug)
|
||||
@@ -1609,14 +1624,15 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
for (int n = 0; n < NET_MAX; n++) {
|
||||
enum Network net = (enum Network)n;
|
||||
if (!nets.count(net))
|
||||
SetLimited(net);
|
||||
SetReachable(net, false);
|
||||
}
|
||||
}
|
||||
|
||||
//fprintf(stderr,"%s tik19\n", __FUNCTION__);
|
||||
if (mapArgs.count("-allowlist")) {
|
||||
BOOST_FOREACH(const std::string& net, mapMultiArgs["-allowlist"]) {
|
||||
CSubNet subnet(net);
|
||||
CSubNet subnet;
|
||||
LookupSubNet(net.c_str(), subnet);
|
||||
if (!subnet.IsValid())
|
||||
return InitError(strprintf(_("Invalid netmask specified in -allowlist: '%s'"), net));
|
||||
CNode::AddAllowlistedRange(subnet);
|
||||
@@ -1627,9 +1643,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
// -proxy sets a proxy for all outgoing network traffic
|
||||
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
|
||||
std::string proxyArg = GetArg("-proxy", "");
|
||||
SetLimited(NET_ONION);
|
||||
SetReachable(NET_ONION,false);
|
||||
if (proxyArg != "" && proxyArg != "0") {
|
||||
proxyType addrProxy = proxyType(CService(proxyArg, 9050), proxyRandomize);
|
||||
CService resolved(LookupNumeric(proxyArg.c_str(), 9050));
|
||||
proxyType addrProxy = proxyType(resolved, proxyRandomize);
|
||||
if (!addrProxy.IsValid())
|
||||
return InitError(strprintf(_("Invalid -proxy address: '%s'"), proxyArg));
|
||||
|
||||
@@ -1637,9 +1654,20 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
SetProxy(NET_IPV6, addrProxy);
|
||||
SetProxy(NET_ONION, addrProxy);
|
||||
SetNameProxy(addrProxy);
|
||||
SetLimited(NET_ONION, false); // by default, -proxy sets onion as reachable, unless -noonion later
|
||||
SetReachable(NET_ONION, true); // by default, -proxy sets onion as reachable, unless -noonion later
|
||||
}
|
||||
|
||||
const std::string& i2psam_arg = GetArg("-i2psam", "");
|
||||
if (!i2psam_arg.empty()) {
|
||||
CService addr;
|
||||
if (!Lookup(i2psam_arg.c_str(), addr, 7656, fNameLookup) || !addr.IsValid()) {
|
||||
return InitError(strprintf(_("Invalid -i2psam address or hostname: '%s'"), i2psam_arg));
|
||||
}
|
||||
SetReachable(NET_I2P, true);
|
||||
SetProxy(NET_I2P, proxyType{addr});
|
||||
} else {
|
||||
SetReachable(NET_I2P, false);
|
||||
}
|
||||
//fprintf(stderr,"%s tik20\n", __FUNCTION__);
|
||||
|
||||
// -onion can be used to set only a proxy for .onion, or override normal proxy for .onion addresses
|
||||
// -noonion (or -onion=0) disables connecting to .onion entirely
|
||||
@@ -1647,13 +1675,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
std::string onionArg = GetArg("-onion", "");
|
||||
if (onionArg != "") {
|
||||
if (onionArg == "0") { // Handle -noonion/-onion=0
|
||||
SetLimited(NET_ONION); // set onions as unreachable
|
||||
SetReachable(NET_ONION,false); // set onions as unreachable
|
||||
} else {
|
||||
proxyType addrOnion = proxyType(CService(onionArg, 9050), proxyRandomize);
|
||||
CService resolved(LookupNumeric(onionArg.c_str(), 9050));
|
||||
proxyType addrOnion = proxyType(resolved, proxyRandomize);
|
||||
if (!addrOnion.IsValid())
|
||||
return InitError(strprintf(_("Invalid -onion address: '%s'"), onionArg));
|
||||
SetProxy(NET_ONION, addrOnion);
|
||||
SetLimited(NET_ONION, false);
|
||||
SetReachable(NET_ONION, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1692,10 +1721,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
if (mapArgs.count("-externalip")) {
|
||||
BOOST_FOREACH(const std::string& strAddr, mapMultiArgs["-externalip"]) {
|
||||
CService addrLocal(strAddr, GetListenPort(), fNameLookup);
|
||||
if (!addrLocal.IsValid())
|
||||
CService addrLocal;
|
||||
if (Lookup(strAddr.c_str(), addrLocal, GetListenPort(), fNameLookup) && addrLocal.IsValid()) {
|
||||
AddLocal(addrLocal, LOCAL_MANUAL);
|
||||
} else {
|
||||
return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr));
|
||||
AddLocal(CService(strAddr, GetListenPort(), fNameLookup), LOCAL_MANUAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user