diff options
author | Riccardo Spagni <ric@spagni.net> | 2014-10-02 18:43:13 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2014-10-02 18:54:55 +0200 |
commit | 18281f4d205d9e320fad23ac3c28b66ea4bb2ff7 (patch) | |
tree | f007a38c98ad2f8d6e7b3cd85230b0ce4c5fcf02 /src | |
parent | fixed unbound static lib on mingw as libunbound.dll.a (diff) | |
download | monero-18281f4d205d9e320fad23ac3c28b66ea4bb2ff7.tar.xz |
remove dangling upnp port mappings, updated miniupnpc
Diffstat (limited to 'src')
-rw-r--r-- | src/p2p/net_node.inl | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 2953bdb7a..01fbaa497 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -48,9 +48,11 @@ #ifdef UPNP_STATIC #include <miniupnpc/miniupnpc.h> #include <miniupnpc/upnpcommands.h> + #include <miniupnpc/upnperrors.h> #else #include "miniupnpc.h" #include "upnpcommands.h" + #include "upnperrors.h" #endif #define NET_MAKE_IP(b1,b2,b3,b4) ((LPARAM)(((DWORD)(b1)<<24)+((DWORD)(b2)<<16)+((DWORD)(b3)<<8)+((DWORD)(b4)))) @@ -326,8 +328,14 @@ namespace nodetool if (result == 1) { std::ostringstream portString; portString << m_listenning_port; - if (UPNP_AddPortMapping(urls.controlURL, igdData.first.servicetype, portString.str().c_str(), portString.str().c_str(), lanAddress, CRYPTONOTE_NAME, "TCP", 0, "0") != 0) { - LOG_ERROR("UPNP_AddPortMapping failed."); + + // Delete the port mapping before we create it, just in case we have dangling port mapping from the daemon not being shut down correctly + UPNP_DeletePortMapping(urls.controlURL, igdData.first.servicetype, portString.str().c_str(), "TCP", 0); + + int portMappingResult; + portMappingResult = UPNP_AddPortMapping(urls.controlURL, igdData.first.servicetype, portString.str().c_str(), portString.str().c_str(), lanAddress, CRYPTONOTE_NAME, "TCP", 0, "0"); + if (portMappingResult != 0) { + LOG_ERROR("UPNP_AddPortMapping failed, error: " << strupnperror(portMappingResult)); } else { LOG_PRINT_GREEN("Added IGD port mapping.", LOG_LEVEL_0); } |