print limits when running limit commands with no arguments
It's more user friendly that an error message saying the command does not exist.
This commit is contained in:
parent
2dc1cd9ae6
commit
d8ee0a95c7
|
@ -251,7 +251,10 @@ bool t_command_parser_executor::print_status(const std::vector<std::string>& arg
|
||||||
|
|
||||||
bool t_command_parser_executor::set_limit(const std::vector<std::string>& args)
|
bool t_command_parser_executor::set_limit(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if(args.size()!=1) return false;
|
if(args.size()>1) return false;
|
||||||
|
if(args.size()==0) {
|
||||||
|
return m_executor.get_limit();
|
||||||
|
}
|
||||||
int limit;
|
int limit;
|
||||||
try {
|
try {
|
||||||
limit = std::stoi(args[0]);
|
limit = std::stoi(args[0]);
|
||||||
|
@ -267,7 +270,10 @@ bool t_command_parser_executor::set_limit(const std::vector<std::string>& args)
|
||||||
|
|
||||||
bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& args)
|
bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if(args.size()!=1) return false;
|
if(args.size()>1) return false;
|
||||||
|
if(args.size()==0) {
|
||||||
|
return m_executor.get_limit_up();
|
||||||
|
}
|
||||||
int limit;
|
int limit;
|
||||||
try {
|
try {
|
||||||
limit = std::stoi(args[0]);
|
limit = std::stoi(args[0]);
|
||||||
|
@ -283,7 +289,10 @@ bool t_command_parser_executor::set_limit_up(const std::vector<std::string>& arg
|
||||||
|
|
||||||
bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& args)
|
bool t_command_parser_executor::set_limit_down(const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if(args.size()!=1) return false;
|
if(args.size()>1) return false;
|
||||||
|
if(args.size()==0) {
|
||||||
|
return m_executor.get_limit_down();
|
||||||
|
}
|
||||||
int limit;
|
int limit;
|
||||||
try {
|
try {
|
||||||
limit = std::stoi(args[0]);
|
limit = std::stoi(args[0]);
|
||||||
|
|
|
@ -737,6 +737,15 @@ bool t_rpc_command_executor::print_status()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool t_rpc_command_executor::get_limit()
|
||||||
|
{
|
||||||
|
int limit_down = epee::net_utils::connection_basic::get_rate_down_limit( );
|
||||||
|
int limit_up = epee::net_utils::connection_basic::get_rate_up_limit( );
|
||||||
|
std::cout << "limit-down is " << limit_down/1024 << " kB/s" << std::endl;
|
||||||
|
std::cout << "limit-up is " << limit_up/1024 << " kB/s" << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool t_rpc_command_executor::set_limit(int limit)
|
bool t_rpc_command_executor::set_limit(int limit)
|
||||||
{
|
{
|
||||||
epee::net_utils::connection_basic::set_rate_down_limit( limit );
|
epee::net_utils::connection_basic::set_rate_down_limit( limit );
|
||||||
|
@ -746,6 +755,13 @@ bool t_rpc_command_executor::set_limit(int limit)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool t_rpc_command_executor::get_limit_up()
|
||||||
|
{
|
||||||
|
int limit_up = epee::net_utils::connection_basic::get_rate_up_limit( );
|
||||||
|
std::cout << "limit-up is " << limit_up/1024 << " kB/s" << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool t_rpc_command_executor::set_limit_up(int limit)
|
bool t_rpc_command_executor::set_limit_up(int limit)
|
||||||
{
|
{
|
||||||
epee::net_utils::connection_basic::set_rate_up_limit( limit );
|
epee::net_utils::connection_basic::set_rate_up_limit( limit );
|
||||||
|
@ -753,6 +769,13 @@ bool t_rpc_command_executor::set_limit_up(int limit)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool t_rpc_command_executor::get_limit_down()
|
||||||
|
{
|
||||||
|
int limit_down = epee::net_utils::connection_basic::get_rate_down_limit( );
|
||||||
|
std::cout << "limit-down is " << limit_down/1024 << " kB/s" << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool t_rpc_command_executor::set_limit_down(int limit)
|
bool t_rpc_command_executor::set_limit_down(int limit)
|
||||||
{
|
{
|
||||||
epee::net_utils::connection_basic::set_rate_down_limit( limit );
|
epee::net_utils::connection_basic::set_rate_down_limit( limit );
|
||||||
|
|
|
@ -99,6 +99,12 @@ public:
|
||||||
|
|
||||||
bool print_status();
|
bool print_status();
|
||||||
|
|
||||||
|
bool get_limit();
|
||||||
|
|
||||||
|
bool get_limit_up();
|
||||||
|
|
||||||
|
bool get_limit_down();
|
||||||
|
|
||||||
bool set_limit(int limit);
|
bool set_limit(int limit);
|
||||||
|
|
||||||
bool set_limit_up(int limit);
|
bool set_limit_up(int limit);
|
||||||
|
|
|
@ -199,6 +199,23 @@ void connection_basic::set_rate_down_limit(uint64_t limit) {
|
||||||
save_limit_to_file(limit);
|
save_limit_to_file(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t connection_basic::get_rate_up_limit() {
|
||||||
|
uint64_t limit;
|
||||||
|
{
|
||||||
|
CRITICAL_REGION_LOCAL( network_throttle_manager::m_lock_get_global_throttle_out );
|
||||||
|
limit = network_throttle_manager::get_global_throttle_out().get_terget_speed();
|
||||||
|
}
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t connection_basic::get_rate_down_limit() {
|
||||||
|
uint64_t limit;
|
||||||
|
{
|
||||||
|
CRITICAL_REGION_LOCAL( network_throttle_manager::m_lock_get_global_throttle_in );
|
||||||
|
limit = network_throttle_manager::get_global_throttle_in().get_terget_speed();
|
||||||
|
}
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
void connection_basic::save_limit_to_file(int limit) {
|
void connection_basic::save_limit_to_file(int limit) {
|
||||||
// saving limit to file
|
// saving limit to file
|
||||||
|
|
|
@ -119,6 +119,8 @@ class connection_basic { // not-templated base class for rapid developmet of som
|
||||||
|
|
||||||
static void set_rate_up_limit(uint64_t limit);
|
static void set_rate_up_limit(uint64_t limit);
|
||||||
static void set_rate_down_limit(uint64_t limit);
|
static void set_rate_down_limit(uint64_t limit);
|
||||||
|
static uint64_t get_rate_up_limit();
|
||||||
|
static uint64_t get_rate_down_limit();
|
||||||
|
|
||||||
// config misc
|
// config misc
|
||||||
static void set_tos_flag(int tos); // ToS / QoS flag
|
static void set_tos_flag(int tos); // ToS / QoS flag
|
||||||
|
|
Loading…
Reference in New Issue