Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 856 Lines • ▼ Show 20 Lines | #else | ||||
argsman.AddArg( | argsman.AddArg( | ||||
"-upnp", | "-upnp", | ||||
strprintf("Use UPnP to map the listening port (default: %u)", 0), | strprintf("Use UPnP to map the listening port (default: %u)", 0), | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||
#endif | #endif | ||||
#else | #else | ||||
hidden_args.emplace_back("-upnp"); | hidden_args.emplace_back("-upnp"); | ||||
#endif | #endif | ||||
#ifdef USE_NATPMP | |||||
argsman.AddArg( | |||||
"-natpmp", | |||||
strprintf("Use NAT-PMP to map the listening port (default: %s)", | |||||
DEFAULT_NATPMP ? "1 when listening and no -proxy" : "0"), | |||||
ArgsManager::ALLOW_BOOL, OptionsCategory::CONNECTION); | |||||
#else | |||||
hidden_args.emplace_back("-natpmp"); | |||||
#endif // USE_NATPMP | |||||
argsman.AddArg( | argsman.AddArg( | ||||
"-whitebind=<[permissions@]addr>", | "-whitebind=<[permissions@]addr>", | ||||
"Bind to the given address and add permission flags to the peers " | "Bind to the given address and add permission flags to the peers " | ||||
"connecting to it." | "connecting to it." | ||||
"Use [host]:port notation for IPv6. Allowed permissions: " + | "Use [host]:port notation for IPv6. Allowed permissions: " + | ||||
Join(NET_PERMISSIONS_DOC, ", ") + | Join(NET_PERMISSIONS_DOC, ", ") + | ||||
". " | ". " | ||||
"Specify multiple permissions separated by commas (default: " | "Specify multiple permissions separated by commas (default: " | ||||
▲ Show 20 Lines • Show All 687 Lines • ▼ Show 20 Lines | void InitParameterInteraction(ArgsManager &args) { | ||||
if (args.IsArgSet("-proxy")) { | if (args.IsArgSet("-proxy")) { | ||||
// to protect privacy, do not listen by default if a default proxy | // to protect privacy, do not listen by default if a default proxy | ||||
// server is specified. | // server is specified. | ||||
if (args.SoftSetBoolArg("-listen", false)) { | if (args.SoftSetBoolArg("-listen", false)) { | ||||
LogPrintf( | LogPrintf( | ||||
"%s: parameter interaction: -proxy set -> setting -listen=0\n", | "%s: parameter interaction: -proxy set -> setting -listen=0\n", | ||||
__func__); | __func__); | ||||
} | } | ||||
// to protect privacy, do not use UPNP when a proxy is set. The user may | // to protect privacy, do not map ports when a proxy is set. The user | ||||
// still specify -listen=1 to listen locally, so don't rely on this | // may still specify -listen=1 to listen locally, so don't rely on this | ||||
// happening through -listen below. | // happening through -listen below. | ||||
if (args.SoftSetBoolArg("-upnp", false)) { | if (args.SoftSetBoolArg("-upnp", false)) { | ||||
LogPrintf( | LogPrintf( | ||||
"%s: parameter interaction: -proxy set -> setting -upnp=0\n", | "%s: parameter interaction: -proxy set -> setting -upnp=0\n", | ||||
__func__); | __func__); | ||||
} | } | ||||
if (args.SoftSetBoolArg("-natpmp", false)) { | |||||
LogPrintf( | |||||
"%s: parameter interaction: -proxy set -> setting -natpmp=0\n", | |||||
__func__); | |||||
} | |||||
// to protect privacy, do not discover addresses by default | // to protect privacy, do not discover addresses by default | ||||
if (args.SoftSetBoolArg("-discover", false)) { | if (args.SoftSetBoolArg("-discover", false)) { | ||||
LogPrintf("%s: parameter interaction: -proxy set -> setting " | LogPrintf("%s: parameter interaction: -proxy set -> setting " | ||||
"-discover=0\n", | "-discover=0\n", | ||||
__func__); | __func__); | ||||
} | } | ||||
} | } | ||||
if (!args.GetBoolArg("-listen", DEFAULT_LISTEN)) { | if (!args.GetBoolArg("-listen", DEFAULT_LISTEN)) { | ||||
// do not map ports or try to retrieve public IP when not listening | // do not map ports or try to retrieve public IP when not listening | ||||
// (pointless) | // (pointless) | ||||
if (args.SoftSetBoolArg("-upnp", false)) { | if (args.SoftSetBoolArg("-upnp", false)) { | ||||
LogPrintf( | LogPrintf( | ||||
"%s: parameter interaction: -listen=0 -> setting -upnp=0\n", | "%s: parameter interaction: -listen=0 -> setting -upnp=0\n", | ||||
__func__); | __func__); | ||||
} | } | ||||
if (args.SoftSetBoolArg("-natpmp", false)) { | |||||
LogPrintf( | |||||
"%s: parameter interaction: -listen=0 -> setting -natpmp=0\n", | |||||
__func__); | |||||
} | |||||
if (args.SoftSetBoolArg("-discover", false)) { | if (args.SoftSetBoolArg("-discover", false)) { | ||||
LogPrintf( | LogPrintf( | ||||
"%s: parameter interaction: -listen=0 -> setting -discover=0\n", | "%s: parameter interaction: -listen=0 -> setting -discover=0\n", | ||||
__func__); | __func__); | ||||
} | } | ||||
if (args.SoftSetBoolArg("-listenonion", false)) { | if (args.SoftSetBoolArg("-listenonion", false)) { | ||||
LogPrintf("%s: parameter interaction: -listen=0 -> setting " | LogPrintf("%s: parameter interaction: -listen=0 -> setting " | ||||
"-listenonion=0\n", | "-listenonion=0\n", | ||||
▲ Show 20 Lines • Show All 1,392 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
LogPrintf("nBestHeight = %d\n", chain_active_height); | LogPrintf("nBestHeight = %d\n", chain_active_height); | ||||
if (node.peerman) { | if (node.peerman) { | ||||
node.peerman->SetBestHeight(chain_active_height); | node.peerman->SetBestHeight(chain_active_height); | ||||
} | } | ||||
Discover(); | Discover(); | ||||
// Map ports with UPnP | // Map ports with UPnP or NAT-PMP. | ||||
StartMapPort(args.GetBoolArg("-upnp", DEFAULT_UPNP)); | StartMapPort(args.GetBoolArg("-upnp", DEFAULT_UPNP), | ||||
gArgs.GetBoolArg("-natpmp", DEFAULT_NATPMP)); | |||||
CConnman::Options connOptions; | CConnman::Options connOptions; | ||||
connOptions.nLocalServices = nLocalServices; | connOptions.nLocalServices = nLocalServices; | ||||
connOptions.nMaxConnections = nMaxConnections; | connOptions.nMaxConnections = nMaxConnections; | ||||
connOptions.m_max_avalanche_outbound = std::min<int64_t>( | connOptions.m_max_avalanche_outbound = std::min<int64_t>( | ||||
g_avalanche && isAvalancheEnabled(args) | g_avalanche && isAvalancheEnabled(args) | ||||
? args.GetIntArg("-maxavalancheoutbound", | ? args.GetIntArg("-maxavalancheoutbound", | ||||
DEFAULT_MAX_AVALANCHE_OUTBOUND_CONNECTIONS) | DEFAULT_MAX_AVALANCHE_OUTBOUND_CONNECTIONS) | ||||
▲ Show 20 Lines • Show All 141 Lines • Show Last 20 Lines |