aboutsummaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
authorrfree2monero <rfreemonero@op.pl>2015-01-05 20:30:17 +0100
committerrfree2monero <rfreemonero@op.pl>2015-02-20 22:13:00 +0100
commiteabb519605cab00dbaa5a1868d229f09c74570a6 (patch)
tree42f909d8e94e8cf67836d57cef4053ac572e3f8c /src/daemon
parentMerge pull request #229 (diff)
downloadmonero-eabb519605cab00dbaa5a1868d229f09c74570a6.tar.xz
2014 network limit 1.0a +utils +toc -doc -drmonero
commands and options for network limiting works very well e.g. for 50 KiB/sec up and down ToS (QoS) flag peer number limit TODO some spikes in ingress/download TODO problems when other up and down limit added "otshell utils" - simple logging (with colors, text files channels)
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/CMakeLists.txt21
-rw-r--r--src/daemon/daemon_commands_handler.h129
2 files changed, 133 insertions, 17 deletions
diff --git a/src/daemon/CMakeLists.txt b/src/daemon/CMakeLists.txt
index 5f60857d6..4a0dcb148 100644
--- a/src/daemon/CMakeLists.txt
+++ b/src/daemon/CMakeLists.txt
@@ -32,23 +32,7 @@ set(daemon_sources
set(daemon_headers)
set(daemon_private_headers
- daemon_commands_handler.h
-
- # cryptonote_protocol
- ../cryptonote_protocol/blobdatatype.h
- ../cryptonote_protocol/cryptonote_protocol_defs.h
- ../cryptonote_protocol/cryptonote_protocol_handler.h
- ../cryptonote_protocol/cryptonote_protocol_handler.inl
- ../cryptonote_protocol/cryptonote_protocol_handler_common.h
-
- # p2p
- ../p2p/net_node.h
- ../p2p/net_node.inl
- ../p2p/net_node_common.h
- ../p2p/net_peerlist.h
- ../p2p/net_peerlist_boost_serialization.h
- ../p2p/p2p_protocol_defs.h
- ../p2p/stdafx.h)
+ daemon_commands_handler.h)
bitmonero_private_headers(daemon
${daemon_private_headers})
@@ -62,6 +46,9 @@ target_link_libraries(daemon
cryptonote_core
crypto
common
+ otshell_utils
+ p2p
+ cryptonote_protocol
${Boost_CHRONO_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h
index 10a07cf89..7cba4ec5a 100644
--- a/src/daemon/daemon_commands_handler.h
+++ b/src/daemon/daemon_commands_handler.h
@@ -40,6 +40,7 @@
#include "common/util.h"
#include "crypto/hash.h"
#include "version.h"
+#include "../../contrib/otshell_utils/utils.hpp"
/*!
* \brief I don't really know right now
@@ -74,6 +75,10 @@ public:
m_cmd_binder.set_handler("save", boost::bind(&daemon_cmmands_handler::save, this, _1), "Save blockchain");
m_cmd_binder.set_handler("set_log", boost::bind(&daemon_cmmands_handler::set_log, this, _1), "set_log <level> - Change current log detalization level, <level> is a number 0-4");
m_cmd_binder.set_handler("diff", boost::bind(&daemon_cmmands_handler::diff, this, _1), "Show difficulty");
+ m_cmd_binder.set_handler("out_peers", boost::bind(&daemon_cmmands_handler::out_peers_limit, this, _1), "Set max limit of out peers");
+ m_cmd_binder.set_handler("limit_up", boost::bind(&daemon_cmmands_handler::limit_up, this, _1), "Set upload limit [kB/s]");
+ m_cmd_binder.set_handler("limit_down", boost::bind(&daemon_cmmands_handler::limit_down, this, _1), "Set download limit [kB/s]");
+ m_cmd_binder.set_handler("limit", boost::bind(&daemon_cmmands_handler::limit, this, _1), "Set download and upload limit [kB/s]");
}
bool start_handling()
@@ -398,4 +403,128 @@ private:
m_srv.get_payload_object().get_core().get_miner().stop();
return true;
}
+ //--------------------------------------------------------------------------------
+ bool out_peers_limit(const std::vector<std::string>& args) {
+ if(args.size()!=1) {
+ std::cout << "Usage: limit_down <speed>" << ENDL;
+ return true;
+ }
+
+ unsigned int limit;
+ try {
+ limit = std::stoi(args[0]);
+ }
+
+ catch(std::invalid_argument& ex) {
+ _erro("stoi exception");
+ return false;
+ }
+
+ if (m_srv.m_config.m_net_config.connections_count > limit)
+ {
+ int count = m_srv.m_config.m_net_config.connections_count - limit;
+ m_srv.m_config.m_net_config.connections_count = limit;
+ m_srv.delete_connections(count);
+ }
+ else
+ m_srv.m_config.m_net_config.connections_count = limit;
+
+ return true;
+ }
+ //--------------------------------------------------------------------------------
+ bool limit_up(const std::vector<std::string>& args)
+ {
+ if(args.size()!=1) {
+ std::cout << "Usage: limit_up <speed>" << ENDL;
+ return false;
+ }
+
+ int limit;
+ try {
+ limit = std::stoi(args[0]);
+ }
+ catch(std::invalid_argument& ex) {
+ return false;
+ }
+
+ if (limit==-1) {
+ limit=128;
+ //this->islimitup=false;
+ }
+
+ limit *= 1024;
+
+
+ //nodetool::epee::net_utils::connection<epee::levin::async_protocol_handler<nodetool::p2p_connection_context> >::set_rate_up_limit( limit );
+ epee::net_utils::connection_basic::set_rate_up_limit( limit );
+ std::cout << "Set limit-up to " << limit/1024 << " kB/s" << std::endl;
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------------------
+ bool limit_down(const std::vector<std::string>& args)
+ {
+
+ if(args.size()!=1) {
+ std::cout << "Usage: limit_down <speed>" << ENDL;
+ return true;
+ }
+
+ int limit;
+ try {
+ limit = std::stoi(args[0]);
+ }
+
+ catch(std::invalid_argument& ex) {
+ return false;
+ }
+
+ if (limit==-1) {
+ limit=128;
+ //this->islimitup=false;
+ }
+
+ limit *= 1024;
+
+
+ //nodetool::epee::net_utils::connection<epee::levin::async_protocol_handler<nodetool::p2p_connection_context> >::set_rate_up_limit( limit );
+ epee::net_utils::connection_basic::set_rate_down_limit( limit );
+ std::cout << "Set limit-down to " << limit/1024 << " kB/s" << std::endl;
+
+ return true;
+ }
+
+ //--------------------------------------------------------------------------------
+ bool limit(const std::vector<std::string>& args)
+ {
+ if(args.size()!=1) {
+ std::cout << "Usage: limit_down <speed>" << ENDL;
+ return true;
+ }
+
+ int limit;
+ try {
+ limit = std::stoi(args[0]);
+ }
+ catch(std::invalid_argument& ex) {
+ return false;
+ }
+
+ if (limit==-1) {
+ limit=128;
+ //this->islimitup=false;
+ }
+
+ limit *= 1024;
+
+
+ //nodetool::epee::net_utils::connection<epee::levin::async_protocol_handler<nodetool::p2p_connection_context> >::set_rate_up_limit( limit );
+ epee::net_utils::connection_basic::set_rate_down_limit( limit );
+ epee::net_utils::connection_basic::set_rate_up_limit( limit );
+ std::cout << "Set limit-down to " << limit/1024 << " kB/s" << std::endl;
+ std::cout << "Set limit-up to " << limit/1024 << " kB/s" << std::endl;
+
+ return true;
+ }
};