aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-07 20:21:45 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-07 20:21:45 +0000
commit2c83055597e01491b6dffc195dd9e6fe559f0bf7 (patch)
treef706256b834588f90f39608bfc21e77ff766b2c6 /src
parentMerge pull request #518 (diff)
downloadmonero-2c83055597e01491b6dffc195dd9e6fe559f0bf7.tar.xz
net_node: add a --offline argument
It will not try to connect to the monero network, nor listen
Diffstat (limited to 'src')
-rw-r--r--src/p2p/net_node.h2
-rw-r--r--src/p2p/net_node.inl10
2 files changed, 12 insertions, 0 deletions
diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h
index 39cbe01fa..99f12beed 100644
--- a/src/p2p/net_node.h
+++ b/src/p2p/net_node.h
@@ -88,6 +88,7 @@ namespace nodetool
m_allow_local_ip(false),
m_hide_my_port(false),
m_no_igd(false),
+ m_offline(false),
m_save_graph(false),
is_closing(false),
m_net_server( epee::net_utils::e_connection_type_P2P ) // this is a P2P connection of the main p2p node server, because this is class node_server<>
@@ -266,6 +267,7 @@ namespace nodetool
bool m_allow_local_ip;
bool m_hide_my_port;
bool m_no_igd;
+ bool m_offline;
std::atomic<bool> m_save_graph;
std::atomic<bool> is_closing;
std::unique_ptr<std::thread> mPeersLoggerThread;
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 067f6378d..35c3115f8 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -92,6 +92,7 @@ namespace nodetool
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<bool> arg_offline = {"offline", "Do not listen for peers, nor connect to any"};
const command_line::arg_descriptor<int64_t> arg_out_peers = {"out-peers", "set max limit of out peers", -1};
const command_line::arg_descriptor<int> arg_tos_flag = {"tos-flag", "set TOS flag", -1};
@@ -116,6 +117,7 @@ namespace nodetool
command_line::add_arg(desc, arg_p2p_seed_node);
command_line::add_arg(desc, arg_p2p_hide_my_port);
command_line::add_arg(desc, arg_no_igd);
+ command_line::add_arg(desc, arg_offline);
command_line::add_arg(desc, arg_out_peers);
command_line::add_arg(desc, arg_tos_flag);
command_line::add_arg(desc, arg_limit_rate_up);
@@ -241,6 +243,7 @@ namespace nodetool
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);
m_no_igd = command_line::get_arg(vm, arg_no_igd);
+ m_offline = command_line::get_arg(vm, arg_offline);
if (command_line::has_arg(vm, arg_p2p_add_peer))
{
@@ -485,6 +488,10 @@ namespace nodetool
m_net_server.get_config_object().m_invoke_timeout = P2P_DEFAULT_INVOKE_TIMEOUT;
m_net_server.set_connection_filter(this);
+ // from here onwards, it's online stuff
+ if (m_offline)
+ return res;
+
//try to bind
LOG_PRINT_L0("Binding on " << m_bind_ip << ":" << m_port);
res = m_net_server.init_server(m_port, m_bind_ip);
@@ -1019,6 +1026,9 @@ namespace nodetool
template<class t_payload_net_handler>
bool node_server<t_payload_net_handler>::make_expected_connections_count(bool white_list, size_t expected_connections)
{
+ if (m_offline)
+ return true;
+
size_t conn_count = get_outgoing_connections_count();
//add new connections from white peers
while(conn_count < expected_connections)