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),
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),
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),
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;
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);
337 bool make_default_peer_id();
338 bool make_default_config();
343 virtual void on_connection_new(p2p_connection_context&
context);
344 virtual void on_connection_close(p2p_connection_context&
context);
345 virtual void callback(p2p_connection_context&
context);
352 virtual void for_each_connection(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();
374 bool do_handshake_with_peer(
peerid_type& pi, p2p_connection_context&
context,
bool just_take_peerlist =
false);
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>
395 bool try_get_support_flags(
const p2p_connection_context&
context, std::function<
void(p2p_connection_context&,
const uint32_t&)> f);
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);
411 bool set_max_out_peers(network_zone&
zone,
int64_t max);
412 bool set_max_in_peers(network_zone&
zone,
int64_t max);
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();
421 size_t get_incoming_connections_count(network_zone&);
422 size_t get_outgoing_connections_count();
423 size_t get_outgoing_connections_count(network_zone&);
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");
445 m_rpc_port = rpc_port;
450 m_rpc_credits_per_hash = rpc_credits_per_hash;
#define P2P_DEFAULT_HANDSHAKE_INTERVAL
Definition: cryptonote_config.h:140
static int init(int argc, char **argv, struct runtime_vars *v)
Definition: miniupnpd.c:1149
const CharType(& source)[N]
Definition: pointer.h:1147
PUSH_WARNINGS
Definition: hash-ops.h:53
Definition: abstract_tcp_server2.h:342
void init_options(boost::program_options::options_description &hidden_options, boost::program_options::options_description &normal_options)
Definition: posix_daemonizer.inl:56
p2p_connection_context_t(bool is_ping=false)
Definition: net_node.h:113
int * count
Definition: gmock_stress_test.cc:176
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT
Definition: cryptonote_config.h:146
::std::string string
Definition: gtest-port.h:1097
Definition: net_utils_base.h:224
t
Definition: console.py:33
Definition: minissdpd.c:83
#define LEVIN_ERROR_CONNECTION_HANDLER_NOT_DEFINED
Definition: levin_base.h:108
#define CRYPTONOTE_PRUNING_LOG_STRIPES
Definition: cryptonote_config.h:207
Definition: net_utils_base.h:366
bool m_in_timedsync
Definition: net_node.h:122
Definition: net_utils_base.h:124
unsigned short uint16_t
Definition: stdint.h:125
Definition: cryptonote_config.h:220
def run(t, blocks)
Definition: block_weight.py:35
ssl_support_t
Definition: net_ssl.h:49
Provides space for levin (p2p) header, so that payload can be sent without copy.
Definition: levin_base.h:131
#define CHAIN_INVOKE_MAP_TO_OBJ_FORCE_CONTEXT(obj, context_type)
Definition: levin_abstract_invoke2.h:278
Provides tx notification privacy.
Definition: levin_notify.h:69
desc
Definition: pymoduletest.py:79
#define P2P_IP_BLOCKTIME
Definition: cryptonote_config.h:156
#define P2P_DEFAULT_LIMIT_RATE_DOWN
Definition: cryptonote_config.h:153
#define BEGIN_INVOKE_MAP2(owner_type)
Definition: levin_abstract_invoke2.h:240
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE
Definition: cryptonote_config.h:142
epee::levin::async_protocol_handler_config< detail::p2p_context > connections
Definition: levin_notify.h:66
const char * uuid
Definition: minissdp.c:598
unsigned int uint32_t
Definition: stdint.h:126
#define POP_WARNINGS
Definition: warnings.h:17
Definition: levin_base.h:90
#define P2P_DEFAULT_CONNECTION_TIMEOUT
Definition: cryptonote_config.h:144
the connection templated-class for one peer connection
Definition: p2p_protocol_defs.h:102
unsigned __int64 uint64_t
Definition: stdint.h:136
Definition: abstract_tcp_server2.h:82
#define CRITICAL_REGION_LOCAL(x)
Definition: syncobj.h:153
std::unique_ptr< void, terminate > context
Unique ZMQ context handle, calls zmq_term on destruction.
Definition: zmq.h:105
Definition: abstract_tcp_server2.h:75
Definition: connection_basic.hpp:96
#define false
Definition: stdbool.h:37
std::set< epee::net_utils::network_address > sent_addresses
Definition: net_node.h:124
#define END_INVOKE_MAP2()
Definition: levin_abstract_invoke2.h:285
relay_method tx_relay
Definition: levin_notify.cpp:549
boost::endian::big_uint16_t port
Definition: socks.cpp:61
#define HANDLE_INVOKE_T2(COMMAND, func)
Definition: levin_abstract_invoke2.h:250
DISABLE_VS_WARNINGS(4244 4345 4503) using namespace crypto
network_type
Definition: cryptonote_config.h:301
randomx_vm * vm
Definition: tests.cpp:20
TODO: (mj-xmr) This will be reduced in an another PR.
Definition: byte_slice.h:39
uint32_t address
Definition: getifaddr.c:269
#define CHAIN_LEVIN_NOTIFY_MAP2(context_type)
Definition: levin_abstract_invoke2.h:212
uint32_t support_flags
Definition: net_node.h:121
signed __int64 int64_t
Definition: stdint.h:135
Definition: levin_notify.h:53
peerid_type peer_id
Definition: net_node.h:120
bool is_ping
Definition: net_node.h:123
zone
Definition: enums.h:49
relay_method
Methods tracking how a tx was received and relayed.
Definition: enums.h:36
#define P2P_DEFAULT_LIMIT_RATE_UP
Definition: cryptonote_config.h:152
#define CHAIN_LEVIN_INVOKE_MAP2(context_type)
Definition: levin_abstract_invoke2.h:205
Definition: command_line.h:53
tuple message
Definition: gtest_output_test.py:331
#define true
Definition: stdbool.h:36
#define P2P_DEFAULT_PACKET_MAX_SIZE
Definition: cryptonote_config.h:141
Definition: p2p_protocol_defs.h:72