mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-10-11 03:53:22 +02:00
net: Add -natpmp command line option
This commit is contained in:
17
src/init.cpp
17
src/init.cpp
@@ -469,6 +469,11 @@ void SetupServerArgs(NodeContext& node)
|
||||
#else
|
||||
hidden_args.emplace_back("-upnp");
|
||||
#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("-whitebind=<[permissions@]addr>", "Bind to the given address and add permission flags to the peers connecting to it. "
|
||||
"Use [host]:port notation for IPv6. Allowed permissions: " + Join(NET_PERMISSIONS_DOC, ", ") + ". "
|
||||
"Specify multiple permissions separated by commas (default: download,noban,mempool,relay). Can be specified multiple times.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
|
||||
@@ -813,10 +818,13 @@ void InitParameterInteraction(ArgsManager& args)
|
||||
// to protect privacy, do not listen by default if a default proxy server is specified
|
||||
if (args.SoftSetBoolArg("-listen", false))
|
||||
LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
|
||||
// to protect privacy, do not use UPNP when a proxy is set. The user may still specify -listen=1
|
||||
// to protect privacy, do not map ports when a proxy is set. The user may still specify -listen=1
|
||||
// to listen locally, so don't rely on this happening through -listen below.
|
||||
if (args.SoftSetBoolArg("-upnp", false))
|
||||
LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __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
|
||||
if (args.SoftSetBoolArg("-discover", false))
|
||||
LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
|
||||
@@ -826,6 +834,9 @@ void InitParameterInteraction(ArgsManager& args)
|
||||
// do not map ports or try to retrieve public IP when not listening (pointless)
|
||||
if (args.SoftSetBoolArg("-upnp", false))
|
||||
LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
|
||||
if (args.SoftSetBoolArg("-natpmp", false)) {
|
||||
LogPrintf("%s: parameter interaction: -listen=0 -> setting -natpmp=0\n", __func__);
|
||||
}
|
||||
if (args.SoftSetBoolArg("-discover", false))
|
||||
LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
|
||||
if (args.SoftSetBoolArg("-listenonion", false))
|
||||
@@ -1899,8 +1910,8 @@ bool AppInitMain(const util::Ref& context, NodeContext& node, interfaces::BlockA
|
||||
|
||||
Discover();
|
||||
|
||||
// Map ports with UPnP
|
||||
StartMapPort(args.GetBoolArg("-upnp", DEFAULT_UPNP));
|
||||
// Map ports with UPnP or NAT-PMP.
|
||||
StartMapPort(args.GetBoolArg("-upnp", DEFAULT_UPNP), gArgs.GetBoolArg("-natpmp", DEFAULT_NATPMP));
|
||||
|
||||
CConnman::Options connOptions;
|
||||
connOptions.nLocalServices = nLocalServices;
|
||||
|
Reference in New Issue
Block a user