aboutsummaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/daemon_commands_handler.h157
1 files changed, 157 insertions, 0 deletions
diff --git a/src/daemon/daemon_commands_handler.h b/src/daemon/daemon_commands_handler.h
index 7416af9c5..7baca596d 100644
--- a/src/daemon/daemon_commands_handler.h
+++ b/src/daemon/daemon_commands_handler.h
@@ -12,6 +12,7 @@
#include "common/util.h"
#include "crypto/hash.h"
#include "version.h"
+#include "../../contrib/otshell_utils/utils.hpp"
//#include "net/net_helper.h"
//#include "../p2p/p2p_protocol_defs.h"
@@ -491,4 +492,160 @@ POP_WARNINGS
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: out_peers <number_of_peers>" << 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)
+ {
+ m_srv.m_config.m_net_config.connections_count = limit;
+ epee::net_utils::data_logger::get_instance().add_data("peers_limit", m_srv.m_config.m_net_config.connections_count);
+ if (m_srv.m_current_number_of_out_peers > limit)
+ {
+ int count = m_srv.m_current_number_of_out_peers - limit;
+ m_srv.delete_connections(count);
+ }
+ }
+ else
+ {
+ m_srv.m_config.m_net_config.connections_count = limit;
+ epee::net_utils::data_logger::get_instance().add_data("peers_limit", m_srv.m_config.m_net_config.connections_count);
+ }
+
+ 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;
+ }
+ //--------------------------------------------------------------------------------
+ bool fast_exit(const std::vector<std::string>& args)
+ {
+ m_srv.get_payload_object().get_core().set_fast_exit();
+ m_srv.send_stop_signal();
+ return true;
+ }
+ //--------------------------------------------------------------------------------
+ bool test_drop_download(const std::vector<std::string>& args)
+ {
+ m_srv.get_payload_object().get_core().test_drop_download();
+ return true;
+ }
+ //--------------------------------------------------------------------------------
+ bool start_save_graph(const std::vector<std::string>& args)
+ {
+ m_srv.set_save_graph(true);
+ return true;
+ }
+ //--------------------------------------------------------------------------------
+ bool stop_save_graph(const std::vector<std::string>& args)
+ {
+ m_srv.set_save_graph(false);
+ return true;
+ }
};