From d609a2c1640a5b3079f65f4c85b3f82afd8e5f16 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Sat, 20 Jan 2018 11:57:02 +1100 Subject: Rename delete_connections to delete_out_connections This rename is needed so that delete_in_connections can be added. --- src/p2p/net_node.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/p2p/net_node.h') diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index 20520f83c..2f26695a2 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -118,7 +118,7 @@ namespace nodetool virtual uint64_t get_connections_count(); size_t get_outgoing_connections_count(); peerlist_manager& get_peerlist_manager(){return m_peerlist;} - void delete_connections(size_t count); + void delete_out_connections(size_t count); virtual bool block_host(const epee::net_utils::network_address &adress, time_t seconds = P2P_IP_BLOCKTIME); virtual bool unblock_host(const epee::net_utils::network_address &address); virtual std::map get_blocked_hosts() { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return m_blocked_hosts; } -- cgit v1.2.3 From 32c0f908cd753f9319909e2f43d2b4657ebaf664 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Sun, 21 Jan 2018 08:44:23 +1100 Subject: Allow the number of incoming connections to be limited It was already possible to limit outgoing connections. One might want to do this on home network connections with high bandwidth but low usage caps. --- src/p2p/net_node.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/p2p/net_node.h') diff --git a/src/p2p/net_node.h b/src/p2p/net_node.h index 2f26695a2..568c650cc 100644 --- a/src/p2p/net_node.h +++ b/src/p2p/net_node.h @@ -81,6 +81,7 @@ namespace nodetool node_server(t_payload_net_handler& payload_handler) :m_payload_handler(payload_handler), m_current_number_of_out_peers(0), + m_current_number_of_in_peers(0), m_allow_local_ip(false), m_hide_my_port(false), m_no_igd(false), @@ -117,8 +118,10 @@ namespace nodetool bool log_connections(); virtual uint64_t get_connections_count(); size_t get_outgoing_connections_count(); + size_t get_incoming_connections_count(); peerlist_manager& get_peerlist_manager(){return m_peerlist;} void delete_out_connections(size_t count); + void delete_in_connections(size_t count); virtual bool block_host(const epee::net_utils::network_address &adress, time_t seconds = P2P_IP_BLOCKTIME); virtual bool unblock_host(const epee::net_utils::network_address &address); virtual std::map get_blocked_hosts() { CRITICAL_REGION_LOCAL(m_blocked_hosts_lock); return m_blocked_hosts; } @@ -230,6 +233,7 @@ namespace nodetool bool parse_peers_and_add_to_container(const boost::program_options::variables_map& vm, const command_line::arg_descriptor > & arg, Container& container); bool set_max_out_peers(const boost::program_options::variables_map& vm, int64_t max); + bool set_max_in_peers(const boost::program_options::variables_map& vm, int64_t max); bool set_tos_flag(const boost::program_options::variables_map& vm, int limit); bool set_rate_up_limit(const boost::program_options::variables_map& vm, int64_t limit); @@ -271,6 +275,7 @@ namespace nodetool public: config m_config; // TODO was private, add getters? std::atomic m_current_number_of_out_peers; + std::atomic m_current_number_of_in_peers; void set_save_graph(bool save_graph) { @@ -345,6 +350,7 @@ namespace nodetool extern const command_line::arg_descriptor arg_no_igd; extern const command_line::arg_descriptor arg_offline; extern const command_line::arg_descriptor arg_out_peers; + extern const command_line::arg_descriptor arg_in_peers; extern const command_line::arg_descriptor arg_tos_flag; extern const command_line::arg_descriptor arg_limit_rate_up; -- cgit v1.2.3