Electroneum
net_node.h
Go to the documentation of this file.
1 // Copyrights(c) 2017-2021, The Electroneum Project
2 // Copyrights(c) 2014-2019, The Monero Project
3 //
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without modification, are
7 // permitted provided that the following conditions are met:
8 //
9 // 1. Redistributions of source code must retain the above copyright notice, this list of
10 // conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright notice, this list
13 // of conditions and the following disclaimer in the documentation and/or other
14 // materials provided with the distribution.
15 //
16 // 3. Neither the name of the copyright holder nor the names of its contributors may be
17 // used to endorse or promote products derived from this software without specific
18 // prior written permission.
19 //
20 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
21 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
22 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23 // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
28 // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
31 
32 #pragma once
33 #include <array>
34 #include <atomic>
35 #include <boost/asio/io_service.hpp>
36 #include <boost/asio/ip/tcp.hpp>
37 #include <boost/thread.hpp>
38 #include <boost/optional/optional_fwd.hpp>
39 #include <boost/program_options/options_description.hpp>
40 #include <boost/program_options/variables_map.hpp>
41 #include <boost/uuid/uuid.hpp>
42 #include <functional>
43 #include <utility>
44 #include <vector>
45 
46 #include "cryptonote_config.h"
47 #include "warnings.h"
51 #include "p2p_protocol_defs.h"
53 #include "net_peerlist.h"
54 #include "math_helper.h"
55 #include "net_node_common.h"
56 #include "net/enums.h"
57 #include "net/fwd.h"
58 #include "common/command_line.h"
59 
62 
63 namespace nodetool
64 {
65  struct proxy
66  {
68  : max_connections(-1),
69  address(),
70  zone(epee::net_utils::zone::invalid)
71  {}
72 
74  boost::asio::ip::tcp::endpoint address;
76  };
77 
79  {
81  : max_connections(-1),
82  local_ip(),
83  local_port(),
84  our_address(),
85  default_remote()
86  {}
87 
93  };
94 
95  boost::optional<std::vector<proxy>> get_proxies(const boost::program_options::variables_map& vm);
96  boost::optional<std::vector<anonymous_inbound>> get_anonymous_inbounds(const boost::program_options::variables_map& vm);
97 
100 
101  // hides boost::future and chrono stuff from mondo template file
102  boost::optional<boost::asio::ip::tcp::socket>
103  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);
104 
105 
106  template<class base_type>
107  struct p2p_connection_context_t: base_type //t_payload_net_handler::connection_context //public net_utils::connection_context_base
108  {
109  p2p_connection_context_t(): peer_id(0), support_flags(0), m_in_timedsync(false) {}
110 
114  };
115 
116  template<class t_payload_net_handler>
117  class node_server: public epee::levin::levin_commands_handler<p2p_connection_context_t<typename t_payload_net_handler::connection_context> >,
118  public i_p2p_endpoint<typename t_payload_net_handler::connection_context>,
120  {
121  struct by_conn_id{};
122  struct by_peer_id{};
123  struct by_addr{};
124 
126 
129 
131 
132  struct network_zone;
133  using connect_func = boost::optional<p2p_connection_context>(network_zone&, epee::net_utils::network_address const&, epee::net_utils::ssl_support_t);
134 
135  struct config_t
136  {
137  config_t()
138  : m_net_config(),
139  m_peer_id(crypto::rand<uint64_t>()),
140  m_support_flags(0)
141  {}
142 
143  network_config m_net_config;
144  uint64_t m_peer_id;
145  uint32_t m_support_flags;
146  };
148 
149  struct network_zone
150  {
151  network_zone()
152  : m_connect(nullptr),
154  m_bind_ip(),
155  m_port(),
156  m_our_address(),
157  m_peerlist(),
158  m_config{},
159  m_proxy_address(),
160  m_current_number_of_out_peers(0),
161  m_current_number_of_in_peers(0),
162  m_can_pingback(false)
163  {
164  set_config_defaults();
165  }
166 
167  network_zone(boost::asio::io_service& public_service)
168  : m_connect(nullptr),
169  m_net_server(public_service, epee::net_utils::e_connection_type_P2P),
170  m_bind_ip(),
171  m_port(),
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  connect_func* m_connect;
184  net_server m_net_server;
185  std::string m_bind_ip;
187  epee::net_utils::network_address m_our_address; // in anonymity networks
188  peerlist_manager m_peerlist;
190  boost::asio::ip::tcp::endpoint m_proxy_address;
191  std::atomic<unsigned int> m_current_number_of_out_peers;
192  std::atomic<unsigned int> m_current_number_of_in_peers;
193  bool m_can_pingback;
194 
195  private:
196  void set_config_defaults() noexcept
197  {
198  // at this moment we have a hardcoded config
199  m_config.m_net_config.handshake_interval = P2P_DEFAULT_HANDSHAKE_INTERVAL;
200  m_config.m_net_config.packet_max_size = P2P_DEFAULT_PACKET_MAX_SIZE;
201  m_config.m_net_config.config_id = 0;
202  m_config.m_net_config.connection_timeout = P2P_DEFAULT_CONNECTION_TIMEOUT;
203  m_config.m_net_config.ping_connection_timeout = P2P_DEFAULT_PING_CONNECTION_TIMEOUT;
204  m_config.m_net_config.send_peerlist_sz = P2P_DEFAULT_PEERS_IN_HANDSHAKE;
205  m_config.m_support_flags = 0; // only set in public zone
206  }
207  };
208 
209  public:
210  typedef t_payload_net_handler payload_net_handler;
211 
212  node_server(t_payload_net_handler& payload_handler)
213  : m_payload_handler(payload_handler),
214  m_external_port(0),
215  m_rpc_port(0),
216  m_allow_local_ip(false),
217  m_hide_my_port(false),
218  m_no_igd(false),
219  m_offline(false),
220  m_save_graph(false),
221  is_closing(false),
222  m_network_id()
223  {}
224  virtual ~node_server();
225 
226  static void init_options(boost::program_options::options_description& desc);
227 
228  bool run();
229  network_zone& add_zone(epee::net_utils::zone zone);
230  bool init(const boost::program_options::variables_map& vm);
231  bool deinit();
232  bool send_stop_signal();
233  uint32_t get_this_peer_port(){return m_listening_port;}
234  t_payload_net_handler& get_payload_object();
235 
236  // debug functions
237  bool log_peerlist();
238  bool log_connections();
239 
240  // These functions only return information for the "public" zone
241  virtual uint64_t get_public_connections_count();
242  size_t get_public_outgoing_connections_count();
243  size_t get_public_white_peers_count();
244  size_t get_public_gray_peers_count();
245  void get_public_peerlist(std::vector<peerlist_entry>& gray, std::vector<peerlist_entry>& white);
246  size_t get_zone_count() const { return m_network_zones.size(); }
247 
248  void change_max_out_public_peers(size_t count);
249  void change_max_in_public_peers(size_t count);
250  virtual bool block_host(const epee::net_utils::network_address &adress, time_t seconds = P2P_IP_BLOCKTIME);
251  virtual bool unblock_host(const epee::net_utils::network_address &address);
252  virtual std::map<std::string, time_t> get_blocked_hosts() { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return m_blocked_hosts; }
253 
254  virtual void add_used_stripe_peer(const typename t_payload_net_handler::connection_context &context);
255  virtual void remove_used_stripe_peer(const typename t_payload_net_handler::connection_context &context);
256  virtual void clear_used_stripe_peers();
257 
258  private:
259  const std::vector<std::string> m_seed_nodes_list =
260  {
261  "seeds.electroneumseed.com",
262  "seeds.electroneumseed.info",
263  "seeds.electroneumseed.org",
264  "seeds.electroneumseed.net",
265  };
266 
267  bool islimitup=false;
268  bool islimitdown=false;
269 
270  typedef COMMAND_REQUEST_STAT_INFO_T<typename t_payload_net_handler::stat_info> COMMAND_REQUEST_STAT_INFO;
271 
272  CHAIN_LEVIN_INVOKE_MAP2(p2p_connection_context); //move levin_commands_handler interface invoke(...) callbacks into invoke map
273  CHAIN_LEVIN_NOTIFY_MAP2(p2p_connection_context); //move levin_commands_handler interface notify(...) callbacks into nothing
274 
275  BEGIN_INVOKE_MAP2(node_server)
276  if (is_filtered_command(context.m_remote_address, command))
278 
279  HANDLE_INVOKE_T2(COMMAND_HANDSHAKE, &node_server::handle_handshake)
280  HANDLE_INVOKE_T2(COMMAND_TIMED_SYNC, &node_server::handle_timed_sync)
281  HANDLE_INVOKE_T2(COMMAND_PING, &node_server::handle_ping)
282 #ifdef ALLOW_DEBUG_COMMANDS
283  HANDLE_INVOKE_T2(COMMAND_REQUEST_STAT_INFO, &node_server::handle_get_stat_info)
284  HANDLE_INVOKE_T2(COMMAND_REQUEST_NETWORK_STATE, &node_server::handle_get_network_state)
285  HANDLE_INVOKE_T2(COMMAND_REQUEST_PEER_ID, &node_server::handle_get_peer_id)
286 #endif
287  HANDLE_INVOKE_T2(COMMAND_REQUEST_SUPPORT_FLAGS, &node_server::handle_get_support_flags)
288  CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(m_payload_handler, typename t_payload_net_handler::connection_context&)
290 
291  enum PeerType { anchor = 0, white, gray };
292 
293  //----------------- commands handlers ----------------------------------------------
294  int handle_handshake(int command, typename COMMAND_HANDSHAKE::request& arg, typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context);
295  int handle_timed_sync(int command, typename COMMAND_TIMED_SYNC::request& arg, typename COMMAND_TIMED_SYNC::response& rsp, p2p_connection_context& context);
296  int handle_ping(int command, COMMAND_PING::request& arg, COMMAND_PING::response& rsp, p2p_connection_context& context);
297 #ifdef ALLOW_DEBUG_COMMANDS
298  int handle_get_stat_info(int command, typename COMMAND_REQUEST_STAT_INFO::request& arg, typename COMMAND_REQUEST_STAT_INFO::response& rsp, p2p_connection_context& context);
299  int handle_get_network_state(int command, COMMAND_REQUEST_NETWORK_STATE::request& arg, COMMAND_REQUEST_NETWORK_STATE::response& rsp, p2p_connection_context& context);
300  int handle_get_peer_id(int command, COMMAND_REQUEST_PEER_ID::request& arg, COMMAND_REQUEST_PEER_ID::response& rsp, p2p_connection_context& context);
301 #endif
302  int handle_get_support_flags(int command, COMMAND_REQUEST_SUPPORT_FLAGS::request& arg, COMMAND_REQUEST_SUPPORT_FLAGS::response& rsp, p2p_connection_context& context);
303  bool init_config();
304  bool make_default_peer_id();
305  bool make_default_config();
306  bool store_config();
307  bool check_trust(const proof_of_trust& tr, epee::net_utils::zone zone_type);
308 
309 
310  //----------------- levin_commands_handler -------------------------------------------------------------
311  virtual void on_connection_new(p2p_connection_context& context);
312  virtual void on_connection_close(p2p_connection_context& context);
313  virtual void callback(p2p_connection_context& context);
314  //----------------- i_p2p_endpoint -------------------------------------------------------------
315  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);
316  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);
317  virtual bool invoke_notify_to_peer(int command, const epee::span<const uint8_t> req_buff, const epee::net_utils::connection_context_base& context);
318  virtual bool drop_connection(const epee::net_utils::connection_context_base& context);
319  virtual void request_callback(const epee::net_utils::connection_context_base& context);
320  virtual void for_each_connection(std::function<bool(typename t_payload_net_handler::connection_context&, peerid_type, uint32_t)> f);
321  virtual bool for_connection(const boost::uuids::uuid&, std::function<bool(typename t_payload_net_handler::connection_context&, peerid_type, uint32_t)> f);
322  virtual bool add_host_fail(const epee::net_utils::network_address &address);
323  //----------------- i_connection_filter --------------------------------------------------------
324  virtual bool is_remote_host_allowed(const epee::net_utils::network_address &address);
325  //-----------------------------------------------------------------------------------------------
326  bool parse_peer_from_string(epee::net_utils::network_address& pe, const std::string& node_addr, uint16_t default_port = 0);
327  bool handle_command_line(
328  const boost::program_options::variables_map& vm
329  );
330  bool idle_worker();
331  bool handle_remote_peerlist(const std::vector<peerlist_entry>& peerlist, time_t local_time, const epee::net_utils::connection_context_base& context);
332  bool get_local_node_data(basic_node_data& node_data, const network_zone& zone);
333  //bool get_local_handshake_data(handshake_data& hshd);
334 
335  bool merge_peerlist_with_local(const std::vector<peerlist_entry>& bs);
336  bool fix_time_delta(std::vector<peerlist_entry>& local_peerlist, time_t local_time, int64_t& delta);
337 
338  bool connections_maker();
339  bool peer_sync_idle_maker();
340  bool do_handshake_with_peer(peerid_type& pi, p2p_connection_context& context, bool just_take_peerlist = false);
341  bool do_peer_timed_sync(const epee::net_utils::connection_context_base& context, peerid_type peer_id);
342 
343  bool make_new_connection_from_anchor_peerlist(const std::vector<anchor_peerlist_entry>& anchor_peerlist);
344  bool make_new_connection_from_peerlist(network_zone& zone, bool use_white_list);
345  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);
346  size_t get_random_index_with_fixed_probability(size_t max_index);
347  bool is_peer_used(const peerlist_entry& peer);
348  bool is_peer_used(const anchor_peerlist_entry& peer);
349  bool is_addr_connected(const epee::net_utils::network_address& peer);
350  void add_upnp_port_mapping(uint32_t port);
351  void delete_upnp_port_mapping(uint32_t port);
352  template<class t_callback>
353  bool try_ping(basic_node_data& node_data, p2p_connection_context& context, const t_callback &cb);
354  bool try_get_support_flags(const p2p_connection_context& context, std::function<void(p2p_connection_context&, const uint32_t&)> f);
355  bool make_expected_connections_count(network_zone& zone, PeerType peer_type, size_t expected_connections);
356  void cache_connect_fail_info(const epee::net_utils::network_address& addr);
357  bool is_addr_recently_failed(const epee::net_utils::network_address& addr);
358  bool is_priority_node(const epee::net_utils::network_address& na);
359  std::set<std::string> get_seed_nodes(cryptonote::network_type nettype) const;
360  bool connect_to_seed();
361 
362  template <class Container>
363  bool connect_to_peerlist(const Container& peers);
364 
365  template <class Container>
366  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);
367 
368  bool set_max_out_peers(network_zone& zone, int64_t max);
369  bool set_max_in_peers(network_zone& zone, int64_t max);
370  bool set_tos_flag(const boost::program_options::variables_map& vm, int limit);
371 
372  bool set_rate_up_limit(const boost::program_options::variables_map& vm, int64_t limit);
373  bool set_rate_down_limit(const boost::program_options::variables_map& vm, int64_t limit);
374  bool set_rate_limit(const boost::program_options::variables_map& vm, int64_t limit);
375 
376  bool has_too_many_connections(const epee::net_utils::network_address &address);
377  uint64_t get_connections_count();
378  size_t get_incoming_connections_count();
379  size_t get_incoming_connections_count(network_zone&);
380  size_t get_outgoing_connections_count();
381  size_t get_outgoing_connections_count(network_zone&);
382 
383  bool check_connection_and_handshake_with_peer(const epee::net_utils::network_address& na, uint64_t last_seen_stamp);
384  bool gray_peerlist_housekeeping();
385  bool check_incoming_connections();
386 
387  void kill() {
388  _info("Killing the net_node");
389  is_closing = true;
390  if(mPeersLoggerThread != nullptr)
391  mPeersLoggerThread->join(); // make sure the thread finishes
392  _info("Joined extra background net_node threads");
393  }
394 
395  //debug functions
396  std::string print_connections_container();
397 
398 
399  public:
400 
401  void set_save_graph(bool save_graph)
402  {
403  m_save_graph = save_graph;
405  }
406 
407  void set_rpc_port(uint16_t rpc_port)
408  {
409  m_rpc_port = rpc_port;
410  }
411 
412  private:
413  std::string m_config_folder;
414 
415  bool m_have_address;
416  bool m_first_connection_maker_call;
417  uint32_t m_listening_port;
418  uint32_t m_external_port;
419  uint16_t m_rpc_port;
420  bool m_allow_local_ip;
421  bool m_hide_my_port;
422  bool m_no_igd;
423  bool m_offline;
424  std::atomic<bool> m_save_graph;
425  std::atomic<bool> is_closing;
426  std::unique_ptr<boost::thread> mPeersLoggerThread;
427  //critical_section m_connections_lock;
428  //connections_indexed_container m_connections;
429 
430  t_payload_net_handler& m_payload_handler;
431  peerlist_storage m_peerlist_storage;
432 
434  epee::math_helper::once_a_time_seconds<1> m_connections_maker_interval;
436  epee::math_helper::once_a_time_seconds<60> m_gray_peerlist_housekeeping_interval;
437  epee::math_helper::once_a_time_seconds<3600, false> m_incoming_connections_interval;
438 
439 #ifdef ALLOW_DEBUG_COMMANDS
440  uint64_t m_last_stat_request_time;
441 #endif
442  std::list<epee::net_utils::network_address> m_priority_peers;
443  std::vector<epee::net_utils::network_address> m_exclusive_peers;
444  std::vector<epee::net_utils::network_address> m_seed_nodes;
445  bool m_fallback_seed_nodes_added;
446  std::vector<nodetool::peerlist_entry> m_command_line_peers;
447  uint64_t m_peer_livetime;
448  //keep connections to initiate some interactions
449 
450 
451  static boost::optional<p2p_connection_context> public_connect(network_zone&, epee::net_utils::network_address const&, epee::net_utils::ssl_support_t);
452  static boost::optional<p2p_connection_context> socks_connect(network_zone&, epee::net_utils::network_address const&, epee::net_utils::ssl_support_t);
453 
454 
455  /* A `std::map` provides constant iterators and key/value pointers even with
456  inserts/erases to _other_ elements. This makes the configuration step easier
457  since references can safely be stored on the stack. Do not insert/erase
458  after configuration and before destruction, lock safety would need to be
459  added. `std::map::operator[]` WILL insert! */
460  std::map<epee::net_utils::zone, network_zone> m_network_zones;
461 
462 
463  std::map<epee::net_utils::network_address, time_t> m_conn_fails_cache;
464  epee::critical_section m_conn_fails_cache_lock;
465 
466  epee::critical_section m_blocked_hosts_lock;
467  std::map<std::string, time_t> m_blocked_hosts;
468 
469  epee::critical_section m_host_fails_score_lock;
470  std::map<std::string, uint64_t> m_host_fails_score;
471 
472  boost::mutex m_used_stripe_peers_mutex;
473  std::array<std::list<epee::net_utils::network_address>, 1 << CRYPTONOTE_PRUNING_LOG_STRIPES> m_used_stripe_peers;
474 
475  boost::uuids::uuid m_network_id;
476  cryptonote::network_type m_nettype;
477 
478  epee::net_utils::ssl_support_t m_ssl_support;
479  };
480 
495 
501 
505 
507 }
508 
510 
#define P2P_DEFAULT_HANDSHAKE_INTERVAL
#define tr(x)
Definition: common_defines.h:4
PUSH_WARNINGS
Definition: hash-ops.h:54
void init_options(boost::program_options::options_description &hidden_options, boost::program_options::options_description &normal_options)
boost::uuids::uuid uuid
const command_line::arg_descriptor< std::vector< std::string > > arg_anonymous_inbound
Definition: net_node.cpp:133
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT
::std::string string
Definition: gtest-port.h:1097
epee::misc_utils::struct_init< response_t > response
#define LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED
Definition: levin_base.h:99
#define CRYPTONOTE_PRUNING_LOG_STRIPES
#define _info(x)
Definition: misc_log_ex.h:108
const command_line::arg_descriptor< int > arg_tos_flag
Definition: net_node.cpp:140
peerlist_entry_base< epee::net_utils::network_address > peerlist_entry
boost::optional< std::vector< anonymous_inbound > > get_anonymous_inbounds(boost::program_options::variables_map const &vm)
Definition: net_node.cpp:206
unsigned short uint16_t
Definition: stdint.h:125
const command_line::arg_descriptor< bool > arg_no_sync
Definition: net_node.cpp:135
Non-owning sequence of data. Does not deep copy.
Definition: span.h:56
const command_line::arg_descriptor< int64_t > arg_out_peers
Definition: net_node.cpp:138
const command_line::arg_descriptor< std::string, false, true, 2 > arg_p2p_bind_port
Definition: net_node.cpp:112
const int64_t default_limit_down
Definition: net_node.h:482
#define CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(obj, context_type)
const command_line::arg_descriptor< std::string > arg_p2p_bind_ip
Definition: net_node.cpp:111
#define P2P_IP_BLOCKTIME
const command_line::arg_descriptor< std::vector< std::string > > arg_proxy
Definition: net_node.cpp:132
#define P2P_DEFAULT_LIMIT_RATE_DOWN
#define BEGIN_INVOKE_MAP2(owner_type)
const command_line::arg_descriptor< int64_t > arg_limit_rate_down
Definition: net_node.cpp:143
boost::asio::ip::tcp::endpoint address
Definition: net_node.h:74
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_add_peer
Definition: net_node.cpp:127
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE
static void set_save_graph(bool save_graph)
mdb_size_t count(MDB_cursor *cur)
bool is_filtered_command(const epee::net_utils::network_address &address, int command)
Definition: net_node.cpp:273
size_t get_zone_count() const
Definition: net_node.h:246
virtual std::map< std::string, time_t > get_blocked_hosts()
Definition: net_node.h:252
unsigned int uint32_t
Definition: stdint.h:126
#define POP_WARNINGS
Definition: warnings.h:17
const int64_t default_limit_up
Definition: net_node.h:481
#define P2P_DEFAULT_CONNECTION_TIMEOUT
the connection templated-class for one peer connection
const command_line::arg_descriptor< int64_t > arg_limit_rate_up
Definition: net_node.cpp:142
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_add_priority_node
Definition: net_node.cpp:128
unsigned __int64 uint64_t
Definition: stdint.h:136
epee::net_utils::network_address default_remote
Definition: net_node.h:92
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:228
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:98
std::int64_t max_connections
Definition: net_node.h:73
uint64_t peerid_type
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_add_exclusive_node
Definition: net_node.cpp:129
#define false
Definition: stdbool.h:38
#define END_INVOKE_MAP2()
void set_save_graph(bool save_graph)
Definition: net_node.h:401
boost::endian::big_uint16_t port
Definition: socks.cpp:60
#define HANDLE_INVOKE_T2(COMMAND, func)
const command_line::arg_descriptor< bool > arg_offline
epee::net_utils::network_address our_address
Definition: net_node.h:91
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_seed_node
Definition: net_node.cpp:131
#define CHAIN_LEVIN_NOTIFY_MAP2(context_type)
const command_line::arg_descriptor< bool > arg_save_graph
Definition: net_node.cpp:146
std::int64_t max_connections
Definition: net_node.h:88
boost::optional< std::vector< proxy > > get_proxies(boost::program_options::variables_map const &vm)
Definition: net_node.cpp:148
const command_line::arg_descriptor< bool > arg_p2p_hide_my_port
Definition: net_node.cpp:134
anchor_peerlist_entry_base< epee::net_utils::network_address > anchor_peerlist_entry
const command_line::arg_descriptor< bool > arg_no_igd
Definition: net_node.cpp:137
epee::net_utils::zone zone
Definition: net_node.h:75
signed __int64 int64_t
Definition: stdint.h:135
TProtocol::config_type m_config
uint32_t get_this_peer_port()
Definition: net_node.h:233
t_payload_net_handler payload_net_handler
Definition: net_node.h:210
DISABLE_VS_WARNINGS(4244 4345 4503) using namespace crypto
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:293
node_server(t_payload_net_handler &payload_handler)
Definition: net_node.h:212
const char * address
Definition: multisig.cpp:37
#define P2P_DEFAULT_LIMIT_RATE_UP
#define CHAIN_LEVIN_INVOKE_MAP2(context_type)
const command_line::arg_descriptor< int64_t > arg_limit_rate
Definition: net_node.cpp:144
const command_line::arg_descriptor< uint32_t > arg_p2p_external_port
Definition: net_node.cpp:125
void set_rpc_port(uint16_t rpc_port)
Definition: net_node.h:407
const command_line::arg_descriptor< bool > arg_p2p_allow_local_ip
Definition: net_node.cpp:126
const command_line::arg_descriptor< int64_t > arg_in_peers
Definition: net_node.cpp:139
#define P2P_DEFAULT_PACKET_MAX_SIZE
bool parse_peer_from_string(uint32_t &ip, uint16_t &port, const std::string &addres)
Definition: string_tools.h:174