aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.h4
-rw-r--r--contrib/epee/include/net/connection_basic.hpp (renamed from src/p2p/connection_basic.hpp)0
-rw-r--r--contrib/epee/include/net/network_throttle-detail.hpp (renamed from src/p2p/network_throttle-detail.hpp)4
-rw-r--r--contrib/epee/include/net/network_throttle.hpp (renamed from src/p2p/network_throttle.hpp)4
-rw-r--r--contrib/epee/src/CMakeLists.txt3
-rw-r--r--contrib/epee/src/connection_basic.cpp (renamed from src/p2p/connection_basic.cpp)4
-rw-r--r--contrib/epee/src/network_throttle-detail.cpp (renamed from src/p2p/network_throttle-detail.cpp)2
-rw-r--r--contrib/epee/src/network_throttle.cpp (renamed from src/p2p/network_throttle.cpp)2
-rw-r--r--src/cryptonote_core/cryptonote_core.cpp16
-rw-r--r--src/cryptonote_core/cryptonote_core.h3
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp2
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.h6
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl6
-rw-r--r--src/daemon/CMakeLists.txt1
-rw-r--r--src/daemon/core.h15
-rw-r--r--src/daemon/main.cpp1
-rw-r--r--src/debug_utilities/object_sizes.cpp2
-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
-rw-r--r--src/rpc/CMakeLists.txt24
-rw-r--r--src/rpc/core_rpc_server.cpp2
-rw-r--r--src/rpc/instanciations.cpp37
-rw-r--r--src/simplewallet/CMakeLists.txt2
-rw-r--r--src/wallet/CMakeLists.txt2
-rw-r--r--tests/core_proxy/core_proxy.cpp2
-rw-r--r--tests/core_tests/chaingen.h2
-rw-r--r--tests/unit_tests/ban.cpp5
-rw-r--r--tests/unit_tests/main.cpp7
30 files changed, 206 insertions, 89 deletions
diff --git a/contrib/epee/include/net/abstract_tcp_server2.h b/contrib/epee/include/net/abstract_tcp_server2.h
index 33fec8ec5..c0401c8b0 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.h
+++ b/contrib/epee/include/net/abstract_tcp_server2.h
@@ -54,8 +54,8 @@
#include <boost/thread/thread.hpp>
#include "net_utils_base.h"
#include "syncobj.h"
-#include "../../../../src/p2p/connection_basic.hpp"
-#include "../../../../src/p2p/network_throttle-detail.hpp"
+#include "connection_basic.hpp"
+#include "network_throttle-detail.hpp"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net"
diff --git a/src/p2p/connection_basic.hpp b/contrib/epee/include/net/connection_basic.hpp
index 16de469a7..16de469a7 100644
--- a/src/p2p/connection_basic.hpp
+++ b/contrib/epee/include/net/connection_basic.hpp
diff --git a/src/p2p/network_throttle-detail.hpp b/contrib/epee/include/net/network_throttle-detail.hpp
index 676d4341a..dba15a5ed 100644
--- a/src/p2p/network_throttle-detail.hpp
+++ b/contrib/epee/include/net/network_throttle-detail.hpp
@@ -33,8 +33,8 @@
/* rfree: throttle details, implementing rate limiting */
-#ifndef INCLUDED_src_p2p_throttle_detail_hpp
-#define INCLUDED_src_p2p_throttle_detail_hpp
+#ifndef INCLUDED_throttle_detail_hpp
+#define INCLUDED_throttle_detail_hpp
#include "network_throttle.hpp"
diff --git a/src/p2p/network_throttle.hpp b/contrib/epee/include/net/network_throttle.hpp
index bf1f93859..464b34726 100644
--- a/src/p2p/network_throttle.hpp
+++ b/contrib/epee/include/net/network_throttle.hpp
@@ -34,8 +34,8 @@
/* rfree: also includes the manager for singeton/global such objects */
-#ifndef INCLUDED_p2p_network_throttle_hpp
-#define INCLUDED_p2p_network_throttle_hpp
+#ifndef INCLUDED_network_throttle_hpp
+#define INCLUDED_network_throttle_hpp
#include <boost/asio.hpp>
#include <string>
diff --git a/contrib/epee/src/CMakeLists.txt b/contrib/epee/src/CMakeLists.txt
index 5cd6d7813..b6967e8fc 100644
--- a/contrib/epee/src/CMakeLists.txt
+++ b/contrib/epee/src/CMakeLists.txt
@@ -26,7 +26,8 @@
# 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.
-add_library(epee STATIC hex.cpp http_auth.cpp mlog.cpp net_utils_base.cpp string_tools.cpp wipeable_string.cpp)
+add_library(epee STATIC hex.cpp http_auth.cpp mlog.cpp net_utils_base.cpp string_tools.cpp wipeable_string.cpp
+ connection_basic.cpp network_throttle.cpp network_throttle-detail.cpp)
if (USE_READLINE AND GNU_READLINE_FOUND)
add_library(epee_readline STATIC readline_buffer.cpp)
endif()
diff --git a/src/p2p/connection_basic.cpp b/contrib/epee/src/connection_basic.cpp
index 06baa7893..534044a79 100644
--- a/src/p2p/connection_basic.cpp
+++ b/contrib/epee/src/connection_basic.cpp
@@ -32,7 +32,7 @@
/* rfree: implementation for the non-template base, can be used by connection<> template class in abstract_tcp_server2 file */
-#include "connection_basic.hpp"
+#include "net/connection_basic.hpp"
#include <boost/asio.hpp>
#include <string>
@@ -77,7 +77,7 @@
#include "net/abstract_tcp_server2.h"
// TODO:
-#include "network_throttle-detail.hpp"
+#include "net/network_throttle-detail.hpp"
#include "cryptonote_core/cryptonote_core.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
diff --git a/src/p2p/network_throttle-detail.cpp b/contrib/epee/src/network_throttle-detail.cpp
index 651e01e6b..317dde8e0 100644
--- a/src/p2p/network_throttle-detail.cpp
+++ b/contrib/epee/src/network_throttle-detail.cpp
@@ -74,7 +74,7 @@
#include "net/abstract_tcp_server2.h"
// TODO:
-#include "network_throttle-detail.hpp"
+#include "net/network_throttle-detail.hpp"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.throttle"
diff --git a/src/p2p/network_throttle.cpp b/contrib/epee/src/network_throttle.cpp
index 74b20376d..afacc3e96 100644
--- a/src/p2p/network_throttle.cpp
+++ b/contrib/epee/src/network_throttle.cpp
@@ -54,7 +54,7 @@ Throttling work by:
// 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.
-#include "network_throttle-detail.hpp"
+#include "net/network_throttle-detail.hpp"
namespace epee
{
diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp
index 8985c11ca..960a07832 100644
--- a/src/cryptonote_core/cryptonote_core.cpp
+++ b/src/cryptonote_core/cryptonote_core.cpp
@@ -48,11 +48,11 @@ using namespace epee;
#include "cryptonote_tx_utils.h"
#include "misc_language.h"
#include <csignal>
-#include <p2p/net_node.h>
#include "checkpoints/checkpoints.h"
#include "ringct/rctTypes.h"
#include "blockchain_db/blockchain_db.h"
#include "ringct/rctSigs.h"
+#include "version.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "cn"
@@ -236,10 +236,6 @@ namespace cryptonote
command_line::add_arg(desc, arg_test_dbg_lock_sleep);
command_line::add_arg(desc, arg_offline);
- // we now also need some of net_node's options (p2p bind arg, for separate data dir)
- command_line::add_arg(desc, nodetool::arg_testnet_p2p_bind_port, false);
- command_line::add_arg(desc, nodetool::arg_p2p_bind_port, false);
-
miner::init_options(desc);
BlockchainDB::init_options(desc);
}
@@ -338,21 +334,17 @@ namespace cryptonote
return m_blockchain_storage.get_alternative_blocks_count();
}
//-----------------------------------------------------------------------------------------------
- bool core::init(const boost::program_options::variables_map& vm, const cryptonote::test_options *test_options)
+ bool core::init(const boost::program_options::variables_map& vm, const char *config_subdir, const cryptonote::test_options *test_options)
{
start_time = std::time(nullptr);
m_fakechain = test_options != NULL;
bool r = handle_command_line(vm);
bool testnet = command_line::get_arg(vm, arg_testnet_on);
- auto p2p_bind_arg = testnet ? nodetool::arg_testnet_p2p_bind_port : nodetool::arg_p2p_bind_port;
- std::string m_port = command_line::get_arg(vm, p2p_bind_arg);
std::string m_config_folder_mempool = m_config_folder;
- if ((!testnet && m_port != std::to_string(::config::P2P_DEFAULT_PORT))
- || (testnet && m_port != std::to_string(::config::testnet::P2P_DEFAULT_PORT))) {
- m_config_folder_mempool = m_config_folder_mempool + "/" + m_port;
- }
+ if (config_subdir)
+ m_config_folder_mempool = m_config_folder_mempool + "/" + config_subdir;
std::string db_type = command_line::get_arg(vm, cryptonote::arg_db_type);
std::string db_sync_mode = command_line::get_arg(vm, cryptonote::arg_db_sync_mode);
diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h
index 1b60f83f0..9f84ed303 100644
--- a/src/cryptonote_core/cryptonote_core.h
+++ b/src/cryptonote_core/cryptonote_core.h
@@ -241,11 +241,12 @@ namespace cryptonote
* a miner instance with parameters given on the command line (or defaults)
*
* @param vm command line parameters
+ * @param config_subdir subdirectory for config storage
* @param test_options configuration options for testing
*
* @return false if one of the init steps fails, otherwise true
*/
- bool init(const boost::program_options::variables_map& vm, const test_options *test_options = NULL);
+ bool init(const boost::program_options::variables_map& vm, const char *config_subdir = NULL, const test_options *test_options = NULL);
/**
* @copydoc Blockchain::reset_and_set_genesis_block
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp b/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp
index 094e4fc95..578abd20c 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler-base.cpp
@@ -70,7 +70,7 @@
#include <boost/asio/ip/unicast.hpp>
#include "cryptonote_protocol_handler.h"
-#include "p2p/network_throttle.hpp"
+#include "net/network_throttle.hpp"
#include "cryptonote_core/cryptonote_core.h" // e.g. for the send_stop_signal()
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.h b/src/cryptonote_protocol/cryptonote_protocol_handler.h
index d54687e6a..f61caf69b 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.h
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.h
@@ -36,7 +36,6 @@
#include <boost/program_options/variables_map.hpp>
#include <string>
-#include <ctime>
#include "math_helper.h"
#include "storages/levin_abstract_invoke2.h"
@@ -46,8 +45,6 @@
#include "block_queue.h"
#include "cryptonote_basic/connection_context.h"
#include "cryptonote_basic/cryptonote_stat_info.h"
-#include "cryptonote_basic/verification_context.h"
-// #include <netinet/in.h>
#include <boost/circular_buffer.hpp>
PUSH_WARNINGS
@@ -173,7 +170,4 @@ namespace cryptonote
} // namespace
-
-#include "cryptonote_protocol_handler.inl"
-
POP_WARNINGS
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index 48ab1eadf..389e8ba84 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -37,11 +37,11 @@
#include <boost/interprocess/detail/atomic.hpp>
#include <list>
-#include <unordered_map>
+#include <ctime>
#include "cryptonote_basic/cryptonote_format_utils.h"
#include "profile_tools.h"
-#include "p2p/network_throttle-detail.hpp"
+#include "net/network_throttle-detail.hpp"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "net.cn"
@@ -1561,7 +1561,7 @@ skip:
size_t t_cryptonote_protocol_handler<t_core>::get_synchronizing_connections_count()
{
size_t count = 0;
- m_p2p->for_each_connection([&](cryptonote_connection_context& context, nodetool::peerid_type peer_id)->bool{
+ m_p2p->for_each_connection([&](cryptonote_connection_context& context, nodetool::peerid_type peer_id, uint32_t support_flags)->bool{
if(context.m_state == cryptonote_connection_context::state_synchronizing)
++count;
return true;
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt
index c8b5abec5..ad84db450 100644
--- a/src/daemon/CMakeLists.txt
+++ b/src/daemon/CMakeLists.txt
@@ -66,7 +66,6 @@ set(daemon_private_headers
# p2p
../p2p/net_node.h
- ../p2p/net_node.inl
../p2p/net_node_common.h
../p2p/net_peerlist.h
../p2p/net_peerlist_boost_serialization.h
diff --git a/src/daemon/core.h b/src/daemon/core.h
index 9e6ff5e29..97f1cb8c1 100644
--- a/src/daemon/core.h
+++ b/src/daemon/core.h
@@ -67,11 +67,24 @@ public:
m_core.set_cryptonote_protocol(&protocol);
}
+ std::string get_config_subdir() const
+ {
+ bool testnet = command_line::get_arg(m_vm_HACK, cryptonote::arg_testnet_on);
+ auto p2p_bind_arg = testnet ? nodetool::arg_testnet_p2p_bind_port : nodetool::arg_p2p_bind_port;
+ std::string port = command_line::get_arg(m_vm_HACK, p2p_bind_arg);
+ if ((!testnet && port != std::to_string(::config::P2P_DEFAULT_PORT))
+ || (testnet && port != std::to_string(::config::testnet::P2P_DEFAULT_PORT))) {
+ return port;
+ }
+ return std::string();
+ }
+
bool run()
{
//initialize core here
MGINFO("Initializing core...");
- if (!m_core.init(m_vm_HACK))
+ std::string config_subdir = get_config_subdir();
+ if (!m_core.init(m_vm_HACK, config_subdir.empty() ? NULL : config_subdir.c_str()))
{
return false;
}
diff --git a/src/daemon/main.cpp b/src/daemon/main.cpp
index d038cc825..6ac47fcb2 100644
--- a/src/daemon/main.cpp
+++ b/src/daemon/main.cpp
@@ -44,6 +44,7 @@
#include "rpc/rpc_args.h"
#include "daemon/command_line_args.h"
#include "blockchain_db/db_types.h"
+#include "version.h"
#ifdef STACK_TRACE
#include "common/stack_trace.h"
diff --git a/src/debug_utilities/object_sizes.cpp b/src/debug_utilities/object_sizes.cpp
index e58da7395..82d8a4add 100644
--- a/src/debug_utilities/object_sizes.cpp
+++ b/src/debug_utilities/object_sizes.cpp
@@ -31,7 +31,7 @@
#include "cryptonote_basic/tx_extra.h"
#include "cryptonote_core/blockchain.h"
#include "p2p/p2p_protocol_defs.h"
-#include "p2p/connection_basic.hpp"
+#include "net/connection_basic.hpp"
#include "p2p/net_peerlist.h"
#include "p2p/net_node.h"
#include "cryptonote_protocol/cryptonote_protocol_handler.h"
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>
diff --git a/src/rpc/CMakeLists.txt b/src/rpc/CMakeLists.txt
index 23bb6aaae..748c6b8c1 100644
--- a/src/rpc/CMakeLists.txt
+++ b/src/rpc/CMakeLists.txt
@@ -26,9 +26,12 @@
# 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.
+set(rpc_base_sources
+ rpc_args.cpp)
+
set(rpc_sources
core_rpc_server.cpp
- rpc_args.cpp)
+ instanciations)
set(daemon_messages_sources
message.cpp
@@ -39,9 +42,11 @@ set(daemon_rpc_server_sources
zmq_server.cpp)
-set(rpc_headers
+set(rpc_base_headers
rpc_args.h)
+set(rpc_headers)
+
set(daemon_rpc_server_headers)
@@ -69,6 +74,11 @@ monero_private_headers(daemon_rpc_server
${daemon_rpc_server_private_headers})
+monero_add_library(rpc_base
+ ${rpc_base_sources}
+ ${rpc_base_headers}
+ ${rpc_base_private_headers})
+
monero_add_library(rpc
${rpc_sources}
${rpc_headers}
@@ -85,8 +95,18 @@ monero_add_library(daemon_rpc_server
${daemon_rpc_server_private_headers})
+target_link_libraries(rpc_base
+ PUBLIC
+ common
+ epee
+ ${Boost_REGEX_LIBRARY}
+ ${Boost_THREAD_LIBRARY}
+ PRIVATE
+ ${EXTRA_LIBRARIES})
+
target_link_libraries(rpc
PUBLIC
+ rpc_base
common
cryptonote_core
cryptonote_protocol
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 8abca43e4..803588cbd 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -45,6 +45,8 @@ using namespace epee;
#include "crypto/hash.h"
#include "rpc/rpc_args.h"
#include "core_rpc_server_error_codes.h"
+#include "p2p/net_node.h"
+#include "version.h"
#undef MONERO_DEFAULT_LOG_CATEGORY
#define MONERO_DEFAULT_LOG_CATEGORY "daemon.rpc"
diff --git a/src/rpc/instanciations.cpp b/src/rpc/instanciations.cpp
new file mode 100644
index 000000000..ac521247e
--- /dev/null
+++ b/src/rpc/instanciations.cpp
@@ -0,0 +1,37 @@
+// Copyright (c) 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 "p2p/net_node.h"
+#include "p2p/net_node.inl"
+#include "cryptonote_protocol/cryptonote_protocol_handler.h"
+#include "cryptonote_protocol/cryptonote_protocol_handler.inl"
+
+namespace nodetool { template class node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core>>; }
+namespace cryptonote { template class t_cryptonote_protocol_handler<cryptonote::core>; }
diff --git a/src/simplewallet/CMakeLists.txt b/src/simplewallet/CMakeLists.txt
index 3ff4466fc..beaacf0e9 100644
--- a/src/simplewallet/CMakeLists.txt
+++ b/src/simplewallet/CMakeLists.txt
@@ -43,7 +43,7 @@ monero_add_executable(simplewallet
target_link_libraries(simplewallet
PRIVATE
wallet
- rpc
+ rpc_base
cryptonote_core
cncrypto
common
diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt
index 74992139d..ab48bd7a2 100644
--- a/src/wallet/CMakeLists.txt
+++ b/src/wallet/CMakeLists.txt
@@ -82,7 +82,7 @@ target_link_libraries(wallet_rpc_server
PRIVATE
wallet
epee
- rpc
+ rpc_base
cryptonote_core
cncrypto
common
diff --git a/tests/core_proxy/core_proxy.cpp b/tests/core_proxy/core_proxy.cpp
index fd07a5d2e..d6c89fc39 100644
--- a/tests/core_proxy/core_proxy.cpp
+++ b/tests/core_proxy/core_proxy.cpp
@@ -42,8 +42,10 @@
#include "common/command_line.h"
#include "console_handler.h"
#include "p2p/net_node.h"
+#include "p2p/net_node.inl"
//#include "cryptonote_core/cryptonote_core.h"
#include "cryptonote_protocol/cryptonote_protocol_handler.h"
+#include "cryptonote_protocol/cryptonote_protocol_handler.inl"
#include "core_proxy.h"
#include "version.h"
diff --git a/tests/core_tests/chaingen.h b/tests/core_tests/chaingen.h
index 7cad04047..0dcbc7f0c 100644
--- a/tests/core_tests/chaingen.h
+++ b/tests/core_tests/chaingen.h
@@ -467,7 +467,7 @@ inline bool do_replay_events(std::vector<test_event_entry>& events)
// FIXME: make sure that vm has arg_testnet_on set to true or false if
// this test needs for it to be so.
get_test_options<t_test_class> gto;
- if (!c.init(vm, &gto.test_options))
+ if (!c.init(vm, NULL, &gto.test_options))
{
MERROR("Failed to init core");
return false;
diff --git a/tests/unit_tests/ban.cpp b/tests/unit_tests/ban.cpp
index 242e5fe1c..5af514643 100644
--- a/tests/unit_tests/ban.cpp
+++ b/tests/unit_tests/ban.cpp
@@ -31,7 +31,9 @@
#include "gtest/gtest.h"
#include "cryptonote_core/cryptonote_core.h"
#include "p2p/net_node.h"
+#include "p2p/net_node.inl"
#include "cryptonote_protocol/cryptonote_protocol_handler.h"
+#include "cryptonote_protocol/cryptonote_protocol_handler.inl"
#define MAKE_IPV4_ADDRESS(a,b,c,d) epee::net_utils::ipv4_network_address{MAKE_IP(a,b,c,d),0}
@@ -79,6 +81,7 @@ public:
cryptonote::difficulty_type get_block_cumulative_difficulty(uint64_t height) const { return 0; }
bool fluffy_blocks_enabled() const { return false; }
uint64_t prevalidate_block_hashes(uint64_t height, const std::list<crypto::hash> &hashes) { return 0; }
+ void stop() {}
};
typedef nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<test_core>> Server;
@@ -184,3 +187,5 @@ TEST(ban, add)
ASSERT_TRUE(t >= 4);
}
+namespace nodetool { template class node_server<cryptonote::t_cryptonote_protocol_handler<test_core>>; }
+namespace cryptonote { template class t_cryptonote_protocol_handler<test_core>; }
diff --git a/tests/unit_tests/main.cpp b/tests/unit_tests/main.cpp
index c0e143551..073ac20fd 100644
--- a/tests/unit_tests/main.cpp
+++ b/tests/unit_tests/main.cpp
@@ -34,6 +34,10 @@
#include <boost/filesystem/operations.hpp>
#include <boost/program_options.hpp>
+#include "p2p/net_node.h"
+#include "p2p/net_node.inl"
+#include "cryptonote_protocol/cryptonote_protocol_handler.h"
+#include "cryptonote_protocol/cryptonote_protocol_handler.inl"
#include "include_base_utils.h"
#include "string_tools.h"
#include "common/command_line.h"
@@ -44,6 +48,9 @@ namespace po = boost::program_options;
boost::filesystem::path unit_test::data_dir;
+namespace nodetool { template class node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core>>; }
+namespace cryptonote { template class t_cryptonote_protocol_handler<cryptonote::core>; }
+
int main(int argc, char** argv)
{
tools::on_startup();