|
|
@ -182,12 +182,15 @@ bool static InitWarning(const std::string &str) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool static Bind(const CService &addr) { |
|
|
|
bool static Bind(const CService &addr, bool fError = true) { |
|
|
|
if (IsLimited(addr)) |
|
|
|
if (IsLimited(addr)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
std::string strError; |
|
|
|
std::string strError; |
|
|
|
if (!BindListenPort(addr, strError)) |
|
|
|
if (!BindListenPort(addr, strError)) { |
|
|
|
|
|
|
|
if (fError) |
|
|
|
return InitError(strError); |
|
|
|
return InitError(strError); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -204,20 +207,18 @@ std::string HelpMessage() |
|
|
|
" -dblogsize=<n> " + _("Set database disk log size in megabytes (default: 100)") + "\n" + |
|
|
|
" -dblogsize=<n> " + _("Set database disk log size in megabytes (default: 100)") + "\n" + |
|
|
|
" -timeout=<n> " + _("Specify connection timeout (in milliseconds)") + "\n" + |
|
|
|
" -timeout=<n> " + _("Specify connection timeout (in milliseconds)") + "\n" + |
|
|
|
" -proxy=<ip:port> " + _("Connect through socks proxy") + "\n" + |
|
|
|
" -proxy=<ip:port> " + _("Connect through socks proxy") + "\n" + |
|
|
|
" -socks=<n> " + _("Select the version of socks proxy to use (4 or 5, 5 is default)") + "\n" + |
|
|
|
" -socks=<n> " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n" + |
|
|
|
" -noproxy=<net> " + _("Do not use proxy for connections to network <net> (IPv4 or IPv6)") + "\n" + |
|
|
|
|
|
|
|
" -dns " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n" + |
|
|
|
" -dns " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n" + |
|
|
|
" -proxydns " + _("Pass DNS requests to (SOCKS5) proxy") + "\n" + |
|
|
|
|
|
|
|
" -port=<port> " + _("Listen for connections on <port> (default: 8333 or testnet: 18333)") + "\n" + |
|
|
|
" -port=<port> " + _("Listen for connections on <port> (default: 8333 or testnet: 18333)") + "\n" + |
|
|
|
" -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n" + |
|
|
|
" -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n" + |
|
|
|
" -addnode=<ip> " + _("Add a node to connect to and attempt to keep the connection open") + "\n" + |
|
|
|
" -addnode=<ip> " + _("Add a node to connect to and attempt to keep the connection open") + "\n" + |
|
|
|
" -connect=<ip> " + _("Connect only to the specified node") + "\n" + |
|
|
|
" -connect=<ip> " + _("Connect only to the specified node(s)") + "\n" + |
|
|
|
" -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n" + |
|
|
|
" -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n" + |
|
|
|
" -externalip=<ip> " + _("Specify your own public address") + "\n" + |
|
|
|
" -externalip=<ip> " + _("Specify your own public address") + "\n" + |
|
|
|
" -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4 or IPv6)") + "\n" + |
|
|
|
" -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4 or IPv6)") + "\n" + |
|
|
|
" -discover " + _("Try to discover public IP address (default: 1)") + "\n" + |
|
|
|
" -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n" + |
|
|
|
" -irc " + _("Find peers using internet relay chat (default: 0)") + "\n" + |
|
|
|
" -irc " + _("Find peers using internet relay chat (default: 0)") + "\n" + |
|
|
|
" -listen " + _("Accept connections from outside (default: 1)") + "\n" + |
|
|
|
" -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n" + |
|
|
|
" -bind=<addr> " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n" + |
|
|
|
" -bind=<addr> " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n" + |
|
|
|
" -dnsseed " + _("Find peers using DNS lookup (default: 1)") + "\n" + |
|
|
|
" -dnsseed " + _("Find peers using DNS lookup (default: 1)") + "\n" + |
|
|
|
" -banscore=<n> " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" + |
|
|
|
" -banscore=<n> " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" + |
|
|
@ -226,9 +227,9 @@ std::string HelpMessage() |
|
|
|
" -maxsendbuffer=<n> " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 10000)") + "\n" + |
|
|
|
" -maxsendbuffer=<n> " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 10000)") + "\n" + |
|
|
|
#ifdef USE_UPNP |
|
|
|
#ifdef USE_UPNP |
|
|
|
#if USE_UPNP |
|
|
|
#if USE_UPNP |
|
|
|
" -upnp " + _("Use Universal Plug and Play to map the listening port (default: 1)") + "\n" + |
|
|
|
" -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n" + |
|
|
|
#else |
|
|
|
#else |
|
|
|
" -upnp " + _("Use Universal Plug and Play to map the listening port (default: 0)") + "\n" + |
|
|
|
" -upnp " + _("Use UPnP to map the listening port (default: 0)") + "\n" + |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
" -detachdb " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n" + |
|
|
|
" -detachdb " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n" + |
|
|
@ -308,30 +309,38 @@ bool AppInit2() |
|
|
|
// ********************************************************* Step 2: parameter interactions
|
|
|
|
// ********************************************************* Step 2: parameter interactions
|
|
|
|
|
|
|
|
|
|
|
|
fTestNet = GetBoolArg("-testnet"); |
|
|
|
fTestNet = GetBoolArg("-testnet"); |
|
|
|
if (fTestNet) |
|
|
|
if (fTestNet) { |
|
|
|
{ |
|
|
|
|
|
|
|
SoftSetBoolArg("-irc", true); |
|
|
|
SoftSetBoolArg("-irc", true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mapArgs.count("-connect")) |
|
|
|
if (mapArgs.count("-bind")) { |
|
|
|
SoftSetBoolArg("-dnsseed", false); |
|
|
|
// when specifying an explicit binding address, you want to listen on it
|
|
|
|
|
|
|
|
// even when -connect or -proxy is specified
|
|
|
|
// even in Tor mode, if -bind is specified, you really want -listen
|
|
|
|
|
|
|
|
if (mapArgs.count("-bind")) |
|
|
|
|
|
|
|
SoftSetBoolArg("-listen", true); |
|
|
|
SoftSetBoolArg("-listen", true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool fTor = (fUseProxy && addrProxy.GetPort() == 9050); |
|
|
|
if (mapArgs.count("-connect")) { |
|
|
|
if (fTor) |
|
|
|
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
|
|
|
|
{ |
|
|
|
SoftSetBoolArg("-dnsseed", false); |
|
|
|
// Use SoftSetBoolArg here so user can override any of these if they wish.
|
|
|
|
SoftSetBoolArg("-listen", false); |
|
|
|
// Note: the GetBoolArg() calls for all of these must happen later.
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mapArgs.count("-proxy")) { |
|
|
|
|
|
|
|
// to protect privacy, do not listen by default if a proxy server is specified
|
|
|
|
SoftSetBoolArg("-listen", false); |
|
|
|
SoftSetBoolArg("-listen", false); |
|
|
|
SoftSetBoolArg("-irc", false); |
|
|
|
} |
|
|
|
SoftSetBoolArg("-proxydns", true); |
|
|
|
|
|
|
|
|
|
|
|
if (GetBoolArg("-listen", true)) { |
|
|
|
|
|
|
|
// do not map ports or try to retrieve public IP when not listening (pointless)
|
|
|
|
SoftSetBoolArg("-upnp", false); |
|
|
|
SoftSetBoolArg("-upnp", false); |
|
|
|
SoftSetBoolArg("-discover", false); |
|
|
|
SoftSetBoolArg("-discover", false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mapArgs.count("-externalip")) { |
|
|
|
|
|
|
|
// if an explicit public IP is specified, do not try to find others
|
|
|
|
|
|
|
|
SoftSetBoolArg("-discover", false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ********************************************************* Step 3: parameter-to-internal-flags
|
|
|
|
// ********************************************************* Step 3: parameter-to-internal-flags
|
|
|
|
|
|
|
|
|
|
|
|
fDebug = GetBoolArg("-debug"); |
|
|
|
fDebug = GetBoolArg("-debug"); |
|
|
@ -425,30 +434,8 @@ bool AppInit2() |
|
|
|
|
|
|
|
|
|
|
|
// ********************************************************* Step 5: network initialization
|
|
|
|
// ********************************************************* Step 5: network initialization
|
|
|
|
|
|
|
|
|
|
|
|
if (mapArgs.count("-proxy")) |
|
|
|
int nSocksVersion = GetArg("-socks", 5); |
|
|
|
{ |
|
|
|
|
|
|
|
fUseProxy = true; |
|
|
|
|
|
|
|
addrProxy = CService(mapArgs["-proxy"], 9050); |
|
|
|
|
|
|
|
if (!addrProxy.IsValid()) |
|
|
|
|
|
|
|
return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"].c_str())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mapArgs.count("-noproxy")) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
BOOST_FOREACH(std::string snet, mapMultiArgs["-noproxy"]) { |
|
|
|
|
|
|
|
enum Network net = ParseNetwork(snet); |
|
|
|
|
|
|
|
if (net == NET_UNROUTABLE) |
|
|
|
|
|
|
|
return InitError(strprintf(_("Unknown network specified in -noproxy: '%s'"), snet.c_str())); |
|
|
|
|
|
|
|
SetNoProxy(net); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fNameLookup = GetBoolArg("-dns"); |
|
|
|
|
|
|
|
fProxyNameLookup = GetBoolArg("-proxydns"); |
|
|
|
|
|
|
|
if (fProxyNameLookup) |
|
|
|
|
|
|
|
fNameLookup = true; |
|
|
|
|
|
|
|
fNoListen = !GetBoolArg("-listen", true); |
|
|
|
|
|
|
|
nSocksVersion = GetArg("-socks", 5); |
|
|
|
|
|
|
|
if (nSocksVersion != 4 && nSocksVersion != 5) |
|
|
|
if (nSocksVersion != 4 && nSocksVersion != 5) |
|
|
|
return InitError(strprintf(_("Unknown -socks proxy version requested: %i"), nSocksVersion)); |
|
|
|
return InitError(strprintf(_("Unknown -socks proxy version requested: %i"), nSocksVersion)); |
|
|
|
|
|
|
|
|
|
|
@ -467,8 +454,29 @@ bool AppInit2() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
BOOST_FOREACH(string strDest, mapMultiArgs["-seednode"]) |
|
|
|
if (mapArgs.count("-proxy")) { |
|
|
|
AddOneShot(strDest); |
|
|
|
CService addrProxy = CService(mapArgs["-proxy"], 9050); |
|
|
|
|
|
|
|
if (!addrProxy.IsValid()) |
|
|
|
|
|
|
|
return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"].c_str())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!IsLimited(NET_IPV4)) |
|
|
|
|
|
|
|
SetProxy(NET_IPV4, addrProxy, nSocksVersion); |
|
|
|
|
|
|
|
if (nSocksVersion > 4) { |
|
|
|
|
|
|
|
#ifdef USE_IPV6 |
|
|
|
|
|
|
|
if (!IsLimited(NET_IPV6)) |
|
|
|
|
|
|
|
SetProxy(NET_IPV6, addrProxy, nSocksVersion); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
SetNameProxy(addrProxy, nSocksVersion); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// see Step 2: parameter interactions for more information about these
|
|
|
|
|
|
|
|
fNoListen = !GetBoolArg("-listen", true); |
|
|
|
|
|
|
|
fDiscover = GetBoolArg("-discover", true); |
|
|
|
|
|
|
|
fNameLookup = GetBoolArg("-dns", true); |
|
|
|
|
|
|
|
#ifdef USE_UPNP |
|
|
|
|
|
|
|
fUseUPnP = GetBoolArg("-upnp", USE_UPNP); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
bool fBound = false; |
|
|
|
bool fBound = false; |
|
|
|
if (!fNoListen) |
|
|
|
if (!fNoListen) |
|
|
@ -484,15 +492,15 @@ bool AppInit2() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
struct in_addr inaddr_any; |
|
|
|
struct in_addr inaddr_any; |
|
|
|
inaddr_any.s_addr = INADDR_ANY; |
|
|
|
inaddr_any.s_addr = INADDR_ANY; |
|
|
|
if (!IsLimited(NET_IPV4)) |
|
|
|
|
|
|
|
fBound |= Bind(CService(inaddr_any, GetListenPort())); |
|
|
|
|
|
|
|
#ifdef USE_IPV6 |
|
|
|
#ifdef USE_IPV6 |
|
|
|
if (!IsLimited(NET_IPV6)) |
|
|
|
if (!IsLimited(NET_IPV6)) |
|
|
|
fBound |= Bind(CService(in6addr_any, GetListenPort())); |
|
|
|
fBound |= Bind(CService(in6addr_any, GetListenPort()), false); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
if (!IsLimited(NET_IPV4)) |
|
|
|
|
|
|
|
fBound |= Bind(CService(inaddr_any, GetListenPort()), !fBound); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!fBound) |
|
|
|
if (!fBound) |
|
|
|
return InitError(_("Not listening on any port")); |
|
|
|
return InitError(_("Failed to listen on any port. Use -listen=0 if you want this.")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mapArgs.count("-externalip")) |
|
|
|
if (mapArgs.count("-externalip")) |
|
|
@ -505,6 +513,9 @@ bool AppInit2() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOST_FOREACH(string strDest, mapMultiArgs["-seednode"]) |
|
|
|
|
|
|
|
AddOneShot(strDest); |
|
|
|
|
|
|
|
|
|
|
|
// ********************************************************* Step 6: load blockchain
|
|
|
|
// ********************************************************* Step 6: load blockchain
|
|
|
|
|
|
|
|
|
|
|
|
if (GetBoolArg("-loadblockindextest")) |
|
|
|
if (GetBoolArg("-loadblockindextest")) |
|
|
|