aboutsummaryrefslogtreecommitdiff
path: root/src/p2p
diff options
context:
space:
mode:
Diffstat (limited to 'src/p2p')
-rw-r--r--src/p2p/net_node.cpp65
-rw-r--r--src/p2p/net_node.h33
-rw-r--r--src/p2p/net_node.inl37
-rw-r--r--src/p2p/net_peerlist.h2
4 files changed, 90 insertions, 47 deletions
diff --git a/src/p2p/net_node.cpp b/src/p2p/net_node.cpp
new file mode 100644
index 000000000..4ea08a1f8
--- /dev/null
+++ b/src/p2p/net_node.cpp
@@ -0,0 +1,65 @@
+// Copyright (c) 2014-2017, The Monero Project
+//
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without modification, are
+// permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this list of
+// conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice, this list
+// of conditions and the following disclaimer in the documentation and/or other
+// materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its contributors may be
+// used to endorse or promote products derived from this software without specific
+// prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
+// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
+// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
+
+#include "common/command_line.h"
+#include "net_node.h"
+
+namespace nodetool
+{
+ const command_line::arg_descriptor<std::string> arg_p2p_bind_ip = {"p2p-bind-ip", "Interface for p2p network protocol", "0.0.0.0"};
+ const command_line::arg_descriptor<std::string> arg_p2p_bind_port = {
+ "p2p-bind-port"
+ , "Port for p2p network protocol"
+ , std::to_string(config::P2P_DEFAULT_PORT)
+ };
+ const command_line::arg_descriptor<std::string> 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<uint32_t> 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<bool> arg_p2p_allow_local_ip = {"allow-local-ip", "Allow local ip add to peer list, mostly in debug purposes"};
+ const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_peer = {"add-peer", "Manually add peer to local peerlist"};
+ const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_priority_node = {"add-priority-node", "Specify list of peers to connect to and attempt to keep the connection open"};
+ const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_exclusive_node = {"add-exclusive-node", "Specify list of peers to connect to only."
+ " If this option is given the options add-priority-node and seed-node are ignored"};
+ const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node = {"seed-node", "Connect to a node to retrieve peer addresses, and disconnect"};
+ const command_line::arg_descriptor<bool> arg_p2p_hide_my_port = {"hide-my-port", "Do not announce yourself as peerlist candidate", false, true};
+
+ const command_line::arg_descriptor<bool> arg_no_igd = {"no-igd", "Disable UPnP port mapping"};
+ const command_line::arg_descriptor<int64_t> arg_out_peers = {"out-peers", "set max number of out peers", -1};
+ const command_line::arg_descriptor<int> arg_tos_flag = {"tos-flag", "set TOS flag", -1};
+
+ const command_line::arg_descriptor<int64_t> arg_limit_rate_up = {"limit-rate-up", "set limit-rate-up [kB/s]", -1};
+ const command_line::arg_descriptor<int64_t> arg_limit_rate_down = {"limit-rate-down", "set limit-rate-down [kB/s]", -1};
+ const command_line::arg_descriptor<int64_t> arg_limit_rate = {"limit-rate", "set limit-rate [kB/s]", -1};
+
+ const command_line::arg_descriptor<bool> arg_save_graph = {"save-graph", "Save data for dr monero", false};
+}
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index 8bbaa9138..294ccde9e 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -30,13 +30,6 @@
#pragma once
#include <boost/thread.hpp>
-#include <boost/bind.hpp>
-#include <boost/bimap.hpp>
-#include <boost/multi_index_container.hpp>
-#include <boost/multi_index/ordered_index.hpp>
-#include <boost/multi_index/identity.hpp>
-#include <boost/multi_index/member.hpp>
-#include <boost/multi_index/global_fun.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
#include <boost/serialization/version.hpp>
@@ -335,8 +328,30 @@ namespace nodetool
bool m_testnet;
};
-}
-#include "net_node.inl"
+ const int64_t default_limit_up = 2048;
+ const int64_t default_limit_down = 8192;
+ extern const command_line::arg_descriptor<std::string> arg_p2p_bind_ip;
+ extern const command_line::arg_descriptor<std::string> arg_p2p_bind_port;
+ extern const command_line::arg_descriptor<std::string> arg_testnet_p2p_bind_port;
+ extern const command_line::arg_descriptor<uint32_t> arg_p2p_external_port;
+ extern const command_line::arg_descriptor<bool> arg_p2p_allow_local_ip;
+ extern const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_peer;
+ extern const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_priority_node;
+ extern const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_exclusive_node;
+ extern const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node;
+ extern const command_line::arg_descriptor<bool> arg_p2p_hide_my_port;
+
+ extern const command_line::arg_descriptor<bool> arg_no_igd;
+ extern const command_line::arg_descriptor<bool> arg_offline;
+ extern const command_line::arg_descriptor<int64_t> arg_out_peers;
+ extern const command_line::arg_descriptor<int> arg_tos_flag;
+
+ extern const command_line::arg_descriptor<int64_t> arg_limit_rate_up;
+ extern const command_line::arg_descriptor<int64_t> arg_limit_rate_down;
+ extern const command_line::arg_descriptor<int64_t> arg_limit_rate;
+
+ extern const command_line::arg_descriptor<bool> arg_save_graph;
+}
POP_WARNINGS
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index c6792f138..55be7c2cb 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -30,11 +30,10 @@
// IP blocking adapted from Boolberry
-#pragma once
-
#include <algorithm>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
#include <atomic>
#include "version.h"
@@ -70,40 +69,6 @@
namespace nodetool
{
- namespace
- {
- const int64_t default_limit_up = 2048; // kB/s
- const int64_t default_limit_down = 8192; // kB/s
- const command_line::arg_descriptor<std::string> arg_p2p_bind_ip = {"p2p-bind-ip", "Interface for p2p network protocol", "0.0.0.0"};
- const command_line::arg_descriptor<std::string> arg_p2p_bind_port = {
- "p2p-bind-port"
- , "Port for p2p network protocol"
- , std::to_string(config::P2P_DEFAULT_PORT)
- };
- const command_line::arg_descriptor<std::string> 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<uint32_t> 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<bool> arg_p2p_allow_local_ip = {"allow-local-ip", "Allow local ip add to peer list, mostly in debug purposes"};
- const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_peer = {"add-peer", "Manually add peer to local peerlist"};
- const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_priority_node = {"add-priority-node", "Specify list of peers to connect to and attempt to keep the connection open"};
- const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_add_exclusive_node = {"add-exclusive-node", "Specify list of peers to connect to only."
- " If this option is given the options add-priority-node and seed-node are ignored"};
- const command_line::arg_descriptor<std::vector<std::string> > arg_p2p_seed_node = {"seed-node", "Connect to a node to retrieve peer addresses, and disconnect"};
- const command_line::arg_descriptor<bool> arg_p2p_hide_my_port = {"hide-my-port", "Do not announce yourself as peerlist candidate", false, true};
-
- const command_line::arg_descriptor<bool> arg_no_igd = {"no-igd", "Disable UPnP port mapping"};
- const command_line::arg_descriptor<int64_t> arg_out_peers = {"out-peers", "set max number of out peers", -1};
- const command_line::arg_descriptor<int> arg_tos_flag = {"tos-flag", "set TOS flag", -1};
-
- const command_line::arg_descriptor<int64_t> arg_limit_rate_up = {"limit-rate-up", "set limit-rate-up [kB/s]", -1};
- const command_line::arg_descriptor<int64_t> arg_limit_rate_down = {"limit-rate-down", "set limit-rate-down [kB/s]", -1};
- const command_line::arg_descriptor<int64_t> arg_limit_rate = {"limit-rate", "set limit-rate [kB/s]", -1};
-
- const command_line::arg_descriptor<bool> arg_save_graph = {"save-graph", "Save data for dr monero", false};
- }
//-----------------------------------------------------------------------------------
template<class t_payload_net_handler>
void node_server<t_payload_net_handler>::init_options(boost::program_options::options_description& desc)
diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h
index 8372445aa..8216e9be6 100644
--- a/src/p2p/net_peerlist.h
+++ b/src/p2p/net_peerlist.h
@@ -33,8 +33,6 @@
#include <list>
#include <set>
#include <map>
-//#include <boost/bimap.hpp>
-//#include <boost/bimap/multiset_of.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/portable_binary_oarchive.hpp>
#include <boost/archive/portable_binary_iarchive.hpp>