You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
argsman.AddArg("-natpmp", strprintf("Use NAT-PMP to map the listening port (default: %u)", DEFAULT_NATPMP), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
576
-
#else
577
-
hidden_args.emplace_back("-natpmp");
578
-
#endif// USE_NATPMP
574
+
argsman.AddArg("-natpmp", strprintf("Use PCP or NAT-PMP to map the listening port (default: %u)", DEFAULT_NATPMP), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
579
575
argsman.AddArg("-whitebind=<[permissions@]addr>", "Bind to the given address and add permission flags to the peers connecting to it. "
"Specify multiple permissions separated by commas (default: download,noban,mempool,relay). Can be specified multiple times.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
LogPrintf("natpmp: The gateway does not support NAT-PMP.\n");
111
-
} else {
112
-
LogPrintf("natpmp: readnatpmpresponseorretry() for port mapping failed with %d error.\n", r_read);
113
112
}
114
-
} else {
115
-
LogPrintf("natpmp: sendnewportmappingrequest() failed with %d error.\n", r_send);
116
-
}
117
-
118
-
returnfalse;
119
-
}
120
113
121
-
staticboolProcessNatpmp()
122
-
{
123
-
bool ret = false;
124
-
natpmp_t natpmp;
125
-
structin_addr external_ipv4_addr;
126
-
if (NatpmpInit(&natpmp) && NatpmpDiscover(&natpmp, external_ipv4_addr)) {
127
-
bool external_ip_discovered = false;
128
-
constuint16_t private_port = GetListenPort();
129
-
do {
130
-
ret = NatpmpMapping(&natpmp, external_ipv4_addr, private_port, external_ip_discovered);
131
-
} while (ret && g_mapport_interrupt.sleep_for(PORT_MAPPING_REANNOUNCE_PERIOD));
132
-
g_mapport_interrupt.reset();
114
+
// Log message if we got NO_RESOURCES.
115
+
if (no_resources) {
116
+
LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "portmap: At least one mapping failed because of a NO_RESOURCES error. This usually indicates that the port is already used on the router. If this is the only instance of bitcoin running on the network, this will resolve itself automatically. Otherwise, you might want to choose a different P2P port to prevent this conflict.\n");
117
+
}
133
118
134
-
constint r_send = sendnewportmappingrequest(&natpmp, NATPMP_PROTOCOL_TCP, private_port, g_mapport_external_port, /* remove a port mapping */0);
135
-
g_mapport_external_port = 0;
136
-
if (r_send == 12/* OK */) {
137
-
LogPrintf("natpmp: Port mapping removed successfully.\n");
138
-
} else {
139
-
LogPrintf("natpmp: sendnewportmappingrequest(0) failed with %d error.\n", r_send);
119
+
// Sanity-check returned lifetime.
120
+
if (actual_lifetime < 30) {
121
+
LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "portmap: Got impossibly short mapping lifetime of %d seconds\n", actual_lifetime);
122
+
returnfalse;
140
123
}
141
-
}
124
+
// RFC6887 11.2.1 recommends that clients send their first renewal packet at a time chosen with uniform random
125
+
// distribution in the range 1/2 to 5/8 of expiration time.
0 commit comments