diff options
author | luigi1111 <luigi1111w@gmail.com> | 2019-07-24 14:35:11 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2019-07-24 14:35:11 -0500 |
commit | 61512cf79813d1fa9b54e3c081e4d0304c419a6c (patch) | |
tree | e5b33c282cef725897b596df04c5a2ef2779ec9e /src/p2p/net_node.inl | |
parent | Merge pull request #5608 (diff) | |
parent | p2p: delay IGP probing on startup (diff) | |
download | monero-61512cf79813d1fa9b54e3c081e4d0304c419a6c.tar.xz |
Merge pull request #5610
068fa1c p2p: delay IGP probing on startup (moneromooo-monero)
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r-- | src/p2p/net_node.inl | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index ba7326286..98484fe78 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -105,6 +105,7 @@ namespace nodetool command_line::add_arg(desc, arg_p2p_hide_my_port); command_line::add_arg(desc, arg_no_sync); command_line::add_arg(desc, arg_no_igd); + command_line::add_arg(desc, arg_igd); command_line::add_arg(desc, arg_out_peers); command_line::add_arg(desc, arg_in_peers); command_line::add_arg(desc, arg_tos_flag); @@ -344,7 +345,35 @@ namespace nodetool public_zone.m_can_pingback = true; m_external_port = command_line::get_arg(vm, arg_p2p_external_port); m_allow_local_ip = command_line::get_arg(vm, arg_p2p_allow_local_ip); - m_no_igd = command_line::get_arg(vm, arg_no_igd); + const bool has_no_igd = command_line::get_arg(vm, arg_no_igd); + const std::string sigd = command_line::get_arg(vm, arg_igd); + if (sigd == "enabled") + { + if (has_no_igd) + { + MFATAL("Cannot have both --" << arg_no_igd.name << " and --" << arg_igd.name << " enabled"); + return false; + } + m_igd = igd; + } + else if (sigd == "disabled") + { + m_igd = no_igd; + } + else if (sigd == "delayed") + { + if (has_no_igd && !command_line::is_arg_defaulted(vm, arg_igd)) + { + MFATAL("Cannot have both --" << arg_no_igd.name << " and --" << arg_igd.name << " delayed"); + return false; + } + m_igd = has_no_igd ? no_igd : delayed_igd; + } + else + { + MFATAL("Invalid value for --" << arg_igd.name << ", expected enabled, disabled or delayed"); + return false; + } m_offline = command_line::get_arg(vm, cryptonote::arg_offline); if (command_line::has_arg(vm, arg_p2p_add_peer)) @@ -764,7 +793,7 @@ namespace nodetool MDEBUG("External port defined as " << m_external_port); // add UPnP port mapping - if(!m_no_igd) + if(m_igd == igd) add_upnp_port_mapping(m_listening_port); return res; @@ -858,7 +887,7 @@ namespace nodetool for(auto& zone : m_network_zones) zone.second.m_net_server.deinit_server(); // remove UPnP port mapping - if(!m_no_igd) + if(m_igd == igd) delete_upnp_port_mapping(m_listening_port); } return store_config(); @@ -1701,8 +1730,17 @@ namespace nodetool } else { - const el::Level level = el::Level::Warning; - MCLOG_RED(level, "global", "No incoming connections - check firewalls/routers allow port " << get_this_peer_port()); + if (m_igd == delayed_igd) + { + MWARNING("No incoming connections, trying to setup IGD"); + add_upnp_port_mapping(m_listening_port); + m_igd = igd; + } + else + { + const el::Level level = el::Level::Warning; + MCLOG_RED(level, "global", "No incoming connections - check firewalls/routers allow port " << get_this_peer_port()); + } } } return true; |