mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
Fix UPnP by reannouncing every 20 minutes.
This commit is contained in:
parent
c52296a73e
commit
177dbcaace
24
src/net.cpp
24
src/net.cpp
@ -967,11 +967,11 @@ void ThreadMapPort2(void* parg)
|
|||||||
{
|
{
|
||||||
string strDesc = "Bitcoin " + FormatFullVersion();
|
string strDesc = "Bitcoin " + FormatFullVersion();
|
||||||
#ifndef UPNPDISCOVER_SUCCESS
|
#ifndef UPNPDISCOVER_SUCCESS
|
||||||
/* miniupnpc 1.5 */
|
/* miniupnpc 1.5 */
|
||||||
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
|
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
|
||||||
port, port, lanaddr, strDesc.c_str(), "TCP", 0);
|
port, port, lanaddr, strDesc.c_str(), "TCP", 0);
|
||||||
#else
|
#else
|
||||||
/* miniupnpc 1.6 */
|
/* miniupnpc 1.6 */
|
||||||
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
|
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
|
||||||
port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0");
|
port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0");
|
||||||
#endif
|
#endif
|
||||||
@ -981,6 +981,7 @@ void ThreadMapPort2(void* parg)
|
|||||||
port, port, lanaddr, r, strupnperror(r));
|
port, port, lanaddr, r, strupnperror(r));
|
||||||
else
|
else
|
||||||
printf("UPnP Port Mapping successful.\n");
|
printf("UPnP Port Mapping successful.\n");
|
||||||
|
int i = 1;
|
||||||
loop {
|
loop {
|
||||||
if (fShutdown || !fUseUPnP)
|
if (fShutdown || !fUseUPnP)
|
||||||
{
|
{
|
||||||
@ -990,7 +991,26 @@ void ThreadMapPort2(void* parg)
|
|||||||
FreeUPNPUrls(&urls);
|
FreeUPNPUrls(&urls);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (i % 600 == 0) // Refresh every 20 minutes
|
||||||
|
{
|
||||||
|
#ifndef UPNPDISCOVER_SUCCESS
|
||||||
|
/* miniupnpc 1.5 */
|
||||||
|
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
|
||||||
|
port, port, lanaddr, strDesc.c_str(), "TCP", 0);
|
||||||
|
#else
|
||||||
|
/* miniupnpc 1.6 */
|
||||||
|
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
|
||||||
|
port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(r!=UPNPCOMMAND_SUCCESS)
|
||||||
|
printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
|
||||||
|
port, port, lanaddr, r, strupnperror(r));
|
||||||
|
else
|
||||||
|
printf("UPnP Port Mapping successful.\n");;
|
||||||
|
}
|
||||||
Sleep(2000);
|
Sleep(2000);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
printf("No valid UPnP IGDs found\n");
|
printf("No valid UPnP IGDs found\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user