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> 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>
116 m_in_timedsync(
false)
125 template<
class t_payload_net_handler>
127 public i_p2p_endpoint<typename t_payload_net_handler::connection_context>,
138 static_assert(p2p_connection_context::handshake_command() == COMMAND_HANDSHAKE::ID,
"invalid handshake command id");
162 : m_connect(nullptr),
166 m_bind_ipv6_address(),
174 m_current_number_of_out_peers(0),
175 m_current_number_of_in_peers(0),
177 m_can_pingback(
false),
178 m_seed_nodes_initialized(
false)
180 set_config_defaults();
184 : m_connect(nullptr),
188 m_bind_ipv6_address(),
196 m_current_number_of_out_peers(0),
197 m_current_number_of_in_peers(0),
199 m_can_pingback(
false),
200 m_seed_nodes_initialized(
false)
202 set_config_defaults();
229 m_config.m_net_config.config_id = 0;
233 m_config.m_support_flags = 0;
248 : m_payload_handler(payload_handler),
251 m_rpc_credits_per_hash(0),
252 m_allow_local_ip(
false),
253 m_hide_my_port(
false),
258 m_enable_dns_seed_nodes(
true),
263 static void init_options(boost::program_options::options_description&
desc);
267 bool init(
const boost::program_options::variables_map&
vm,
const std::string&
proxy = {},
bool proxy_dns_leaks_allowed = {});
269 bool send_stop_signal();
271 t_payload_net_handler& get_payload_object();
275 bool log_connections();
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);
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;
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();
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" 309 bool islimitup=
false;
310 bool islimitdown=
false;
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);
334 bool make_default_peer_id();
335 bool make_default_config();
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);
349 virtual void for_each_connection(std::function<
bool(
typename t_payload_net_handler::connection_context&,
peerid_type,
uint32_t)> f);
356 bool handle_command_line(
357 const boost::program_options::variables_map&
vm 364 bool sanitize_peerlist(std::vector<peerlist_entry>& local_peerlist);
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);
370 bool update_dns_blocklist();
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);
375 size_t get_random_index_with_fixed_probability(
size_t max_index);
379 void add_upnp_port_mapping_impl(
uint32_t port,
bool ipv6=
false);
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);
387 template<
class t_callback>
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);
394 std::set<std::string> get_ip_seed_nodes()
const;
395 std::set<std::string> get_dns_seed_nodes();
399 template <
class Container>
400 bool connect_to_peerlist(
const Container& peers);
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);
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);
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);
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&);
420 bool gray_peerlist_housekeeping();
421 bool check_incoming_connections();
424 _info(
"Killing the net_node");
426 if(mPeersLoggerThread !=
nullptr)
427 mPeersLoggerThread->join();
428 _info(
"Joined extra background net_node threads");
439 m_rpc_port = rpc_port;
444 m_rpc_credits_per_hash = rpc_credits_per_hash;
#define P2P_DEFAULT_HANDSHAKE_INTERVAL
Definition: cryptonote_config.h:136
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:322
void init_options(boost::program_options::options_description &hidden_options, boost::program_options::options_description &normal_options)
Definition: posix_daemonizer.inl:56
int * count
Definition: gmock_stress_test.cc:176
#define P2P_DEFAULT_PING_CONNECTION_TIMEOUT
Definition: cryptonote_config.h:142
::std::string string
Definition: gtest-port.h:1097
Definition: net_utils_base.h:222
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:203
Definition: net_utils_base.h:364
bool m_in_timedsync
Definition: net_node.h:121
Definition: net_utils_base.h:122
unsigned short uint16_t
Definition: stdint.h:125
Definition: cryptonote_config.h:216
def run(t, blocks)
Definition: block_weight.py:35
ssl_support_t
Definition: net_ssl.h:48
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:152
#define P2P_DEFAULT_LIMIT_RATE_DOWN
Definition: cryptonote_config.h:149
#define BEGIN_INVOKE_MAP2(owner_type)
Definition: levin_abstract_invoke2.h:240
boost::asio::io_service io_service
Definition: levin.cpp:303
#define P2P_DEFAULT_PEERS_IN_HANDSHAKE
Definition: cryptonote_config.h:138
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:140
the connection templated-class for one peer connection
Definition: p2p_protocol_defs.h:102
unsigned __int64 uint64_t
Definition: stdint.h:136
#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:73
Definition: connection_basic.hpp:96
#define false
Definition: stdbool.h:37
std::set< epee::net_utils::network_address > sent_addresses
Definition: net_node.h:122
#define END_INVOKE_MAP2()
Definition: levin_abstract_invoke2.h:285
relay_method tx_relay
Definition: levin_notify.cpp:545
boost::endian::big_uint16_t port
Definition: socks.cpp:59
#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:295
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:120
signed __int64 int64_t
Definition: stdint.h:135
Definition: levin_notify.h:53
p2p_connection_context_t()
Definition: net_node.h:113
peerid_type peer_id
Definition: net_node.h:119
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:148
#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:137
Definition: p2p_protocol_defs.h:72