aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
authorZachary Michaels <mikezackles@gmail.com>2014-07-16 13:30:15 -0400
committerRiccardo Spagni <ric@spagni.net>2014-09-15 15:53:01 +0200
commit07470fd400ee30b84f6227edffb24094d03781cb (patch)
tree6399848a2020528971884f5f625d0a2403f92327 /src/p2p
parentincrease ABSTRACT_SERVER_SEND_QUE_MAX_COUNT to a more sane value (diff)
downloadmonero-07470fd400ee30b84f6227edffb24094d03781cb.tar.xz
Add testnet flag
Source: cryptonotefoundation
Diffstat (limited to 'src/p2p')
-rw-r--r--src/p2p/net_node.h5
-rw-r--r--src/p2p/net_node.inl34
2 files changed, 22 insertions, 17 deletions
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index d7576d5dd..bca18c906 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -79,13 +79,13 @@ namespace nodetool
public:
typedef t_payload_net_handler payload_net_handler;
// Some code
- node_server(t_payload_net_handler& payload_handler):m_payload_handler(payload_handler), m_allow_local_ip(false), m_hide_my_port(false)
+ node_server(t_payload_net_handler& payload_handler):m_payload_handler(payload_handler), m_allow_local_ip(false), m_hide_my_port(false), m_network_id(MONERO_NETWORK)
{}
static void init_options(boost::program_options::options_description& desc);
bool run();
- bool init(const boost::program_options::variables_map& vm);
+ bool init(const boost::program_options::variables_map& vm, bool testnet);
bool deinit();
bool send_stop_signal();
uint32_t get_this_peer_port(){return m_listenning_port;}
@@ -229,6 +229,7 @@ namespace nodetool
uint64_t m_peer_livetime;
//keep connections to initiate some interactions
net_server m_net_server;
+ boost::uuids::uuid m_network_id;
};
}
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index ee401ce42..211f5064a 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -224,19 +224,23 @@ namespace nodetool
#define ADD_HARDCODED_SEED_NODE(addr) append_net_address(m_seed_nodes, addr);
//-----------------------------------------------------------------------------------
template<class t_payload_net_handler>
- bool node_server<t_payload_net_handler>::init(const boost::program_options::variables_map& vm)
+ bool node_server<t_payload_net_handler>::init(const boost::program_options::variables_map& vm, bool testnet)
{
- ADD_HARDCODED_SEED_NODE("62.210.78.186:18080");
- ADD_HARDCODED_SEED_NODE("195.12.60.154:18080");
- ADD_HARDCODED_SEED_NODE("54.241.246.125:18080");
- ADD_HARDCODED_SEED_NODE("107.170.157.169:18080");
- ADD_HARDCODED_SEED_NODE("54.207.112.216:18080");
- ADD_HARDCODED_SEED_NODE("78.27.112.54:18080");
- ADD_HARDCODED_SEED_NODE("209.222.30.57:18080");
- ADD_HARDCODED_SEED_NODE("80.71.13.55:18080");
- ADD_HARDCODED_SEED_NODE("107.178.112.126:18080");
- ADD_HARDCODED_SEED_NODE("107.158.233.98:18080");
- ADD_HARDCODED_SEED_NODE("64.22.111.2:18080");
+ if (!testnet) {
+ ADD_HARDCODED_SEED_NODE("62.210.78.186:18080");
+ ADD_HARDCODED_SEED_NODE("195.12.60.154:18080");
+ ADD_HARDCODED_SEED_NODE("54.241.246.125:18080");
+ ADD_HARDCODED_SEED_NODE("107.170.157.169:18080");
+ ADD_HARDCODED_SEED_NODE("54.207.112.216:18080");
+ ADD_HARDCODED_SEED_NODE("78.27.112.54:18080");
+ ADD_HARDCODED_SEED_NODE("209.222.30.57:18080");
+ ADD_HARDCODED_SEED_NODE("80.71.13.55:18080");
+ ADD_HARDCODED_SEED_NODE("107.178.112.126:18080");
+ ADD_HARDCODED_SEED_NODE("107.158.233.98:18080");
+ ADD_HARDCODED_SEED_NODE("64.22.111.2:18080");
+ } else {
+ m_network_id.data[0] += 1;
+ }
bool res = handle_command_line(vm);
CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line");
@@ -410,7 +414,7 @@ namespace nodetool
return;
}
- if(rsp.node_data.network_id != MONERO_NETWORK)
+ if(rsp.node_data.network_id != m_network_id)
{
LOG_ERROR_CCONTEXT("COMMAND_HANDSHAKE Failed, wrong network! (" << epee::string_tools::get_str_from_guid_a(rsp.node_data.network_id) << "), closing connection.");
return;
@@ -818,7 +822,7 @@ namespace nodetool
node_data.my_port = m_external_port ? m_external_port : m_listenning_port;
else
node_data.my_port = 0;
- node_data.network_id = MONERO_NETWORK;
+ node_data.network_id = m_network_id;
return true;
}
//-----------------------------------------------------------------------------------
@@ -1038,7 +1042,7 @@ namespace nodetool
template<class t_payload_net_handler>
int node_server<t_payload_net_handler>::handle_handshake(int command, typename COMMAND_HANDSHAKE::request& arg, typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context)
{
- if(arg.node_data.network_id != MONERO_NETWORK)
+ if(arg.node_data.network_id != m_network_id)
{
LOG_PRINT_CCONTEXT_L1("WRONG NETWORK AGENT CONNECTED! id=" << epee::string_tools::get_str_from_guid_a(arg.node_data.network_id));