Monero
Loading...
Searching...
No Matches
net_node.h
Go to the documentation of this file.
1// Copyright (c) 2014-2022, 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"
53#include "p2p_protocol_defs.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
65namespace 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;
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;
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
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 : peer_id(0),
115 support_flags(0),
116 m_in_timedsync(false)
117 {}
118
122 std::set<epee::net_utils::network_address> sent_addresses;
123 };
124
125 template<class t_payload_net_handler>
126 class node_server: public epee::levin::levin_commands_handler<p2p_connection_context_t<typename t_payload_net_handler::connection_context> >,
127 public i_p2p_endpoint<typename t_payload_net_handler::connection_context>,
129 {
130 struct by_conn_id{};
131 struct by_peer_id{};
132 struct by_addr{};
133
135
138 static_assert(p2p_connection_context::handshake_command() == COMMAND_HANDSHAKE::ID, "invalid handshake command id");
139
141
142 struct network_zone;
143 using connect_func = boost::optional<p2p_connection_context>(network_zone&, epee::net_utils::network_address const&, epee::net_utils::ssl_support_t);
144
145 struct config_t
146 {
148 : m_net_config(),
149 m_peer_id(1),
150 m_support_flags(0)
151 {}
152
156 };
158
160 {
162 : m_connect(nullptr),
163 m_net_server(epee::net_utils::e_connection_type_P2P),
164 m_seed_nodes(),
165 m_bind_ip(),
166 m_bind_ipv6_address(),
167 m_port(),
168 m_port_ipv6(),
169 m_notifier(),
170 m_our_address(),
171 m_peerlist(),
172 m_config{},
173 m_proxy_address(),
174 m_current_number_of_out_peers(0),
175 m_current_number_of_in_peers(0),
176 m_seed_nodes_lock(),
177 m_can_pingback(false),
178 m_seed_nodes_initialized(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_seed_nodes(),
187 m_bind_ip(),
188 m_bind_ipv6_address(),
189 m_port(),
190 m_port_ipv6(),
191 m_notifier(),
192 m_our_address(),
193 m_peerlist(),
194 m_config{},
195 m_proxy_address(),
196 m_current_number_of_out_peers(0),
197 m_current_number_of_in_peers(0),
198 m_seed_nodes_lock(),
199 m_can_pingback(false),
200 m_seed_nodes_initialized(false)
201 {
202 set_config_defaults();
203 }
204
207 std::vector<epee::net_utils::network_address> m_seed_nodes;
208 std::string m_bind_ip;
210 std::string m_port;
211 std::string m_port_ipv6;
216 boost::asio::ip::tcp::endpoint m_proxy_address;
217 std::atomic<unsigned int> m_current_number_of_out_peers;
218 std::atomic<unsigned int> m_current_number_of_in_peers;
219 boost::shared_mutex m_seed_nodes_lock;
222
223 private:
224 void set_config_defaults() noexcept
225 {
226 // at this moment we have a hardcoded config
227 m_config.m_net_config.handshake_interval = P2P_DEFAULT_HANDSHAKE_INTERVAL;
228 m_config.m_net_config.packet_max_size = P2P_DEFAULT_PACKET_MAX_SIZE;
229 m_config.m_net_config.config_id = 0;
230 m_config.m_net_config.connection_timeout = P2P_DEFAULT_CONNECTION_TIMEOUT;
231 m_config.m_net_config.ping_connection_timeout = P2P_DEFAULT_PING_CONNECTION_TIMEOUT;
232 m_config.m_net_config.send_peerlist_sz = P2P_DEFAULT_PEERS_IN_HANDSHAKE;
233 m_config.m_support_flags = 0; // only set in public zone
234 }
235 };
236
237 enum igd_t
238 {
242 };
243
244 public:
245 typedef t_payload_net_handler payload_net_handler;
246
247 node_server(t_payload_net_handler& payload_handler)
248 : m_payload_handler(payload_handler),
249 m_external_port(0),
250 m_rpc_port(0),
251 m_rpc_credits_per_hash(0),
252 m_allow_local_ip(false),
253 m_hide_my_port(false),
254 m_igd(no_igd),
255 m_offline(false),
256 is_closing(false),
257 m_network_id(),
258 m_enable_dns_seed_nodes(true),
259 max_connections(1)
260 {}
261 virtual ~node_server();
262
263 static void init_options(boost::program_options::options_description& desc);
264
265 bool run();
266 network_zone& add_zone(epee::net_utils::zone zone);
267 bool init(const boost::program_options::variables_map& vm, const std::string& proxy = {}, bool proxy_dns_leaks_allowed = {});
268 bool deinit();
269 bool send_stop_signal();
270 uint32_t get_this_peer_port(){return m_listening_port;}
271 t_payload_net_handler& get_payload_object();
272
273 // debug functions
274 bool log_peerlist();
275 bool log_connections();
276
277 // These functions only return information for the "public" zone
278 virtual uint64_t get_public_connections_count();
279 size_t get_public_outgoing_connections_count();
280 size_t get_public_white_peers_count();
281 size_t get_public_gray_peers_count();
282 void get_public_peerlist(std::vector<peerlist_entry>& gray, std::vector<peerlist_entry>& white);
283 void get_peerlist(std::vector<peerlist_entry>& gray, std::vector<peerlist_entry>& white);
284
285 void change_max_out_public_peers(size_t count);
286 uint32_t get_max_out_public_peers() const;
287 void change_max_in_public_peers(size_t count);
288 uint32_t get_max_in_public_peers() const;
289 virtual bool block_host(epee::net_utils::network_address address, time_t seconds = P2P_IP_BLOCKTIME, bool add_only = false);
290 virtual bool unblock_host(const epee::net_utils::network_address &address);
291 virtual bool block_subnet(const epee::net_utils::ipv4_network_subnet &subnet, time_t seconds = P2P_IP_BLOCKTIME);
292 virtual bool unblock_subnet(const epee::net_utils::ipv4_network_subnet &subnet);
293 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); }
294 virtual std::map<std::string, time_t> get_blocked_hosts() { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return m_blocked_hosts; }
295 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; }
296
297 virtual void add_used_stripe_peer(const typename t_payload_net_handler::connection_context &context);
298 virtual void remove_used_stripe_peer(const typename t_payload_net_handler::connection_context &context);
299 virtual void clear_used_stripe_peers();
300
301 private:
302 const std::vector<std::string> m_seed_nodes_list =
303 { "seeds.moneroseeds.se"
304 , "seeds.moneroseeds.ae.org"
305 , "seeds.moneroseeds.ch"
306 , "seeds.moneroseeds.li"
307 };
308
309 bool islimitup=false;
310 bool islimitdown=false;
311
312 CHAIN_LEVIN_INVOKE_MAP2(p2p_connection_context); //move levin_commands_handler interface invoke(...) callbacks into invoke map
313 CHAIN_LEVIN_NOTIFY_MAP2(p2p_connection_context); //move levin_commands_handler interface notify(...) callbacks into nothing
314
316 if (is_filtered_command(context.m_remote_address, command))
318
323 CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(m_payload_handler, typename t_payload_net_handler::connection_context&)
325
326 enum PeerType { anchor = 0, white, gray };
327
328 //----------------- commands handlers ----------------------------------------------
329 int handle_handshake(int command, typename COMMAND_HANDSHAKE::request& arg, typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context);
330 int handle_timed_sync(int command, typename COMMAND_TIMED_SYNC::request& arg, typename COMMAND_TIMED_SYNC::response& rsp, p2p_connection_context& context);
331 int handle_ping(int command, COMMAND_PING::request& arg, COMMAND_PING::response& rsp, p2p_connection_context& context);
332 int handle_get_support_flags(int command, COMMAND_REQUEST_SUPPORT_FLAGS::request& arg, COMMAND_REQUEST_SUPPORT_FLAGS::response& rsp, p2p_connection_context& context);
333 bool init_config();
336 bool store_config();
337
338
339 //----------------- levin_commands_handler -------------------------------------------------------------
340 virtual void on_connection_new(p2p_connection_context& context);
341 virtual void on_connection_close(p2p_connection_context& context);
342 virtual void callback(p2p_connection_context& context);
343 //----------------- i_p2p_endpoint -------------------------------------------------------------
344 virtual bool relay_notify_to_list(int command, epee::levin::message_writer message, std::vector<std::pair<epee::net_utils::zone, boost::uuids::uuid>> connections) final;
345 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);
346 virtual bool invoke_notify_to_peer(int command, epee::levin::message_writer message, const epee::net_utils::connection_context_base& context) final;
347 virtual bool drop_connection(const epee::net_utils::connection_context_base& context);
348 virtual void request_callback(const epee::net_utils::connection_context_base& context);
349 virtual void for_each_connection(std::function<bool(typename t_payload_net_handler::connection_context&, peerid_type, uint32_t)> f);
350 virtual bool for_connection(const boost::uuids::uuid&, std::function<bool(typename t_payload_net_handler::connection_context&, peerid_type, uint32_t)> f);
351 virtual bool add_host_fail(const epee::net_utils::network_address &address, unsigned int score = 1);
352 //----------------- i_connection_filter --------------------------------------------------------
353 virtual bool is_remote_host_allowed(const epee::net_utils::network_address &address, time_t *t = NULL);
354 //-----------------------------------------------------------------------------------------------
355 bool parse_peer_from_string(epee::net_utils::network_address& pe, const std::string& node_addr, uint16_t default_port = 0);
356 bool handle_command_line(
357 const boost::program_options::variables_map& vm
358 );
359 bool idle_worker();
360 bool handle_remote_peerlist(const std::vector<peerlist_entry>& peerlist, const epee::net_utils::connection_context_base& context);
361 bool get_local_node_data(basic_node_data& node_data, const network_zone& zone);
362 //bool get_local_handshake_data(handshake_data& hshd);
363
364 bool sanitize_peerlist(std::vector<peerlist_entry>& local_peerlist);
365
366 bool connections_maker();
367 bool peer_sync_idle_maker();
368 bool do_handshake_with_peer(peerid_type& pi, p2p_connection_context& context, bool just_take_peerlist = false);
369 bool do_peer_timed_sync(const epee::net_utils::connection_context_base& context, peerid_type peer_id);
370 bool update_dns_blocklist();
371
372 bool make_new_connection_from_anchor_peerlist(const std::vector<anchor_peerlist_entry>& anchor_peerlist);
373 bool make_new_connection_from_peerlist(network_zone& zone, bool use_white_list);
374 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);
375 size_t get_random_index_with_fixed_probability(size_t max_index);
376 bool is_peer_used(const peerlist_entry& peer);
377 bool is_peer_used(const anchor_peerlist_entry& peer);
378 bool is_addr_connected(const epee::net_utils::network_address& peer);
379 void add_upnp_port_mapping_impl(uint32_t port, bool ipv6=false);
380 void add_upnp_port_mapping_v4(uint32_t port);
381 void add_upnp_port_mapping_v6(uint32_t port);
382 void add_upnp_port_mapping(uint32_t port, bool ipv4=true, bool ipv6=false);
383 void delete_upnp_port_mapping_impl(uint32_t port, bool ipv6=false);
384 void delete_upnp_port_mapping_v4(uint32_t port);
385 void delete_upnp_port_mapping_v6(uint32_t port);
386 void delete_upnp_port_mapping(uint32_t port);
387 template<class t_callback>
388 bool try_ping(basic_node_data& node_data, p2p_connection_context& context, const t_callback &cb);
389 bool try_get_support_flags(const p2p_connection_context& context, std::function<void(p2p_connection_context&, const uint32_t&)> f);
390 bool make_expected_connections_count(network_zone& zone, PeerType peer_type, size_t expected_connections);
391 void record_addr_failed(const epee::net_utils::network_address& addr);
392 bool is_addr_recently_failed(const epee::net_utils::network_address& addr);
393 bool is_priority_node(const epee::net_utils::network_address& na);
394 std::set<std::string> get_ip_seed_nodes() const;
395 std::set<std::string> get_dns_seed_nodes();
396 std::set<std::string> get_seed_nodes(epee::net_utils::zone);
397 bool connect_to_seed(epee::net_utils::zone);
398
399 template <class Container>
400 bool connect_to_peerlist(const Container& peers);
401
402 template <class Container>
403 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);
404
405 bool set_max_out_peers(network_zone& zone, int64_t max);
406 bool set_max_in_peers(network_zone& zone, int64_t max);
407 bool set_tos_flag(const boost::program_options::variables_map& vm, int limit);
408
409 bool set_rate_up_limit(const boost::program_options::variables_map& vm, int64_t limit);
410 bool set_rate_down_limit(const boost::program_options::variables_map& vm, int64_t limit);
411 bool set_rate_limit(const boost::program_options::variables_map& vm, int64_t limit);
412
413 bool has_too_many_connections(const epee::net_utils::network_address &address);
414 size_t get_incoming_connections_count();
415 size_t get_incoming_connections_count(network_zone&);
416 size_t get_outgoing_connections_count();
417 size_t get_outgoing_connections_count(network_zone&);
418
419 bool check_connection_and_handshake_with_peer(const epee::net_utils::network_address& na, uint64_t last_seen_stamp);
420 bool gray_peerlist_housekeeping();
421 bool check_incoming_connections();
422
423 void kill() {
424 _info("Killing the net_node");
425 is_closing = true;
426 if(mPeersLoggerThread != nullptr)
427 mPeersLoggerThread->join(); // make sure the thread finishes
428 _info("Joined extra background net_node threads");
429 }
430
431 //debug functions
432 std::string print_connections_container();
433
434
435 public:
436
437 void set_rpc_port(uint16_t rpc_port)
438 {
439 m_rpc_port = rpc_port;
440 }
441
442 void set_rpc_credits_per_hash(uint32_t rpc_credits_per_hash)
443 {
444 m_rpc_credits_per_hash = rpc_credits_per_hash;
445 }
446
447 private:
448 std::string m_config_folder;
449
463 std::atomic<bool> is_closing;
464 std::unique_ptr<boost::thread> mPeersLoggerThread;
465 //critical_section m_connections_lock;
466 //connections_indexed_container m_connections;
467
468 t_payload_net_handler& m_payload_handler;
470
477
478 std::list<epee::net_utils::network_address> m_priority_peers;
479 std::vector<epee::net_utils::network_address> m_exclusive_peers;
481 std::vector<nodetool::peerlist_entry> m_command_line_peers;
483 //keep connections to initiate some interactions
484
485
486 static boost::optional<p2p_connection_context> public_connect(network_zone&, epee::net_utils::network_address const&, epee::net_utils::ssl_support_t);
487 static boost::optional<p2p_connection_context> socks_connect(network_zone&, epee::net_utils::network_address const&, epee::net_utils::ssl_support_t);
488
489
490 /* A `std::map` provides constant iterators and key/value pointers even with
491 inserts/erases to _other_ elements. This makes the configuration step easier
492 since references can safely be stored on the stack. Do not insert/erase
493 after configuration and before destruction, lock safety would need to be
494 added. `std::map::operator[]` WILL insert! */
495 std::map<epee::net_utils::zone, network_zone> m_network_zones;
496
497
498 std::map<std::string, time_t> m_conn_fails_cache;
500
501 epee::critical_section m_blocked_hosts_lock; // for both hosts and subnets
502 std::map<std::string, time_t> m_blocked_hosts;
503 std::map<epee::net_utils::ipv4_network_subnet, time_t> m_blocked_subnets;
504
506 std::map<std::string, uint64_t> m_host_fails_score;
507
509 std::array<std::list<epee::net_utils::network_address>, 1 << CRYPTONOTE_PRUNING_LOG_STRIPES> m_used_stripe_peers;
510
511 boost::uuids::uuid m_network_id;
513
515
518
520 };
521
542
545 extern const command_line::arg_descriptor<bool> arg_offline;
549
555}
556
558
the connection templated-class for one peer connection
Provides tx notification privacy.
Definition: levin_notify.h:70
Definition: syncobj.h:82
Provides space for levin (p2p) header, so that payload can be sent without copy.
Definition: levin_base.h:132
Definition: math_helper.h:297
Definition: abstract_tcp_server2.h:324
Definition: net_utils_base.h:123
Definition: net_utils_base.h:223
Definition: net_node.h:129
virtual bool is_host_blocked(const epee::net_utils::network_address &address, time_t *seconds)
Definition: net_node.h:293
peerlist_storage m_peerlist_storage
Definition: net_node.h:469
std::map< epee::net_utils::zone, network_zone > m_network_zones
Definition: net_node.h:495
bool m_first_connection_maker_call
Definition: net_node.h:451
std::vector< nodetool::peerlist_entry > m_command_line_peers
Definition: net_node.h:481
epee::critical_section m_conn_fails_cache_lock
Definition: net_node.h:499
epee::misc_utils::struct_init< config_t > config
Definition: net_node.h:157
uint64_t m_peer_livetime
Definition: net_node.h:482
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:143
std::list< epee::net_utils::network_address > m_priority_peers
Definition: net_node.h:478
bool m_enable_dns_seed_nodes
Definition: net_node.h:516
boost::mutex m_used_stripe_peers_mutex
Definition: net_node.h:508
bool m_offline
Definition: net_node.h:460
std::string m_config_folder
Definition: net_node.h:448
uint32_t get_this_peer_port()
Definition: net_node.h:270
void kill()
Definition: net_node.h:423
PeerType
Definition: net_node.h:326
std::unique_ptr< boost::thread > mPeersLoggerThread
Definition: net_node.h:464
std::atomic< bool > is_closing
Definition: net_node.h:463
epee::math_helper::once_a_time_seconds< 7000 > m_dns_blocklist_interval
Definition: net_node.h:476
std::map< std::string, time_t > m_blocked_hosts
Definition: net_node.h:502
virtual std::map< std::string, time_t > get_blocked_hosts()
Definition: net_node.h:294
igd_t
Definition: net_node.h:238
@ no_igd
Definition: net_node.h:239
@ igd
Definition: net_node.h:240
@ delayed_igd
Definition: net_node.h:241
CHAIN_LEVIN_NOTIFY_MAP2(p2p_connection_context)
bool m_allow_local_ip
Definition: net_node.h:457
epee::net_utils::boosted_tcp_server< epee::levin::async_protocol_handler< p2p_connection_context > > net_server
Definition: net_node.h:140
epee::critical_section m_blocked_hosts_lock
Definition: net_node.h:501
epee::math_helper::once_a_time_seconds< 60 *30, false > m_peerlist_store_interval
Definition: net_node.h:473
uint32_t m_rpc_credits_per_hash
Definition: net_node.h:456
igd_t m_igd
Definition: net_node.h:459
epee::math_helper::once_a_time_seconds< 1 > m_connections_maker_interval
Definition: net_node.h:472
epee::math_helper::once_a_time_seconds< P2P_DEFAULT_HANDSHAKE_INTERVAL > m_peer_handshake_idle_maker_interval
Definition: net_node.h:471
epee::critical_section m_host_fails_score_lock
Definition: net_node.h:505
void set_rpc_credits_per_hash(uint32_t rpc_credits_per_hash)
Definition: net_node.h:442
epee::math_helper::once_a_time_seconds< 60 > m_gray_peerlist_housekeeping_interval
Definition: net_node.h:474
uint16_t m_rpc_port
Definition: net_node.h:455
uint32_t m_external_port
Definition: net_node.h:454
std::atomic_flag m_fallback_seed_nodes_added
Definition: net_node.h:480
epee::math_helper::once_a_time_seconds< 3600, false > m_incoming_connections_interval
Definition: net_node.h:475
t_payload_net_handler payload_net_handler
Definition: net_node.h:245
uint32_t max_connections
Definition: net_node.h:519
std::map< std::string, uint64_t > m_host_fails_score
Definition: net_node.h:506
COMMAND_HANDSHAKE_T< typename t_payload_net_handler::payload_type > COMMAND_HANDSHAKE
Definition: net_node.h:136
boost::uuids::uuid m_network_id
Definition: net_node.h:511
COMMAND_TIMED_SYNC_T< typename t_payload_net_handler::payload_type > COMMAND_TIMED_SYNC
Definition: net_node.h:137
bool parse_peer_from_string(epee::net_utils::network_address &pe, const std::string &node_addr, uint16_t default_port=0)
virtual std::map< epee::net_utils::ipv4_network_subnet, time_t > get_blocked_subnets()
Definition: net_node.h:295
cryptonote::network_type m_nettype
Definition: net_node.h:512
p2p_connection_context_t< typename t_payload_net_handler::connection_context > p2p_connection_context
Definition: net_node.h:134
t_payload_net_handler & m_payload_handler
Definition: net_node.h:468
bool m_hide_my_port
Definition: net_node.h:458
bool m_enable_dns_blocklist
Definition: net_node.h:517
epee::net_utils::ssl_support_t m_ssl_support
Definition: net_node.h:514
std::map< std::string, time_t > m_conn_fails_cache
Definition: net_node.h:498
uint32_t m_listening_port
Definition: net_node.h:452
CHAIN_LEVIN_INVOKE_MAP2(p2p_connection_context)
std::array< std::list< epee::net_utils::network_address >, 1<< CRYPTONOTE_PRUNING_LOG_STRIPES > m_used_stripe_peers
Definition: net_node.h:509
bool m_have_address
Definition: net_node.h:450
uint32_t m_listening_port_ipv6
Definition: net_node.h:453
bool m_require_ipv4
Definition: net_node.h:462
std::map< epee::net_utils::ipv4_network_subnet, time_t > m_blocked_subnets
Definition: net_node.h:503
std::vector< epee::net_utils::network_address > m_exclusive_peers
Definition: net_node.h:479
node_server(t_payload_net_handler &payload_handler)
Definition: net_node.h:247
bool m_use_ipv6
Definition: net_node.h:461
void set_rpc_port(uint16_t rpc_port)
Definition: net_node.h:437
Definition: net_peerlist.h:100
Definition: net_peerlist.h:63
#define P2P_DEFAULT_PACKET_MAX_SIZE
Definition: cryptonote_config.h:136
#define P2P_DEFAULT_LIMIT_RATE_DOWN
Definition: cryptonote_config.h:148
#define P2P_IP_BLOCKTIME
Definition: cryptonote_config.h:151
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE
Definition: cryptonote_config.h:137
#define CRYPTONOTE_PRUNING_LOG_STRIPES
Definition: cryptonote_config.h:202
#define P2P_DEFAULT_CONNECTION_TIMEOUT
Definition: cryptonote_config.h:139
#define P2P_DEFAULT_LIMIT_RATE_UP
Definition: cryptonote_config.h:147
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT
Definition: cryptonote_config.h:141
#define P2P_DEFAULT_HANDSHAKE_INTERVAL
Definition: cryptonote_config.h:135
int * count
Definition: gmock_stress_test.cc:176
#define END_INVOKE_MAP2()
Definition: levin_abstract_invoke2.h:285
#define CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(obj, context_type)
Definition: levin_abstract_invoke2.h:278
#define BEGIN_INVOKE_MAP2(owner_type)
Definition: levin_abstract_invoke2.h:240
#define HANDLE_INVOKE_T2(COMMAND, func)
Definition: levin_abstract_invoke2.h:250
#define LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED
Definition: levin_base.h:108
relay_method tx_relay
Definition: levin_notify.cpp:545
static void init()
Definition: logging.cpp:38
uint32_t address
Definition: getifaddr.c:269
Definition: cryptonote_config.h:211
network_type
Definition: cryptonote_config.h:289
relay_method
Methods tracking how a tx was received and relayed.
Definition: enums.h:37
zone
Definition: enums.h:50
ssl_support_t
Definition: net_ssl.h:48
TODO: (mj-xmr) This will be reduced in an another PR.
Definition: byte_slice.h:40
Definition: levin_notify.h:52
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_add_priority_node
Definition: net_node.cpp:146
bool is_filtered_command(const epee::net_utils::network_address &address, int command)
Definition: net_node.cpp:310
const command_line::arg_descriptor< int > arg_tos_flag
Definition: net_node.cpp:163
const command_line::arg_descriptor< uint32_t > arg_p2p_external_port
Definition: net_node.cpp:143
const int64_t default_limit_up
Definition: net_node.h:522
const command_line::arg_descriptor< std::string > arg_ban_list
Definition: net_node.cpp:152
const command_line::arg_descriptor< bool > arg_enable_dns_blocklist
Definition: net_node.cpp:155
const command_line::arg_descriptor< bool > arg_pad_transactions
Definition: net_node.cpp:169
uint64_t peerid_type
Definition: p2p_protocol_defs.h:49
const command_line::arg_descriptor< bool > arg_no_igd
Definition: net_node.cpp:157
const command_line::arg_descriptor< std::vector< std::string > > arg_tx_proxy
Definition: net_node.cpp:150
const command_line::arg_descriptor< int64_t > arg_limit_rate
Definition: net_node.cpp:167
const command_line::arg_descriptor< std::string, false, true, 2 > arg_p2p_bind_port
Definition: net_node.cpp:116
const command_line::arg_descriptor< bool > arg_no_sync
Definition: net_node.cpp:154
const command_line::arg_descriptor< bool > arg_p2p_use_ipv6
Definition: net_node.cpp:159
boost::optional< std::vector< anonymous_inbound > > get_anonymous_inbounds(boost::program_options::variables_map const &vm)
Definition: net_node.cpp:243
const command_line::arg_descriptor< bool > arg_p2p_allow_local_ip
Definition: net_node.cpp:144
const command_line::arg_descriptor< int64_t > arg_limit_rate_down
Definition: net_node.cpp:166
const command_line::arg_descriptor< std::string > arg_p2p_bind_ip
Definition: net_node.cpp:114
const command_line::arg_descriptor< int64_t > arg_limit_rate_up
Definition: net_node.cpp:165
boost::optional< std::vector< proxy > > get_proxies(boost::program_options::variables_map const &vm)
Definition: net_node.cpp:174
const command_line::arg_descriptor< std::vector< std::string > > arg_anonymous_inbound
Definition: net_node.cpp:151
const command_line::arg_descriptor< std::string > arg_p2p_bind_ipv6_address
Definition: net_node.cpp:115
const command_line::arg_descriptor< int64_t > arg_out_peers
Definition: net_node.cpp:161
const command_line::arg_descriptor< std::string, false, true, 2 > arg_p2p_bind_port_ipv6
Definition: net_node.cpp:129
const command_line::arg_descriptor< uint32_t > arg_max_connections_per_ip
Definition: net_node.cpp:172
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:330
const command_line::arg_descriptor< bool > arg_p2p_hide_my_port
Definition: net_node.cpp:153
const command_line::arg_descriptor< bool > arg_p2p_ignore_ipv4
Definition: net_node.cpp:160
const command_line::arg_descriptor< std::string > arg_igd
Definition: net_node.cpp:158
const command_line::arg_descriptor< int64_t > arg_in_peers
Definition: net_node.cpp:162
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_seed_node
Definition: net_node.cpp:149
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_add_peer
Definition: net_node.cpp:145
const int64_t default_limit_down
Definition: net_node.h:523
const command_line::arg_descriptor< std::vector< std::string > > arg_p2p_add_exclusive_node
Definition: net_node.cpp:147
const CharType(& source)[N]
Definition: pointer.h:1147
if(!cryptonote::get_account_address_from_str_or_url(info, cryptonote::TESTNET, "9uVsvEryzpN8WH2t1WWhFFCG5tS8cBNdmJYNRuckLENFimfauV5pZKeS1P2CbxGkSDTUPHXWwiYE5ZGSXDAGbaZgDxobqDN"))
Definition: signature.cpp:53
boost::endian::big_uint16_t port
Definition: socks.cpp:59
#define true
Definition: stdbool.h:36
#define false
Definition: stdbool.h:37
unsigned short uint16_t
Definition: stdint.h:125
signed __int64 int64_t
Definition: stdint.h:135
unsigned int uint32_t
Definition: stdint.h:126
unsigned __int64 uint64_t
Definition: stdint.h:136
Definition: command_line.h:53
Definition: levin_base.h:91
Definition: misc_language.h:104
Definition: net_utils_base.h:365
Definition: abstract_tcp_server2.h:74
Definition: p2p_protocol_defs.h:212
Definition: p2p_protocol_defs.h:278
Definition: p2p_protocol_defs.h:315
Definition: p2p_protocol_defs.h:248
Definition: p2p_protocol_defs.h:103
Definition: net_node.h:83
std::string local_ip
Definition: net_node.h:93
anonymous_inbound()
Definition: net_node.h:84
std::string local_port
Definition: net_node.h:94
epee::net_utils::network_address our_address
Definition: net_node.h:95
epee::net_utils::network_address default_remote
Definition: net_node.h:96
std::int64_t max_connections
Definition: net_node.h:92
Definition: p2p_protocol_defs.h:186
Definition: net_node_common.h:53
Definition: p2p_protocol_defs.h:166
Definition: net_node.h:132
Definition: net_node.h:130
Definition: net_node.h:131
Definition: net_node.h:146
network_config m_net_config
Definition: net_node.h:153
config_t()
Definition: net_node.h:147
uint64_t m_peer_id
Definition: net_node.h:154
uint32_t m_support_flags
Definition: net_node.h:155
Definition: net_node.h:160
std::atomic< unsigned int > m_current_number_of_out_peers
Definition: net_node.h:217
cryptonote::levin::notify m_notifier
Definition: net_node.h:212
void set_config_defaults() noexcept
Definition: net_node.h:224
net_server m_net_server
Definition: net_node.h:206
std::atomic< unsigned int > m_current_number_of_in_peers
Definition: net_node.h:218
std::string m_port_ipv6
Definition: net_node.h:211
std::string m_bind_ip
Definition: net_node.h:208
boost::asio::ip::tcp::endpoint m_proxy_address
Definition: net_node.h:216
network_zone()
Definition: net_node.h:161
bool m_can_pingback
Definition: net_node.h:220
boost::shared_mutex m_seed_nodes_lock
Definition: net_node.h:219
std::vector< epee::net_utils::network_address > m_seed_nodes
Definition: net_node.h:207
std::string m_port
Definition: net_node.h:210
bool m_seed_nodes_initialized
Definition: net_node.h:221
epee::net_utils::network_address m_our_address
Definition: net_node.h:213
network_zone(boost::asio::io_service &public_service)
Definition: net_node.h:183
peerlist_manager m_peerlist
Definition: net_node.h:214
config m_config
Definition: net_node.h:215
connect_func * m_connect
Definition: net_node.h:205
std::string m_bind_ipv6_address
Definition: net_node.h:209
Definition: net_node.h:112
uint32_t support_flags
Definition: net_node.h:120
peerid_type peer_id
Definition: net_node.h:119
std::set< epee::net_utils::network_address > sent_addresses
Definition: net_node.h:122
p2p_connection_context_t()
Definition: net_node.h:113
bool m_in_timedsync
Definition: net_node.h:121
Definition: p2p_protocol_defs.h:73
Definition: net_node.h:68
proxy()
Definition: net_node.h:69
epee::net_utils::zone zone
Definition: net_node.h:78
boost::asio::ip::tcp::endpoint address
Definition: net_node.h:77
bool noise
Definition: net_node.h:79
std::int64_t max_connections
Definition: net_node.h:76
Definition: minissdpd.c:83
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:153
randomx_vm * vm
Definition: tests.cpp:20
#define DISABLE_VS_WARNINGS(w)
Definition: warnings.h:18
#define POP_WARNINGS
Definition: warnings.h:17
#define PUSH_WARNINGS
Definition: warnings.h:16