Monero
net_node.h
Go to the documentation of this file.
1 // Copyright (c) 2014-2020, The Monero Project
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification, are
6 // permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice, this list of
9 // conditions and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 // of conditions and the following disclaimer in the documentation and/or other
13 // materials provided with the distribution.
14 //
15 // 3. Neither the name of the copyright holder nor the names of its contributors may be
16 // used to endorse or promote products derived from this software without specific
17 // prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 //
29 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
30 
31 #pragma once
32 #include <array>
33 #include <atomic>
34 #include <boost/asio/io_service.hpp>
35 #include <boost/asio/ip/tcp.hpp>
36 #include <boost/thread.hpp>
37 #include <boost/optional/optional_fwd.hpp>
38 #include <boost/program_options/options_description.hpp>
39 #include <boost/program_options/variables_map.hpp>
40 #include <boost/uuid/uuid.hpp>
41 #include <chrono>
42 #include <functional>
43 #include <utility>
44 #include <vector>
45 
46 #include "cryptonote_config.h"
49 #include "warnings.h"
50 #include "net/abstract_tcp_server2.h"
51 #include "net/levin_protocol_handler.h"
52 #include "net/levin_protocol_handler_async.h"
53 #include "p2p_protocol_defs.h"
54 #include "storages/levin_abstract_invoke2.h"
55 #include "net_peerlist.h"
56 #include "math_helper.h"
57 #include "net_node_common.h"
58 #include "net/enums.h"
59 #include "net/fwd.h"
60 #include "common/command_line.h"
61 
64 
65 namespace nodetool
66 {
67  struct proxy
68  {
70  : max_connections(-1),
71  address(),
72  zone(epee::net_utils::zone::invalid),
73  noise(true)
74  {}
75 
76  std::int64_t max_connections;
77  boost::asio::ip::tcp::endpoint address;
78  epee::net_utils::zone zone;
79  bool noise;
80  };
81 
83  {
85  : max_connections(-1),
86  local_ip(),
87  local_port(),
88  our_address(),
89  default_remote()
90  {}
91 
92  std::int64_t max_connections;
93  std::string local_ip;
94  std::string local_port;
95  epee::net_utils::network_address our_address;
96  epee::net_utils::network_address default_remote;
97  };
98 
99  boost::optional<std::vector<proxy>> get_proxies(const boost::program_options::variables_map& vm);
100  boost::optional<std::vector<anonymous_inbound>> get_anonymous_inbounds(const boost::program_options::variables_map& vm);
101 
103  bool is_filtered_command(epee::net_utils::network_address const& address, int command);
104 
105  // hides boost::future and chrono stuff from mondo template file
106  boost::optional<boost::asio::ip::tcp::socket>
107  socks_connect_internal(const std::atomic<bool>& stop_signal, boost::asio::io_service& service, const boost::asio::ip::tcp::endpoint& proxy, const epee::net_utils::network_address& remote);
108 
109 
110  template<class base_type>
111  struct p2p_connection_context_t: base_type //t_payload_net_handler::connection_context //public net_utils::connection_context_base
112  {
114  : fluff_txs(),
115  flush_time(std::chrono::steady_clock::time_point::max()),
116  peer_id(0),
117  support_flags(0),
118  m_in_timedsync(false)
119  {}
120 
121  std::vector<cryptonote::blobdata> fluff_txs;
122  std::chrono::steady_clock::time_point flush_time;
124  uint32_t support_flags;
126  std::set<epee::net_utils::network_address> sent_addresses;
127  };
128 
129  template<class t_payload_net_handler>
130  class node_server: public epee::levin::levin_commands_handler<p2p_connection_context_t<typename t_payload_net_handler::connection_context> >,
131  public i_p2p_endpoint<typename t_payload_net_handler::connection_context>,
132  public epee::net_utils::i_connection_filter
133  {
134  struct by_conn_id{};
135  struct by_peer_id{};
136  struct by_addr{};
137 
139 
142 
143  typedef epee::net_utils::boosted_tcp_server<epee::levin::async_protocol_handler<p2p_connection_context>> net_server;
144 
145  struct network_zone;
146  using connect_func = boost::optional<p2p_connection_context>(network_zone&, epee::net_utils::network_address const&, epee::net_utils::ssl_support_t);
147 
148  struct config_t
149  {
151  : m_net_config(),
152  m_peer_id(crypto::rand<uint64_t>()),
153  m_support_flags(0)
154  {}
155 
157  uint64_t m_peer_id;
158  uint32_t m_support_flags;
159  };
160  typedef epee::misc_utils::struct_init<config_t> config;
161 
163  {
165  : m_connect(nullptr),
166  m_net_server(epee::net_utils::e_connection_type_P2P),
167  m_bind_ip(),
168  m_bind_ipv6_address(),
169  m_port(),
170  m_port_ipv6(),
171  m_notifier(),
172  m_our_address(),
173  m_peerlist(),
174  m_config{},
175  m_proxy_address(),
176  m_current_number_of_out_peers(0),
177  m_current_number_of_in_peers(0),
178  m_can_pingback(false)
179  {
180  set_config_defaults();
181  }
182 
183  network_zone(boost::asio::io_service& public_service)
184  : m_connect(nullptr),
185  m_net_server(public_service, epee::net_utils::e_connection_type_P2P),
186  m_bind_ip(),
187  m_bind_ipv6_address(),
188  m_port(),
189  m_port_ipv6(),
190  m_notifier(),
191  m_our_address(),
192  m_peerlist(),
193  m_config{},
194  m_proxy_address(),
195  m_current_number_of_out_peers(0),
196  m_current_number_of_in_peers(0),
197  m_can_pingback(false)
198  {
199  set_config_defaults();
200  }
201 
204  std::string m_bind_ip;
205  std::string m_bind_ipv6_address;
206  std::string m_port;
207  std::string m_port_ipv6;
209  epee::net_utils::network_address m_our_address; // in anonymity networks
212  boost::asio::ip::tcp::endpoint m_proxy_address;
213  std::atomic<unsigned int> m_current_number_of_out_peers;
214  std::atomic<unsigned int> m_current_number_of_in_peers;
216 
217  private:
218  void set_config_defaults() noexcept
219  {
220  // at this moment we have a hardcoded config
221  m_config.m_net_config.handshake_interval = P2P_DEFAULT_HANDSHAKE_INTERVAL;
222  m_config.m_net_config.packet_max_size = P2P_DEFAULT_PACKET_MAX_SIZE;
223  m_config.m_net_config.config_id = 0;
224  m_config.m_net_config.connection_timeout = P2P_DEFAULT_CONNECTION_TIMEOUT;
225  m_config.m_net_config.ping_connection_timeout = P2P_DEFAULT_PING_CONNECTION_TIMEOUT;
226  m_config.m_net_config.send_peerlist_sz = P2P_DEFAULT_PEERS_IN_HANDSHAKE;
227  m_config.m_support_flags = 0; // only set in public zone
228  }
229  };
230 
231  enum igd_t
232  {
236  };
237 
238  public:
239  typedef t_payload_net_handler payload_net_handler;
240 
241  node_server(t_payload_net_handler& payload_handler)
242  : m_payload_handler(payload_handler),
243  m_external_port(0),
244  m_rpc_port(0),
245  m_rpc_credits_per_hash(0),
246  m_allow_local_ip(false),
247  m_hide_my_port(false),
248  m_igd(no_igd),
249  m_offline(false),
250  is_closing(false),
251  m_network_id()
252  {}
253  virtual ~node_server();
254 
255  static void init_options(boost::program_options::options_description& desc);
256 
257  bool run();
258  network_zone& add_zone(epee::net_utils::zone zone);
259  bool init(const boost::program_options::variables_map& vm);
260  bool deinit();
261  bool send_stop_signal();
262  uint32_t get_this_peer_port(){return m_listening_port;}
263  t_payload_net_handler& get_payload_object();
264 
265  // debug functions
266  bool log_peerlist();
267  bool log_connections();
268 
269  // These functions only return information for the "public" zone
270  virtual uint64_t get_public_connections_count();
271  size_t get_public_outgoing_connections_count();
272  size_t get_public_white_peers_count();
273  size_t get_public_gray_peers_count();
274  void get_public_peerlist(std::vector<peerlist_entry>& gray, std::vector<peerlist_entry>& white);
275  void get_peerlist(std::vector<peerlist_entry>& gray, std::vector<peerlist_entry>& white);
276 
277  void change_max_out_public_peers(size_t count);
278  uint32_t get_max_out_public_peers() const;
279  void change_max_in_public_peers(size_t count);
280  uint32_t get_max_in_public_peers() const;
281  virtual bool block_host(const epee::net_utils::network_address &adress, time_t seconds = P2P_IP_BLOCKTIME);
282  virtual bool unblock_host(const epee::net_utils::network_address &address);
283  virtual bool block_subnet(const epee::net_utils::ipv4_network_subnet &subnet, time_t seconds = P2P_IP_BLOCKTIME);
284  virtual bool unblock_subnet(const epee::net_utils::ipv4_network_subnet &subnet);
285  virtual bool is_host_blocked(const epee::net_utils::network_address &address, time_t *seconds) { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return !is_remote_host_allowed(address, seconds); }
286  virtual std::map<std::string, time_t> get_blocked_hosts() { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return m_blocked_hosts; }
287  virtual std::map<epee::net_utils::ipv4_network_subnet, time_t> get_blocked_subnets() { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return m_blocked_subnets; }
288 
289  virtual void add_used_stripe_peer(const typename t_payload_net_handler::connection_context &context);
290  virtual void remove_used_stripe_peer(const typename t_payload_net_handler::connection_context &context);
291  virtual void clear_used_stripe_peers();
292 
293  private:
294  const std::vector<std::string> m_seed_nodes_list =
295  { "seeds.moneroseeds.se"
296  , "seeds.moneroseeds.ae.org"
297  , "seeds.moneroseeds.ch"
298  , "seeds.moneroseeds.li"
299  };
300 
301  bool islimitup=false;
302  bool islimitdown=false;
303 
304  CHAIN_LEVIN_INVOKE_MAP2(p2p_connection_context); //move levin_commands_handler interface invoke(...) callbacks into invoke map
305  CHAIN_LEVIN_NOTIFY_MAP2(p2p_connection_context); //move levin_commands_handler interface notify(...) callbacks into nothing
306 
307  BEGIN_INVOKE_MAP2(node_server)
308  if (is_filtered_command(context.m_remote_address, command))
309  return LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED;
310 
311  HANDLE_INVOKE_T2(COMMAND_HANDSHAKE, &node_server::handle_handshake)
312  HANDLE_INVOKE_T2(COMMAND_TIMED_SYNC, &node_server::handle_timed_sync)
313  HANDLE_INVOKE_T2(COMMAND_PING, &node_server::handle_ping)
314  HANDLE_INVOKE_T2(COMMAND_REQUEST_SUPPORT_FLAGS, &node_server::handle_get_support_flags)
315  CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(m_payload_handler, typename t_payload_net_handler::connection_context&)
316  END_INVOKE_MAP2()
317 
318  enum PeerType { anchor = 0, white, gray };
319 
320  //----------------- commands handlers ----------------------------------------------
321  int handle_handshake(int command, typename COMMAND_HANDSHAKE::request& arg, typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context);
322  int handle_timed_sync(int command, typename COMMAND_TIMED_SYNC::request& arg, typename COMMAND_TIMED_SYNC::response& rsp, p2p_connection_context& context);
323  int handle_ping(int command, COMMAND_PING::request& arg, COMMAND_PING::response& rsp, p2p_connection_context& context);
324  int handle_get_support_flags(int command, COMMAND_REQUEST_SUPPORT_FLAGS::request& arg, COMMAND_REQUEST_SUPPORT_FLAGS::response& rsp, p2p_connection_context& context);
325  bool init_config();
328  bool store_config();
329 
330 
331  //----------------- levin_commands_handler -------------------------------------------------------------
332  virtual void on_connection_new(p2p_connection_context& context);
333  virtual void on_connection_close(p2p_connection_context& context);
334  virtual void callback(p2p_connection_context& context);
335  //----------------- i_p2p_endpoint -------------------------------------------------------------
336  virtual bool relay_notify_to_list(int command, const epee::span<const uint8_t> data_buff, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections);
337  virtual epee::net_utils::zone send_txs(std::vector<cryptonote::blobdata> txs, const epee::net_utils::zone origin, const boost::uuids::uuid& source, cryptonote::relay_method tx_relay);
338  virtual bool invoke_command_to_peer(int command, const epee::span<const uint8_t> req_buff, std::string& resp_buff, const epee::net_utils::connection_context_base& context);
339  virtual bool invoke_notify_to_peer(int command, const epee::span<const uint8_t> req_buff, const epee::net_utils::connection_context_base& context);
340  virtual bool drop_connection(const epee::net_utils::connection_context_base& context);
341  virtual void request_callback(const epee::net_utils::connection_context_base& context);
342  virtual void for_each_connection(std::function<bool(typename t_payload_net_handler::connection_context&, peerid_type, uint32_t)> f);
343  virtual bool for_connection(const boost::uuids::uuid&, std::function<bool(typename t_payload_net_handler::connection_context&, peerid_type, uint32_t)> f);
344  virtual bool add_host_fail(const epee::net_utils::network_address &address, unsigned int score = 1);
345  //----------------- i_connection_filter --------------------------------------------------------
346  virtual bool is_remote_host_allowed(const epee::net_utils::network_address &address, time_t *t = NULL);
347  //-----------------------------------------------------------------------------------------------
348  bool parse_peer_from_string(epee::net_utils::network_address& pe, const std::string& node_addr, uint16_t default_port = 0);
349  bool handle_command_line(
350  const boost::program_options::variables_map& vm
351  );
352  bool idle_worker();
353  bool handle_remote_peerlist(const std::vector<peerlist_entry>& peerlist, const epee::net_utils::connection_context_base& context);
354  bool get_local_node_data(basic_node_data& node_data, const network_zone& zone);
355  //bool get_local_handshake_data(handshake_data& hshd);
356 
357  bool sanitize_peerlist(std::vector<peerlist_entry>& local_peerlist);
358 
359  bool connections_maker();
360  bool peer_sync_idle_maker();
361  bool do_handshake_with_peer(peerid_type& pi, p2p_connection_context& context, bool just_take_peerlist = false);
362  bool do_peer_timed_sync(const epee::net_utils::connection_context_base& context, peerid_type peer_id);
363 
364  bool make_new_connection_from_anchor_peerlist(const std::vector<anchor_peerlist_entry>& anchor_peerlist);
365  bool make_new_connection_from_peerlist(network_zone& zone, bool use_white_list);
366  bool try_to_connect_and_handshake_with_new_peer(const epee::net_utils::network_address& na, bool just_take_peerlist = false, uint64_t last_seen_stamp = 0, PeerType peer_type = white, uint64_t first_seen_stamp = 0);
367  size_t get_random_index_with_fixed_probability(size_t max_index);
368  bool is_peer_used(const peerlist_entry& peer);
369  bool is_peer_used(const anchor_peerlist_entry& peer);
370  bool is_addr_connected(const epee::net_utils::network_address& peer);
371  void add_upnp_port_mapping_impl(uint32_t port, bool ipv6=false);
372  void add_upnp_port_mapping_v4(uint32_t port);
373  void add_upnp_port_mapping_v6(uint32_t port);
374  void add_upnp_port_mapping(uint32_t port, bool ipv4=true, bool ipv6=false);
375  void delete_upnp_port_mapping_impl(uint32_t port, bool ipv6=false);
376  void delete_upnp_port_mapping_v4(uint32_t port);
377  void delete_upnp_port_mapping_v6(uint32_t port);
378  void delete_upnp_port_mapping(uint32_t port);
379  template<class t_callback>
380  bool try_ping(basic_node_data& node_data, p2p_connection_context& context, const t_callback &cb);
381  bool try_get_support_flags(const p2p_connection_context& context, std::function<void(p2p_connection_context&, const uint32_t&)> f);
382  bool make_expected_connections_count(network_zone& zone, PeerType peer_type, size_t expected_connections);
383  void record_addr_failed(const epee::net_utils::network_address& addr);
384  bool is_addr_recently_failed(const epee::net_utils::network_address& addr);
385  bool is_priority_node(const epee::net_utils::network_address& na);
386  std::set<std::string> get_seed_nodes(cryptonote::network_type nettype) const;
387  std::set<std::string> get_seed_nodes();
388  bool connect_to_seed();
389 
390  template <class Container>
391  bool connect_to_peerlist(const Container& peers);
392 
393  template <class Container>
394  bool parse_peers_and_add_to_container(const boost::program_options::variables_map& vm, const command_line::arg_descriptor<std::vector<std::string> > & arg, Container& container);
395 
396  bool set_max_out_peers(network_zone& zone, int64_t max);
397  bool set_max_in_peers(network_zone& zone, int64_t max);
398  bool set_tos_flag(const boost::program_options::variables_map& vm, int limit);
399 
400  bool set_rate_up_limit(const boost::program_options::variables_map& vm, int64_t limit);
401  bool set_rate_down_limit(const boost::program_options::variables_map& vm, int64_t limit);
402  bool set_rate_limit(const boost::program_options::variables_map& vm, int64_t limit);
403 
404  bool has_too_many_connections(const epee::net_utils::network_address &address);
405  size_t get_incoming_connections_count();
406  size_t get_incoming_connections_count(network_zone&);
407  size_t get_outgoing_connections_count();
408  size_t get_outgoing_connections_count(network_zone&);
409 
410  bool check_connection_and_handshake_with_peer(const epee::net_utils::network_address& na, uint64_t last_seen_stamp);
411  bool gray_peerlist_housekeeping();
412  bool check_incoming_connections();
413 
414  void kill() {
415  _info("Killing the net_node");
416  is_closing = true;
417  if(mPeersLoggerThread != nullptr)
418  mPeersLoggerThread->join(); // make sure the thread finishes
419  _info("Joined extra background net_node threads");
420  }
421 
422  //debug functions
423  std::string print_connections_container();
424 
425 
426  public:
427 
428  void set_rpc_port(uint16_t rpc_port)
429  {
430  m_rpc_port = rpc_port;
431  }
432 
433  void set_rpc_credits_per_hash(uint32_t rpc_credits_per_hash)
434  {
435  m_rpc_credits_per_hash = rpc_credits_per_hash;
436  }
437 
438  private:
439  std::string m_config_folder;
440 
445  uint32_t m_external_port;
446  uint16_t m_rpc_port;
450  igd_t m_igd;
451  bool m_offline;
454  std::atomic<bool> is_closing;
455  std::unique_ptr<boost::thread> mPeersLoggerThread;
456  //critical_section m_connections_lock;
457  //connections_indexed_container m_connections;
458 
459  t_payload_net_handler& m_payload_handler;
461 
462  epee::math_helper::once_a_time_seconds<P2P_DEFAULT_HANDSHAKE_INTERVAL> m_peer_handshake_idle_maker_interval;
463  epee::math_helper::once_a_time_seconds<1> m_connections_maker_interval;
464  epee::math_helper::once_a_time_seconds<60*30, false> m_peerlist_store_interval;
465  epee::math_helper::once_a_time_seconds<60> m_gray_peerlist_housekeeping_interval;
466  epee::math_helper::once_a_time_seconds<3600, false> m_incoming_connections_interval;
467 
468  std::list<epee::net_utils::network_address> m_priority_peers;
469  std::vector<epee::net_utils::network_address> m_exclusive_peers;
470  std::vector<epee::net_utils::network_address> m_seed_nodes;
471  bool m_seed_nodes_initialized = false;
472  boost::shared_mutex m_seed_nodes_lock;
473  std::atomic_flag m_fallback_seed_nodes_added;
474  std::vector<nodetool::peerlist_entry> m_command_line_peers;
475  uint64_t m_peer_livetime;
476  //keep connections to initiate some interactions
477 
478 
479  static boost::optional<p2p_connection_context> public_connect(network_zone&, epee::net_utils::network_address const&, epee::net_utils::ssl_support_t);
480  static boost::optional<p2p_connection_context> socks_connect(network_zone&, epee::net_utils::network_address const&, epee::net_utils::ssl_support_t);
481 
482 
483  /* A `std::map` provides constant iterators and key/value pointers even with
484  inserts/erases to _other_ elements. This makes the configuration step easier
485  since references can safely be stored on the stack. Do not insert/erase
486  after configuration and before destruction, lock safety would need to be
487  added. `std::map::operator[]` WILL insert! */
488  std::map<epee::net_utils::zone, network_zone> m_network_zones;
489 
490 
491  std::map<std::string, time_t> m_conn_fails_cache;
492  epee::critical_section m_conn_fails_cache_lock;
493 
494  epee::critical_section m_blocked_hosts_lock; // for both hosts and subnets
495  std::map<std::string, time_t> m_blocked_hosts;
496  std::map<epee::net_utils::ipv4_network_subnet, time_t> m_blocked_subnets;
497 
498  epee::critical_section m_host_fails_score_lock;
499  std::map<std::string, uint64_t> m_host_fails_score;
500 
502  std::array<std::list<epee::net_utils::network_address>, 1 << CRYPTONOTE_PRUNING_LOG_STRIPES> m_used_stripe_peers;
503 
506 
507  epee::net_utils::ssl_support_t m_ssl_support;
508  };
509 
528 
535 
540 }
541 
542 POP_WARNINGS
543 
nodetool::p2p_connection_context_t::support_flags
uint32_t support_flags
Definition: net_node.h:124
nodetool::anchor_peerlist_entry_base
Definition: p2p_protocol_defs.h:102
nodetool::node_server::CHAIN_LEVIN_NOTIFY_MAP2
CHAIN_LEVIN_NOTIFY_MAP2(p2p_connection_context)
nodetool::node_server::mPeersLoggerThread
std::unique_ptr< boost::thread > mPeersLoggerThread
Definition: net_node.h:455
P2P_DEFAULT_LIMIT_RATE_DOWN
#define P2P_DEFAULT_LIMIT_RATE_DOWN
Definition: cryptonote_config.h:144
nodetool::node_server::network_zone::m_bind_ipv6_address
std::string m_bind_ipv6_address
Definition: net_node.h:205
nodetool::node_server::kill
void kill()
Definition: net_node.h:414
nodetool::node_server::get_this_peer_port
uint32_t get_this_peer_port()
Definition: net_node.h:262
P2P_DEFAULT_LIMIT_RATE_UP
#define P2P_DEFAULT_LIMIT_RATE_UP
Definition: cryptonote_config.h:143
nodetool::node_server::config_t::m_support_flags
uint32_t m_support_flags
Definition: net_node.h:158
nodetool::node_server::COMMAND_HANDSHAKE
COMMAND_HANDSHAKE_T< typename t_payload_net_handler::payload_type > COMMAND_HANDSHAKE
Definition: net_node.h:140
nodetool::arg_p2p_seed_node
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_seed_node
Definition: net_node.cpp:146
nodetool::node_server::set_rpc_credits_per_hash
void set_rpc_credits_per_hash(uint32_t rpc_credits_per_hash)
Definition: net_node.h:433
nodetool::proxy::address
boost::asio::ip::tcp::endpoint address
Definition: net_node.h:77
nodetool::node_server::m_conn_fails_cache
std::map< std::string, time_t > m_conn_fails_cache
Definition: net_node.h:491
nodetool::node_server::network_zone::m_current_number_of_out_peers
std::atomic< unsigned int > m_current_number_of_out_peers
Definition: net_node.h:213
nodetool::node_server::m_blocked_hosts
std::map< std::string, time_t > m_blocked_hosts
Definition: net_node.h:495
nodetool::node_server::get_blocked_hosts
virtual std::map< std::string, time_t > get_blocked_hosts()
Definition: net_node.h:286
nodetool::get_anonymous_inbounds
boost::optional< std::vector< anonymous_inbound > > get_anonymous_inbounds(boost::program_options::variables_map const &vm)
Definition: net_node.cpp:237
nodetool::node_server::network_zone::m_proxy_address
boost::asio::ip::tcp::endpoint m_proxy_address
Definition: net_node.h:212
levin_notify.h
nodetool::p2p_connection_context_t::fluff_txs
std::vector< cryptonote::blobdata > fluff_txs
Definition: net_node.h:121
P2P_DEFAULT_PEERS_IN_HANDSHAKE
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE
Definition: cryptonote_config.h:134
nodetool::node_server::m_blocked_hosts_lock
epee::critical_section m_blocked_hosts_lock
Definition: net_node.h:494
nodetool::arg_in_peers
const command_line::arg_descriptor< int64_t > arg_in_peers
Definition: net_node.cpp:157
nodetool::node_server::network_zone::m_port_ipv6
std::string m_port_ipv6
Definition: net_node.h:207
nodetool::node_server::m_offline
bool m_offline
Definition: net_node.h:451
nodetool::proxy::zone
epee::net_utils::zone zone
Definition: net_node.h:78
nodetool::arg_anonymous_inbound
const command_line::arg_descriptor< std::vector< std::string > > arg_anonymous_inbound
Definition: net_node.cpp:148
nodetool::default_limit_down
const int64_t default_limit_down
Definition: net_node.h:511
nodetool::node_server::make_default_config
bool make_default_config()
nodetool::node_server::parse_peer_from_string
bool parse_peer_from_string(epee::net_utils::network_address &pe, const std::string &node_addr, uint16_t default_port=0)
cryptonote::relay_method
relay_method
Methods tracking how a tx was received and relayed.
Definition: enums.h:37
nodetool::arg_p2p_bind_ip
const command_line::arg_descriptor< std::string > arg_p2p_bind_ip
Definition: net_node.cpp:111
nodetool::arg_p2p_bind_ipv6_address
const command_line::arg_descriptor< std::string > arg_p2p_bind_ipv6_address
Definition: net_node.cpp:112
nodetool::node_server::m_used_stripe_peers_mutex
boost::mutex m_used_stripe_peers_mutex
Definition: net_node.h:501
nodetool::arg_p2p_add_exclusive_node
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_add_exclusive_node
Definition: net_node.cpp:144
nodetool::node_server::get_blocked_subnets
virtual std::map< epee::net_utils::ipv4_network_subnet, time_t > get_blocked_subnets()
Definition: net_node.h:287
nodetool::node_server::m_host_fails_score_lock
epee::critical_section m_host_fails_score_lock
Definition: net_node.h:498
P2P_DEFAULT_PACKET_MAX_SIZE
#define P2P_DEFAULT_PACKET_MAX_SIZE
Definition: cryptonote_config.h:133
P2P_DEFAULT_CONNECTION_TIMEOUT
#define P2P_DEFAULT_CONNECTION_TIMEOUT
Definition: cryptonote_config.h:135
nodetool::arg_offline
const command_line::arg_descriptor< bool > arg_offline
nodetool::proxy::noise
bool noise
Definition: net_node.h:79
nodetool::node_server::set_rpc_port
void set_rpc_port(uint16_t rpc_port)
Definition: net_node.h:428
nodetool::get_proxies
boost::optional< std::vector< proxy > > get_proxies(boost::program_options::variables_map const &vm)
Definition: net_node.cpp:168
nodetool::peerlist_storage
Definition: net_peerlist.h:63
nodetool::node_server::config_t::m_net_config
network_config m_net_config
Definition: net_node.h:156
nodetool::node_server::m_priority_peers
std::list< epee::net_utils::network_address > m_priority_peers
Definition: net_node.h:468
nodetool::node_server::m_seed_nodes_lock
boost::shared_mutex m_seed_nodes_lock
Definition: net_node.h:472
daemonizer::init_options
void init_options(boost::program_options::options_description &hidden_options, boost::program_options::options_description &normal_options)
Definition: posix_daemonizer.inl:56
cryptonote::network_type
network_type
Definition: cryptonote_config.h:268
crypto
crypto namespace.
Definition: crypto.cpp:60
command_line.h
nodetool::node_server::m_blocked_subnets
std::map< epee::net_utils::ipv4_network_subnet, time_t > m_blocked_subnets
Definition: net_node.h:496
nodetool::node_server::network_zone::m_config
config m_config
Definition: net_node.h:211
nodetool::network_config
Definition: p2p_protocol_defs.h:165
cryptonote::levin::notify
Provides tx notification privacy.
Definition: levin_notify.h:70
nodetool::node_server::m_used_stripe_peers
std::array< std::list< epee::net_utils::network_address >, 1<< CRYPTONOTE_PRUNING_LOG_STRIPES > m_used_stripe_peers
Definition: net_node.h:502
nodetool::node_server::m_igd
igd_t m_igd
Definition: net_node.h:450
nodetool::arg_limit_rate_up
const command_line::arg_descriptor< int64_t > arg_limit_rate_up
Definition: net_node.cpp:160
nodetool::p2p_connection_context_t::m_in_timedsync
bool m_in_timedsync
Definition: net_node.h:125
nodetool::node_server::no_igd
@ no_igd
Definition: net_node.h:233
nodetool::arg_limit_rate_down
const command_line::arg_descriptor< int64_t > arg_limit_rate_down
Definition: net_node.cpp:161
nodetool::COMMAND_REQUEST_SUPPORT_FLAGS::request
epee::misc_utils::struct_init< request_t > request
Definition: p2p_protocol_defs.h:320
cryptonote_config.h
nodetool::node_server::igd
@ igd
Definition: net_node.h:234
config
Definition: cryptonote_config.h:200
DISABLE_VS_WARNINGS
DISABLE_VS_WARNINGS(4244 4345 4503) using namespace crypto
nodetool::node_server::by_peer_id
Definition: net_node.h:135
init
static void init(std::string cache_filename)
Definition: blockchain_blackball.cpp:221
nodetool::node_server::network_zone
Definition: net_node.h:163
nodetool::p2p_connection_context_t
Definition: net_node.h:112
nodetool::node_server::network_zone::m_port
std::string m_port
Definition: net_node.h:206
nodetool::arg_limit_rate
const command_line::arg_descriptor< int64_t > arg_limit_rate
Definition: net_node.cpp:162
nodetool::arg_p2p_allow_local_ip
const command_line::arg_descriptor< bool > arg_p2p_allow_local_ip
Definition: net_node.cpp:141
nodetool::anonymous_inbound::anonymous_inbound
anonymous_inbound()
Definition: net_node.h:84
nodetool::COMMAND_PING
Definition: p2p_protocol_defs.h:275
P2P_DEFAULT_PING_CONNECTION_TIMEOUT
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT
Definition: cryptonote_config.h:137
nodetool::node_server::m_have_address
bool m_have_address
Definition: net_node.h:441
nodetool::proxy::proxy
proxy()
Definition: net_node.h:69
nodetool::node_server::by_conn_id
Definition: net_node.h:134
nodetool::arg_no_igd
const command_line::arg_descriptor< bool > arg_no_igd
Definition: net_node.cpp:152
if
if(APPLE) if(DEPENDS) list(APPEND EXTRA_LIBRARIES "-framework Foundation -framework ApplicationServices -framework AppKit -framework IOKit") else() find_library(IOKIT_LIBRARY IOKit) mark_as_advanced(IOKIT_LIBRARY) list(APPEND EXTRA_LIBRARIES $
Definition: CMakeLists.txt:29
CRYPTONOTE_PRUNING_LOG_STRIPES
#define CRYPTONOTE_PRUNING_LOG_STRIPES
Definition: cryptonote_config.h:192
nodetool::node_server::make_default_peer_id
bool make_default_peer_id()
lmdb::stream::count
mdb_size_t count(MDB_cursor *cur)
Definition: value_stream.cpp:39
net_peerlist.h
nodetool::node_server::m_command_line_peers
std::vector< nodetool::peerlist_entry > m_command_line_peers
Definition: net_node.h:474
nodetool::is_filtered_command
bool is_filtered_command(const epee::net_utils::network_address &address, int command)
Definition: net_node.cpp:304
nodetool::anonymous_inbound::local_port
std::string local_port
Definition: net_node.h:94
nodetool::node_server::m_external_port
uint32_t m_external_port
Definition: net_node.h:445
nodetool::arg_igd
const command_line::arg_descriptor< std::string > arg_igd
Definition: net_node.cpp:153
nodetool::node_server::network_zone::m_our_address
epee::net_utils::network_address m_our_address
Definition: net_node.h:209
nodetool::node_server::m_rpc_credits_per_hash
uint32_t m_rpc_credits_per_hash
Definition: net_node.h:447
nodetool::node_server::m_host_fails_score
std::map< std::string, uint64_t > m_host_fails_score
Definition: net_node.h:499
nodetool::arg_p2p_hide_my_port
const command_line::arg_descriptor< bool > arg_p2p_hide_my_port
Definition: net_node.cpp:149
nodetool::node_server::node_server
node_server(t_payload_net_handler &payload_handler)
Definition: net_node.h:241
nodetool::node_server::m_peer_livetime
uint64_t m_peer_livetime
Definition: net_node.h:475
nodetool::arg_pad_transactions
const command_line::arg_descriptor< bool > arg_pad_transactions
Definition: net_node.cpp:164
nodetool::uuid
boost::uuids::uuid uuid
Definition: net_node_common.h:46
nodetool::node_server::m_hide_my_port
bool m_hide_my_port
Definition: net_node.h:449
nodetool::node_server::m_network_zones
std::map< epee::net_utils::zone, network_zone > m_network_zones
Definition: net_node.h:488
nodetool::node_server::m_allow_local_ip
bool m_allow_local_ip
Definition: net_node.h:448
nodetool::node_server::network_zone::m_net_server
net_server m_net_server
Definition: net_node.h:203
nodetool::node_server< cryptonote::t_cryptonote_protocol_handler< cryptonote::core > >::PeerType
PeerType
Definition: net_node.h:318
crypto::rand
void rand(size_t N, uint8_t *bytes)
Definition: crypto.h:156
fwd.h
P2P_DEFAULT_HANDSHAKE_INTERVAL
#define P2P_DEFAULT_HANDSHAKE_INTERVAL
Definition: cryptonote_config.h:132
nodetool::node_server::by_addr
Definition: net_node.h:136
nodetool::node_server::config_t
Definition: net_node.h:149
nodetool::node_server::COMMAND_TIMED_SYNC
COMMAND_TIMED_SYNC_T< typename t_payload_net_handler::payload_type > COMMAND_TIMED_SYNC
Definition: net_node.h:141
net::zmq::context
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105
nodetool::i_p2p_endpoint
Definition: net_node_common.h:51
nodetool::node_server::network_zone::m_current_number_of_in_peers
std::atomic< unsigned int > m_current_number_of_in_peers
Definition: net_node.h:214
nodetool::node_server::network_zone::network_zone
network_zone()
Definition: net_node.h:164
nodetool::node_server::network_zone::m_bind_ip
std::string m_bind_ip
Definition: net_node.h:204
nodetool::node_server::config
epee::misc_utils::struct_init< config_t > config
Definition: net_node.h:160
nodetool::node_server::network_zone::network_zone
network_zone(boost::asio::io_service &public_service)
Definition: net_node.h:183
nodetool::node_server::m_payload_handler
t_payload_net_handler & m_payload_handler
Definition: net_node.h:459
nodetool::node_server::m_use_ipv6
bool m_use_ipv6
Definition: net_node.h:452
nodetool::node_server::m_nettype
cryptonote::network_type m_nettype
Definition: net_node.h:505
nodetool::node_server::network_zone::m_notifier
cryptonote::levin::notify m_notifier
Definition: net_node.h:208
nodetool::anonymous_inbound::default_remote
epee::net_utils::network_address default_remote
Definition: net_node.h:96
nodetool::node_server::network_zone::m_peerlist
peerlist_manager m_peerlist
Definition: net_node.h:210
nodetool::node_server::white
@ white
Definition: net_node.h:318
nodetool::p2p_connection_context_t::sent_addresses
std::set< epee::net_utils::network_address > sent_addresses
Definition: net_node.h:126
nodetool::node_server::m_peerlist_store_interval
epee::math_helper::once_a_time_seconds< 60 *30, false > m_peerlist_store_interval
Definition: net_node.h:464
nodetool::node_server::net_server
epee::net_utils::boosted_tcp_server< epee::levin::async_protocol_handler< p2p_connection_context > > net_server
Definition: net_node.h:143
nodetool::arg_no_sync
const command_line::arg_descriptor< bool > arg_no_sync
Definition: net_node.cpp:150
false
#define false
Definition: stdbool.h:37
nodetool::node_server::payload_net_handler
t_payload_net_handler payload_net_handler
Definition: net_node.h:239
nodetool::COMMAND_REQUEST_SUPPORT_FLAGS::response
epee::misc_utils::struct_init< response_t > response
Definition: p2p_protocol_defs.h:330
nodetool::arg_p2p_bind_port_ipv6
const command_line::arg_descriptor< std::string, false, true, 2 > arg_p2p_bind_port_ipv6
Definition: net_node.cpp:126
nodetool::p2p_connection_context_t::peer_id
peerid_type peer_id
Definition: net_node.h:123
nodetool::node_server::m_incoming_connections_interval
epee::math_helper::once_a_time_seconds< 3600, false > m_incoming_connections_interval
Definition: net_node.h:466
nodetool::arg_p2p_external_port
const command_line::arg_descriptor< uint32_t > arg_p2p_external_port
Definition: net_node.cpp:140
nodetool::node_server::p2p_connection_context
p2p_connection_context_t< typename t_payload_net_handler::connection_context > p2p_connection_context
Definition: net_node.h:138
nodetool::anonymous_inbound
Definition: net_node.h:83
nodetool::anonymous_inbound::our_address
epee::net_utils::network_address our_address
Definition: net_node.h:95
nodetool::node_server::m_first_connection_maker_call
bool m_first_connection_maker_call
Definition: net_node.h:442
nodetool::proxy::max_connections
std::int64_t max_connections
Definition: net_node.h:76
nodetool::COMMAND_TIMED_SYNC_T
Definition: p2p_protocol_defs.h:245
nodetool::peerid_type
uint64_t peerid_type
Definition: p2p_protocol_defs.h:48
nodetool::COMMAND_PING::response
epee::misc_utils::struct_init< response_t > response
Definition: p2p_protocol_defs.h:304
nodetool::arg_tos_flag
const command_line::arg_descriptor< int > arg_tos_flag
Definition: net_node.cpp:158
nodetool::arg_out_peers
const command_line::arg_descriptor< int64_t > arg_out_peers
Definition: net_node.cpp:156
nodetool::node_server::delayed_igd
@ delayed_igd
Definition: net_node.h:235
nodetool::socks_connect_internal
boost::optional< boost::asio::ip::tcp::socket > socks_connect_internal(const std::atomic< bool > &stop_signal, boost::asio::io_service &service, const boost::asio::ip::tcp::endpoint &proxy, const epee::net_utils::network_address &remote)
Definition: net_node.cpp:324
nodetool::p2p_connection_context_t::flush_time
std::chrono::steady_clock::time_point flush_time
Definition: net_node.h:122
nodetool::default_limit_up
const int64_t default_limit_up
Definition: net_node.h:510
nodetool::COMMAND_PING::request
epee::misc_utils::struct_init< request_t > request
Definition: p2p_protocol_defs.h:292
nodetool::node_server::m_fallback_seed_nodes_added
std::atomic_flag m_fallback_seed_nodes_added
Definition: net_node.h:473
nodetool::node_server::m_listening_port_ipv6
uint32_t m_listening_port_ipv6
Definition: net_node.h:444
nodetool::node_server::m_rpc_port
uint16_t m_rpc_port
Definition: net_node.h:446
nodetool::basic_node_data
Definition: p2p_protocol_defs.h:185
nodetool::anonymous_inbound::max_connections
std::int64_t max_connections
Definition: net_node.h:92
std
Definition: blockchain_ancestry.cpp:72
nodetool::node_server::network_zone::m_can_pingback
bool m_can_pingback
Definition: net_node.h:215
nodetool::proxy
Definition: net_node.h:68
nodetool::node_server::m_ssl_support
epee::net_utils::ssl_support_t m_ssl_support
Definition: net_node.h:507
nodetool::COMMAND_HANDSHAKE_T
Definition: p2p_protocol_defs.h:209
nodetool::COMMAND_REQUEST_SUPPORT_FLAGS
Definition: p2p_protocol_defs.h:312
nodetool::p2p_connection_context_t::p2p_connection_context_t
p2p_connection_context_t()
Definition: net_node.h:113
nodetool::node_server::m_peer_handshake_idle_maker_interval
epee::math_helper::once_a_time_seconds< P2P_DEFAULT_HANDSHAKE_INTERVAL > m_peer_handshake_idle_maker_interval
Definition: net_node.h:462
p2p_protocol_defs.h
nodetool::peerlist_entry_base
Definition: p2p_protocol_defs.h:72
cryptonote::levin::connections
epee::levin::async_protocol_handler_config< detail::p2p_context > connections
Definition: levin_notify.h:66
nodetool::node_server::m_require_ipv4
bool m_require_ipv4
Definition: net_node.h:453
nodetool::arg_p2p_use_ipv6
const command_line::arg_descriptor< bool > arg_p2p_use_ipv6
Definition: net_node.cpp:154
fwd.h
net_node_common.h
nodetool::arg_p2p_add_peer
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_add_peer
Definition: net_node.cpp:142
nodetool::anonymous_inbound::local_ip
std::string local_ip
Definition: net_node.h:93
nodetool::node_server::network_zone::set_config_defaults
void set_config_defaults() noexcept
Definition: net_node.h:218
nodetool::node_server::is_host_blocked
virtual bool is_host_blocked(const epee::net_utils::network_address &address, time_t *seconds)
Definition: net_node.h:285
nodetool::node_server::m_conn_fails_cache_lock
epee::critical_section m_conn_fails_cache_lock
Definition: net_node.h:492
nodetool::node_server::m_peerlist_storage
peerlist_storage m_peerlist_storage
Definition: net_node.h:460
nodetool::node_server::CHAIN_LEVIN_INVOKE_MAP2
CHAIN_LEVIN_INVOKE_MAP2(p2p_connection_context)
PUSH_WARNINGS
PUSH_WARNINGS
Definition: hash-ops.h:53
true
#define true
Definition: stdbool.h:36
nodetool::node_server::m_gray_peerlist_housekeeping_interval
epee::math_helper::once_a_time_seconds< 60 > m_gray_peerlist_housekeeping_interval
Definition: net_node.h:465
nodetool::node_server::network_zone::m_connect
connect_func * m_connect
Definition: net_node.h:202
nodetool::node_server
Definition: net_node.h:133
nodetool::arg_p2p_ignore_ipv4
const command_line::arg_descriptor< bool > arg_p2p_ignore_ipv4
Definition: net_node.cpp:155
nodetool::node_server::config_t::config_t
config_t()
Definition: net_node.h:150
nodetool::node_server::m_exclusive_peers
std::vector< epee::net_utils::network_address > m_exclusive_peers
Definition: net_node.h:469
nodetool
Definition: levin_notify.h:52
nodetool::node_server::m_config_folder
std::string m_config_folder
Definition: net_node.h:439
epee
Definition: cryptonote_format_utils.h:44
P2P_IP_BLOCKTIME
#define P2P_IP_BLOCKTIME
Definition: cryptonote_config.h:147
nodetool::node_server::is_closing
std::atomic< bool > is_closing
Definition: net_node.h:454
nodetool::node_server::m_seed_nodes
std::vector< epee::net_utils::network_address > m_seed_nodes
Definition: net_node.h:470
command_line::arg_descriptor
Definition: command_line.h:53
nodetool::peerlist_manager
Definition: net_peerlist.h:100
nodetool::arg_p2p_add_priority_node
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_add_priority_node
Definition: net_node.cpp:143
nodetool::node_server::m_network_id
boost::uuids::uuid m_network_id
Definition: net_node.h:504
nodetool::node_server::config_t::m_peer_id
uint64_t m_peer_id
Definition: net_node.h:157
nodetool::node_server::m_listening_port
uint32_t m_listening_port
Definition: net_node.h:443
nodetool::node_server< cryptonote::t_cryptonote_protocol_handler< cryptonote::core > >::connect_func
boost::optional< p2p_connection_context >(network_zone &, epee::net_utils::network_address const &, epee::net_utils::ssl_support_t) connect_func
Definition: net_node.h:146
nodetool::arg_p2p_bind_port
const command_line::arg_descriptor< std::string, false, true, 2 > arg_p2p_bind_port
Definition: net_node.cpp:113
nodetool::node_server::m_connections_maker_interval
epee::math_helper::once_a_time_seconds< 1 > m_connections_maker_interval
Definition: net_node.h:463
nodetool::arg_tx_proxy
const command_line::arg_descriptor< std::vector< std::string > > arg_tx_proxy
Definition: net_node.cpp:147