aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
Diffstat (limited to 'src/p2p')
-rw-r--r--src/p2p/net_node.h3
-rw-r--r--src/p2p/net_node.inl27
2 files changed, 27 insertions, 3 deletions
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index 4606f66ee..90e2f78b1 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -244,6 +244,7 @@ namespace nodetool
bool check_connection_and_handshake_with_peer(const epee::net_utils::network_address& na, uint64_t last_seen_stamp);
bool gray_peerlist_housekeeping();
+ bool check_incoming_connections();
void kill() { ///< will be called e.g. from deinit()
_info("Killing the net_node");
@@ -307,6 +308,7 @@ namespace nodetool
epee::math_helper::once_a_time_seconds<1> m_connections_maker_interval;
epee::math_helper::once_a_time_seconds<60*30, false> m_peerlist_store_interval;
epee::math_helper::once_a_time_seconds<60> m_gray_peerlist_housekeeping_interval;
+ epee::math_helper::once_a_time_seconds<900, false> m_incoming_connections_interval;
std::string m_bind_ip;
std::string m_port;
@@ -316,6 +318,7 @@ namespace nodetool
std::list<epee::net_utils::network_address> m_priority_peers;
std::vector<epee::net_utils::network_address> m_exclusive_peers;
std::vector<epee::net_utils::network_address> m_seed_nodes;
+ bool m_fallback_seed_nodes_added;
std::list<nodetool::peerlist_entry> m_command_line_peers;
uint64_t m_peer_livetime;
//keep connections to initiate some interactions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 9b21705ec..5b65ba4d2 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -405,6 +405,7 @@ namespace nodetool
bool res = handle_command_line(vm);
CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line");
+ m_fallback_seed_nodes_added = false;
if (m_nettype == cryptonote::TESTNET)
{
memcpy(&m_network_id, &::config::testnet::NETWORK_ID, 16);
@@ -498,6 +499,7 @@ namespace nodetool
for (const auto &peer: get_seed_nodes(cryptonote::MAINNET))
full_addrs.insert(peer);
+ m_fallback_seed_nodes_added = true;
}
}
}
@@ -1134,7 +1136,6 @@ namespace nodetool
size_t try_count = 0;
size_t current_index = crypto::rand<size_t>()%m_seed_nodes.size();
- bool fallback_nodes_added = false;
while(true)
{
if(m_net_server.is_stop_signal_sent())
@@ -1144,15 +1145,21 @@ namespace nodetool
break;
if(++try_count > m_seed_nodes.size())
{
- if (!fallback_nodes_added)
+ if (!m_fallback_seed_nodes_added)
{
MWARNING("Failed to connect to any of seed peers, trying fallback seeds");
+ current_index = m_seed_nodes.size();
for (const auto &peer: get_seed_nodes(m_nettype))
{
MDEBUG("Fallback seed node: " << peer);
append_net_address(m_seed_nodes, peer);
}
- fallback_nodes_added = true;
+ m_fallback_seed_nodes_added = true;
+ if (current_index == m_seed_nodes.size())
+ {
+ MWARNING("No fallback seeds, continuing without seeds");
+ break;
+ }
// continue for another few cycles
}
else
@@ -1293,6 +1300,20 @@ namespace nodetool
m_connections_maker_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::connections_maker, this));
m_gray_peerlist_housekeeping_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::gray_peerlist_housekeeping, this));
m_peerlist_store_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::store_config, this));
+ m_incoming_connections_interval.do_call(boost::bind(&node_server<t_payload_net_handler>::check_incoming_connections, this));
+ return true;
+ }
+ //-----------------------------------------------------------------------------------
+ template<class t_payload_net_handler>
+ bool node_server<t_payload_net_handler>::check_incoming_connections()
+ {
+ if (m_offline || m_hide_my_port)
+ return true;
+ if (get_incoming_connections_count() == 0)
+ {
+ 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;
}
//-----------------------------------------------------------------------------------