aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
Diffstat (limited to 'src/p2p')
-rw-r--r--src/p2p/net_node.h7
-rw-r--r--src/p2p/net_node.inl55
-rw-r--r--src/p2p/net_peerlist.h4
-rw-r--r--src/p2p/p2p_protocol_defs.h2
4 files changed, 48 insertions, 20 deletions
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index 759b21fcf..53a13f327 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -112,6 +112,13 @@ namespace nodetool
size_t get_outgoing_connections_count();
peerlist_manager& get_peerlist_manager(){return m_peerlist;}
private:
+ const std::vector<std::string> m_seed_nodes_list =
+ { "seeds.moneroseeds.se"
+ , "seeds.moneroseeds.ae.org"
+ , "seeds.moneroseeds.ch"
+ , "seeds.moneroseeds.li"
+ };
+
typedef COMMAND_REQUEST_STAT_INFO_T<typename t_payload_net_handler::stat_info> COMMAND_REQUEST_STAT_INFO;
CHAIN_LEVIN_INVOKE_MAP2(p2p_connection_context); //move levin_commands_handler interface invoke(...) callbacks into invoke map
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 870e7572e..08fd1d1e6 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -35,6 +35,7 @@
#include "version.h"
#include "string_tools.h"
#include "common/util.h"
+#include "common/dns_utils.h"
#include "net/net_helper.h"
#include "math_helper.h"
#include "p2p_protocol_defs.h"
@@ -195,7 +196,7 @@ namespace nodetool
return true;
}
//-----------------------------------------------------------------------------------
- inline void add_hardcoded_seed_node(
+ inline void append_net_address(
std::vector<net_address> & seed_nodes
, std::string const & addr
)
@@ -239,23 +240,39 @@ namespace nodetool
{
if (testnet)
{
- add_hardcoded_seed_node(m_seed_nodes, "107.152.187.202:28080");
- add_hardcoded_seed_node(m_seed_nodes, "197.242.158.240:28080");
- add_hardcoded_seed_node(m_seed_nodes, "107.152.130.98:28080");
+ append_net_address(m_seed_nodes, "107.152.187.202:28080");
+ append_net_address(m_seed_nodes, "197.242.158.240:28080");
+ append_net_address(m_seed_nodes, "107.152.130.98:28080");
}
else
{
- add_hardcoded_seed_node(m_seed_nodes, "62.210.78.186:18080");
- add_hardcoded_seed_node(m_seed_nodes, "195.12.60.154:18080");
- add_hardcoded_seed_node(m_seed_nodes, "54.241.246.125:18080");
- add_hardcoded_seed_node(m_seed_nodes, "107.170.157.169:18080");
- add_hardcoded_seed_node(m_seed_nodes, "54.207.112.216:18080");
- add_hardcoded_seed_node(m_seed_nodes, "78.27.112.54:18080");
- add_hardcoded_seed_node(m_seed_nodes, "209.222.30.57:18080");
- add_hardcoded_seed_node(m_seed_nodes, "80.71.13.55:18080");
- add_hardcoded_seed_node(m_seed_nodes, "107.178.112.126:18080");
- add_hardcoded_seed_node(m_seed_nodes, "107.158.233.98:18080");
- add_hardcoded_seed_node(m_seed_nodes, "64.22.111.2:18080");
+ // for each hostname in the seed nodes list, attempt to DNS resolve and
+ // add the result addresses as seed nodes
+ // TODO: at some point add IPv6 support, but that won't be relevant
+ // 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);
+ for (const std::string& a : addr_list)
+ {
+ append_net_address(m_seed_nodes, a + ":18080");
+ }
+ }
+
+ if (!m_seed_nodes.size())
+ {
+ append_net_address(m_seed_nodes, "62.210.78.186:18080");
+ append_net_address(m_seed_nodes, "195.12.60.154:18080");
+ append_net_address(m_seed_nodes, "54.241.246.125:18080");
+ append_net_address(m_seed_nodes, "107.170.157.169:18080");
+ append_net_address(m_seed_nodes, "54.207.112.216:18080");
+ append_net_address(m_seed_nodes, "78.27.112.54:18080");
+ append_net_address(m_seed_nodes, "209.222.30.57:18080");
+ append_net_address(m_seed_nodes, "80.71.13.55:18080");
+ append_net_address(m_seed_nodes, "107.178.112.126:18080");
+ append_net_address(m_seed_nodes, "107.158.233.98:18080");
+ append_net_address(m_seed_nodes, "64.22.111.2:18080");
+ }
}
bool res = handle_command_line(vm, testnet);
@@ -624,7 +641,9 @@ namespace nodetool
peerlist_entry pe_local = AUTO_VAL_INIT(pe_local);
pe_local.adr = na;
pe_local.id = pi;
- time(&pe_local.last_seen);
+ time_t last_seen;
+ time(&last_seen);
+ pe_local.last_seen = static_cast<int64_t>(last_seen);
m_peerlist.append_with_peer_white(pe_local);
//update last seen and push it to peerlist manager
@@ -1102,7 +1121,9 @@ namespace nodetool
peerlist_entry pe;
pe.adr.ip = context.m_remote_ip;
pe.adr.port = port_l;
- time(&pe.last_seen);
+ time_t last_seen;
+ time(&last_seen);
+ pe.last_seen = static_cast<int64_t>(last_seen);
pe.id = peer_id_l;
this->m_peerlist.append_with_peer_white(pe);
LOG_PRINT_CCONTEXT_L2("PING SUCCESS " << epee::string_tools::get_ip_string_from_int32(context.m_remote_ip) << ":" << port_l);
diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h
index b02326905..e3e387bbc 100644
--- a/src/p2p/net_peerlist.h
+++ b/src/p2p/net_peerlist.h
@@ -128,7 +128,7 @@ namespace nodetool
// access by peerlist_entry::net_adress
boost::multi_index::ordered_unique<boost::multi_index::tag<by_addr>, boost::multi_index::member<peerlist_entry,net_address,&peerlist_entry::adr> >,
// sort by peerlist_entry::last_seen<
- boost::multi_index::ordered_non_unique<boost::multi_index::tag<by_time>, boost::multi_index::member<peerlist_entry,time_t,&peerlist_entry::last_seen> >
+ boost::multi_index::ordered_non_unique<boost::multi_index::tag<by_time>, boost::multi_index::member<peerlist_entry,int64_t,&peerlist_entry::last_seen> >
>
> peers_indexed;
@@ -140,7 +140,7 @@ namespace nodetool
// access by peerlist_entry::net_adress
boost::multi_index::ordered_unique<boost::multi_index::tag<by_addr>, boost::multi_index::member<peerlist_entry,net_address,&peerlist_entry::adr> >,
// sort by peerlist_entry::last_seen<
- boost::multi_index::ordered_non_unique<boost::multi_index::tag<by_time>, boost::multi_index::member<peerlist_entry,time_t,&peerlist_entry::last_seen> >
+ boost::multi_index::ordered_non_unique<boost::multi_index::tag<by_time>, boost::multi_index::member<peerlist_entry,int64_t,&peerlist_entry::last_seen> >
>
> peers_indexed_old;
public:
diff --git a/src/p2p/p2p_protocol_defs.h b/src/p2p/p2p_protocol_defs.h
index a14d00dcd..44b8c5b50 100644
--- a/src/p2p/p2p_protocol_defs.h
+++ b/src/p2p/p2p_protocol_defs.h
@@ -53,7 +53,7 @@ namespace nodetool
{
net_address adr;
peerid_type id;
- time_t last_seen;
+ int64_t last_seen;
};
struct connection_entry