34#include <boost/asio/io_context.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>
70 : max_connections(-1),
72 zone(
epee::net_utils::zone::invalid),
85 : max_connections(-1),
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);
106 boost::optional<boost::asio::ip::tcp::socket>
110 template<
class base_type>
117 m_in_timedsync(
false)
127 template<
class t_payload_net_handler>
129 public i_p2p_endpoint<typename t_payload_net_handler::connection_context>,
141 static_assert(p2p_connection_context::handshake_command() == COMMAND_HANDSHAKE::ID,
"invalid handshake command id");
165 : m_connect(nullptr),
166 m_net_server(
epee::net_utils::e_connection_type_P2P),
169 m_bind_ipv6_address(),
177 m_current_number_of_out_peers(0),
178 m_current_number_of_in_peers(0),
180 m_can_pingback(
false),
181 m_seed_nodes_initialized(
false)
183 set_config_defaults();
187 : m_connect(nullptr),
188 m_net_server(public_service,
epee::net_utils::e_connection_type_P2P),
191 m_bind_ipv6_address(),
199 m_current_number_of_out_peers(0),
200 m_current_number_of_in_peers(0),
202 m_can_pingback(
false),
203 m_seed_nodes_initialized(
false)
205 set_config_defaults();
232 m_config.m_net_config.config_id = 0;
236 m_config.m_support_flags = 0;
251 : m_payload_handler(payload_handler),
254 m_rpc_credits_per_hash(0),
255 m_allow_local_ip(
false),
256 m_hide_my_port(
false),
261 m_enable_dns_seed_nodes(
true),
266 static void init_options(boost::program_options::options_description& desc);
270 bool init(
const boost::program_options::variables_map&
vm,
const std::string&
proxy = {},
bool proxy_dns_leaks_allowed = {});
272 bool send_stop_signal();
274 t_payload_net_handler& get_payload_object();
278 bool log_connections();
281 virtual uint64_t get_public_connections_count();
282 size_t get_public_outgoing_connections_count();
283 size_t get_public_white_peers_count();
284 size_t get_public_gray_peers_count();
285 void get_public_peerlist(std::vector<peerlist_entry>& gray, std::vector<peerlist_entry>& white);
286 void get_peerlist(std::vector<peerlist_entry>& gray, std::vector<peerlist_entry>& white);
288 void change_max_out_public_peers(
size_t count);
289 uint32_t get_max_out_public_peers()
const;
290 void change_max_in_public_peers(
size_t count);
291 uint32_t get_max_in_public_peers()
const;
300 virtual void add_used_stripe_peer(
const typename t_payload_net_handler::connection_context &context);
301 virtual void remove_used_stripe_peer(
const typename t_payload_net_handler::connection_context &context);
302 virtual void clear_used_stripe_peers();
305 const std::vector<std::string> m_seed_nodes_list =
306 {
"seeds.moneroseeds.se"
307 ,
"seeds.moneroseeds.ae.org"
308 ,
"seeds.moneroseeds.ch"
309 ,
"seeds.moneroseeds.li"
312 bool islimitup=
false;
313 bool islimitdown=
false;
319 if (is_filtered_command(context.m_remote_address, command))
332 int handle_handshake(
int command,
typename COMMAND_HANDSHAKE::request& arg,
typename COMMAND_HANDSHAKE::response& rsp, p2p_connection_context& context);
333 int handle_timed_sync(
int command,
typename COMMAND_TIMED_SYNC::request& arg,
typename COMMAND_TIMED_SYNC::response& rsp, p2p_connection_context& context);
347 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;
352 virtual void for_each_connection(std::function<
bool(
typename t_payload_net_handler::connection_context&,
peerid_type,
uint32_t)> f);
353 virtual bool for_connection(
const boost::uuids::uuid&, std::function<
bool(
typename t_payload_net_handler::connection_context&,
peerid_type,
uint32_t)> f);
362 bool handle_command_line(
363 const boost::program_options::variables_map&
vm
370 bool sanitize_peerlist(std::vector<peerlist_entry>& local_peerlist);
372 bool connections_maker();
373 bool peer_sync_idle_maker();
376 bool update_dns_blocklist();
378 bool make_new_connection_from_anchor_peerlist(
const std::vector<anchor_peerlist_entry>& anchor_peerlist);
379 bool make_new_connection_from_peerlist(
network_zone& zone,
bool use_white_list);
381 size_t get_random_index_with_fixed_probability(
size_t max_index);
385 void add_upnp_port_mapping_impl(
uint32_t port,
bool ipv6=
false);
388 void add_upnp_port_mapping(
uint32_t port,
bool ipv4=
true,
bool ipv6=
false);
389 void delete_upnp_port_mapping_impl(
uint32_t port,
bool ipv6=
false);
393 template<
class t_callback>
396 bool make_expected_connections_count(
network_zone& zone,
PeerType peer_type,
size_t expected_connections);
400 std::set<std::string> get_ip_seed_nodes()
const;
401 std::set<std::string> get_dns_seed_nodes();
405 template <
class Container>
406 bool connect_to_peerlist(
const Container& peers);
408 template <
class Container>
409 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);
413 bool set_tos_flag(
const boost::program_options::variables_map&
vm,
int limit);
415 bool set_rate_up_limit(
const boost::program_options::variables_map&
vm,
int64_t limit);
416 bool set_rate_down_limit(
const boost::program_options::variables_map&
vm,
int64_t limit);
417 bool set_rate_limit(
const boost::program_options::variables_map&
vm,
int64_t limit);
420 size_t get_incoming_connections_count();
422 size_t get_outgoing_connections_count();
426 bool gray_peerlist_housekeeping();
427 bool check_incoming_connections();
430 _info(
"Killing the net_node");
432 if(mPeersLoggerThread !=
nullptr)
433 mPeersLoggerThread->join();
434 _info(
"Joined extra background net_node threads");
438 std::string print_connections_container();
445 m_rpc_port = rpc_port;
450 m_rpc_credits_per_hash = rpc_credits_per_hash;
the connection templated-class for one peer connection
Provides tx notification privacy.
Definition levin_notify.h:70
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:347
Definition net_utils_base.h:125
Definition net_utils_base.h:225
#define P2P_DEFAULT_PACKET_MAX_SIZE
Definition cryptonote_config.h:141
#define P2P_DEFAULT_LIMIT_RATE_DOWN
Definition cryptonote_config.h:153
#define P2P_IP_BLOCKTIME
Definition cryptonote_config.h:156
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE
Definition cryptonote_config.h:142
#define CRYPTONOTE_PRUNING_LOG_STRIPES
Definition cryptonote_config.h:207
#define P2P_DEFAULT_CONNECTION_TIMEOUT
Definition cryptonote_config.h:144
#define P2P_DEFAULT_LIMIT_RATE_UP
Definition cryptonote_config.h:152
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT
Definition cryptonote_config.h:146
#define P2P_DEFAULT_HANDSHAKE_INTERVAL
Definition cryptonote_config.h:140
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:549
static void init()
Definition logging.cpp:42
uint32_t address
Definition getifaddr.c:269
Definition cryptonote_config.h:221
network_type
Definition cryptonote_config.h:302
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:49
TODO: (mj-xmr) This will be reduced in an another PR.
Definition byte_slice.h:40
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:61
#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:367
Definition abstract_tcp_server2.h:76
Definition abstract_tcp_server2.h:83
Definition p2p_protocol_defs.h:103
Definition net_node.h:112
uint32_t support_flags
Definition net_node.h:121
bool is_ping
Definition net_node.h:123
peerid_type peer_id
Definition net_node.h:120
std::set< epee::net_utils::network_address > sent_addresses
Definition net_node.h:124
bool m_in_timedsync
Definition net_node.h:122
p2p_connection_context_t(bool is_ping=false)
Definition net_node.h:113
Definition p2p_protocol_defs.h:73
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