From 98ed9a41f7bf0d904e257372f4561aea3ad12c18 Mon Sep 17 00:00:00 2001 From: Zachary Michaels Date: Mon, 8 Sep 2014 12:51:04 -0400 Subject: [PATCH] Separate p2p port for testnet --- src/p2p/net_node.h | 5 ++++- src/p2p/net_node.inl | 23 +++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index 3a659dcd8..7030d93f7 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -149,7 +149,10 @@ namespace nodetool virtual void for_each_connection(std::function f); //----------------------------------------------------------------------------------------------- bool parse_peer_from_string(nodetool::net_address& pe, const std::string& node_addr); - bool handle_command_line(const boost::program_options::variables_map& vm); + bool handle_command_line( + const boost::program_options::variables_map& vm + , bool testnet + ); bool idle_worker(); bool handle_remote_peerlist(const std::list& peerlist, time_t local_time, const epee::net_utils::connection_context_base& context); bool get_local_node_data(basic_node_data& node_data); diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 28c572513..753af7321 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -60,7 +60,16 @@ namespace nodetool namespace { const command_line::arg_descriptor arg_p2p_bind_ip = {"p2p-bind-ip", "Interface for p2p network protocol", "0.0.0.0"}; - const command_line::arg_descriptor arg_p2p_bind_port = {"p2p-bind-port", "Port for p2p network protocol", boost::to_string(config::P2P_DEFAULT_PORT)}; + const command_line::arg_descriptor arg_p2p_bind_port = { + "p2p-bind-port" + , "Port for p2p network protocol" + , std::to_string(config::P2P_DEFAULT_PORT) + }; + const command_line::arg_descriptor arg_testnet_p2p_bind_port = { + "testnet-p2p-bind-port" + , "Port for testnet p2p network protocol" + , std::to_string(config::testnet::P2P_DEFAULT_PORT) + }; const command_line::arg_descriptor arg_p2p_external_port = {"p2p-external-port", "External port for p2p network protocol (if port forwarding used with NAT)", 0}; const command_line::arg_descriptor arg_p2p_allow_local_ip = {"allow-local-ip", "Allow local ip add to peer list, mostly in debug purposes"}; const command_line::arg_descriptor > arg_p2p_add_peer = {"add-peer", "Manually add peer to local peerlist"}; @@ -77,6 +86,7 @@ namespace nodetool { command_line::add_arg(desc, arg_p2p_bind_ip); command_line::add_arg(desc, arg_p2p_bind_port); + command_line::add_arg(desc, arg_testnet_p2p_bind_port); command_line::add_arg(desc, arg_p2p_external_port); command_line::add_arg(desc, arg_p2p_allow_local_ip); command_line::add_arg(desc, arg_p2p_add_peer); @@ -138,10 +148,15 @@ namespace nodetool } //----------------------------------------------------------------------------------- template - bool node_server::handle_command_line(const boost::program_options::variables_map& vm) + bool node_server::handle_command_line( + const boost::program_options::variables_map& vm + , bool testnet + ) { + auto p2p_bind_arg = testnet ? arg_testnet_p2p_bind_port : arg_p2p_bind_port; + m_bind_ip = command_line::get_arg(vm, arg_p2p_bind_ip); - m_port = command_line::get_arg(vm, arg_p2p_bind_port); + m_port = command_line::get_arg(vm, p2p_bind_arg); 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); @@ -242,7 +257,7 @@ namespace nodetool m_network_id.data[0] += 1; } - bool res = handle_command_line(vm); + bool res = handle_command_line(vm, testnet); CHECK_AND_ASSERT_MES(res, false, "Failed to handle command line"); m_config_folder = command_line::get_arg(vm, command_line::arg_data_dir);