aboutsummaryrefslogtreecommitdiff
path: root/src/p2p/net_node.inl
diff options
context:
space:
mode:
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r--src/p2p/net_node.inl16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 08fd1d1e6..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))))
@@ -252,7 +254,9 @@ namespace nodetool
// for some time yet.
for (const std::string& addr_str : m_seed_nodes_list)
{
- std::vector<std::string> addr_list = tools::DNSResolver::instance().get_ipv4(addr_str);
+ // TODO: care about dnssec avail/valid
+ bool avail, valid;
+ std::vector<std::string> addr_list = tools::DNSResolver::instance().get_ipv4(addr_str, avail, valid);
for (const std::string& a : addr_list)
{
append_net_address(m_seed_nodes, a + ":18080");
@@ -324,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);
}