mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 05:02:31 +00:00
* Finished refactoring command_network.cc.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1152 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+15
-17
@@ -59,7 +59,7 @@ namespace rpc {
|
||||
#define COMMAND_TRACKER_SLOTS_SIZE 15
|
||||
#define COMMAND_ANY_SLOTS_SIZE 50
|
||||
|
||||
#define COMMAND_NEW_SLOTS_SIZE 100
|
||||
#define COMMAND_NEW_SLOTS_SIZE 200
|
||||
|
||||
#define ADDING_COMMANDS
|
||||
|
||||
@@ -238,26 +238,24 @@ add_variable(key, NULL, NULL, &rpc::CommandVariable::get_string, NULL, std::stri
|
||||
rpc::commands.insert_type(key, commandNewSlotItr++, &rpc::function, \
|
||||
rpc::CommandMap::flag_dont_delete | rpc::CommandMap::flag_public_xmlrpc, NULL, NULL);
|
||||
|
||||
#define CMD2_ANY(key, slot) \
|
||||
CMD2_A_FUNCTION(key, command_base_call_any, any_function, slot, "i:", "")
|
||||
#define CMD2_ANY(key, slot) CMD2_A_FUNCTION(key, command_base_call_any, any_function, slot, "i:", "")
|
||||
#define CMD2_ANY_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_list, any_list_function, object_convert_void(slot), "i:", "")
|
||||
#define CMD2_ANY_L(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_list, any_list_function, slot, "A:", "")
|
||||
|
||||
#define CMD2_ANY_L(key, slot) \
|
||||
CMD2_A_FUNCTION(key, command_base_call_any_list, any_list_function, slot, "A:", "")
|
||||
#define CMD2_ANY_VALUE(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_value, any_value_function, slot, "i:i", "")
|
||||
#define CMD2_ANY_VALUE_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_value, any_value_function, object_convert_void(slot), "i:i", "")
|
||||
|
||||
#define CMD2_ANY_VALUE(key, slot) \
|
||||
CMD2_A_FUNCTION(key, command_base_call_any_value, any_value_function, slot, "i:i", "")
|
||||
#define CMD2_ANY_STRING(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_string, any_string_function, slot, "i:s", "")
|
||||
#define CMD2_ANY_STRING_V(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_string, any_string_function, object_convert_void(slot), "i:s", "")
|
||||
|
||||
#define CMD2_ANY_VALUE_V(key, slot) \
|
||||
CMD2_A_FUNCTION(key, command_base_call_any_value, any_value_function, object_convert_void(slot), "i:i", "")
|
||||
#define CMD2_ANY_LIST(key, slot) CMD2_A_FUNCTION(key, command_base_call_any_list, any_list_function, slot, "i:", "")
|
||||
|
||||
#define CMD2_ANY_STRING(key, slot) \
|
||||
CMD2_A_FUNCTION(key, command_base_call_any_string, any_string_function, slot, "i:s", "")
|
||||
|
||||
#define CMD2_ANY_STRING_V(key, slot) \
|
||||
CMD2_A_FUNCTION(key, command_base_call_any_string, any_string_function, object_convert_void(slot), "i:s", "")
|
||||
|
||||
#define CMD2_ANY_LIST(key, slot) \
|
||||
CMD2_A_FUNCTION(key, command_base_call_any_list, any_list_function, slot, "i:", "")
|
||||
#define CMD2_VAR_BOOL(key, value) \
|
||||
rpc::commands.call("method.insert", rpc::create_object_list(key, "bool|const", int64_t(value)));
|
||||
#define CMD2_VAR_VALUE(key, value) \
|
||||
rpc::commands.call("method.insert", rpc::create_object_list(key, "value|const", int64_t(value)));
|
||||
#define CMD2_VAR_STRING(key, value) \
|
||||
rpc::commands.call("method.insert", rpc::create_object_list(key, "string|const", std::string(value)));
|
||||
|
||||
//
|
||||
// Conversion of return types:
|
||||
|
||||
+58
-49
@@ -227,9 +227,9 @@ apply_tos(const torrent::Object::string_type& arg) {
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
void apply_hash_read_ahead(int arg) { torrent::set_hash_read_ahead(arg << 20); }
|
||||
void apply_hash_interval(int arg) { torrent::set_hash_interval(arg * 1000); }
|
||||
void apply_encoding_list(const std::string& arg) { torrent::encoding_list()->push_back(arg); }
|
||||
torrent::Object apply_hash_read_ahead(int arg) { torrent::set_hash_read_ahead(arg << 20); return torrent::Object(); }
|
||||
torrent::Object apply_hash_interval(int arg) { torrent::set_hash_interval(arg * 1000); return torrent::Object(); }
|
||||
torrent::Object apply_encoding_list(const std::string& arg) { torrent::encoding_list()->push_back(arg); return torrent::Object(); }
|
||||
|
||||
struct call_add_node_t {
|
||||
call_add_node_t(int port) : m_port(port) { }
|
||||
@@ -244,7 +244,7 @@ struct call_add_node_t {
|
||||
int m_port;
|
||||
};
|
||||
|
||||
void
|
||||
torrent::Object
|
||||
apply_dht_add_node(const std::string& arg) {
|
||||
if (!torrent::dht_manager()->is_valid())
|
||||
throw torrent::input_error("DHT not enabled.");
|
||||
@@ -264,17 +264,20 @@ apply_dht_add_node(const std::string& arg) {
|
||||
throw torrent::input_error("Invalid port number.");
|
||||
|
||||
torrent::connection_manager()->resolver()(host, (int)rak::socket_address::pf_inet, SOCK_DGRAM, call_add_node_t(port));
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
void
|
||||
torrent::Object
|
||||
apply_enable_trackers(int64_t arg) {
|
||||
for (core::Manager::DListItr itr = control->core()->download_list()->begin(), last = control->core()->download_list()->end(); itr != last; ++itr) {
|
||||
std::for_each((*itr)->tracker_list()->begin(), (*itr)->tracker_list()->end(),
|
||||
arg ? std::mem_fun(&torrent::Tracker::enable) : std::mem_fun(&torrent::Tracker::disable));
|
||||
|
||||
if (arg && !rpc::call_command_value("get_use_udp_trackers"))
|
||||
if (arg && !rpc::call_command_value("trackers.use_udp"))
|
||||
(*itr)->enable_udp_trackers(false);
|
||||
}
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::File*
|
||||
@@ -382,7 +385,7 @@ apply_scgi(const std::string& arg, int type) {
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
void
|
||||
torrent::Object
|
||||
apply_xmlrpc_dialect(const std::string& arg) {
|
||||
int value;
|
||||
|
||||
@@ -396,6 +399,7 @@ apply_xmlrpc_dialect(const std::string& arg) {
|
||||
value = -1;
|
||||
|
||||
rpc::xmlrpc.set_dialect(value);
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -404,37 +408,41 @@ initialize_command_network() {
|
||||
torrent::FileManager* fileManager = torrent::file_manager();
|
||||
core::CurlStack* httpStack = control->core()->http_stack();
|
||||
|
||||
ADD_VARIABLE_BOOL("use_udp_trackers", true);
|
||||
CMD2_VAR_BOOL ("protocol.pex", true);
|
||||
CMD2_VAR_BOOL ("log.handshake", false);
|
||||
CMD2_VAR_STRING ("log.tracker", "");
|
||||
|
||||
CMD2_ANY_STRING ("encoding_list", std::tr1::bind(&apply_encoding_list, std::tr1::placeholders::_2));
|
||||
|
||||
// Isn't port_open used?
|
||||
ADD_VARIABLE_BOOL("port_open", true);
|
||||
ADD_VARIABLE_BOOL("port_random", true);
|
||||
ADD_VARIABLE_STRING("port_range", "6881-6999");
|
||||
CMD2_VAR_BOOL("port_open", true);
|
||||
CMD2_VAR_BOOL("port_random", true);
|
||||
CMD2_VAR_STRING("port_range", "6881-6999");
|
||||
|
||||
ADD_VARIABLE_STRING("connection_leech", "leech");
|
||||
ADD_VARIABLE_STRING("connection_seed", "seed");
|
||||
CMD2_VAR_STRING("connection_leech", "leech");
|
||||
CMD2_VAR_STRING("connection_seed", "seed");
|
||||
|
||||
ADD_VARIABLE_VALUE("min_peers", 40);
|
||||
ADD_VARIABLE_VALUE("max_peers", 100);
|
||||
ADD_VARIABLE_VALUE("min_peers_seed", -1);
|
||||
ADD_VARIABLE_VALUE("max_peers_seed", -1);
|
||||
CMD2_VAR_VALUE("min_peers", 40);
|
||||
CMD2_VAR_VALUE("max_peers", 100);
|
||||
CMD2_VAR_VALUE("min_peers_seed", -1);
|
||||
CMD2_VAR_VALUE("max_peers_seed", -1);
|
||||
|
||||
ADD_VARIABLE_VALUE("max_uploads", 15);
|
||||
CMD2_VAR_VALUE("max_uploads", 15);
|
||||
|
||||
ADD_VARIABLE_VALUE("max_uploads_div", 1);
|
||||
ADD_VARIABLE_VALUE("max_uploads_global", 0);
|
||||
ADD_VARIABLE_VALUE("max_downloads_div", 1);
|
||||
ADD_VARIABLE_VALUE("max_downloads_global", 0);
|
||||
CMD2_VAR_VALUE("max_uploads_div", 1);
|
||||
CMD2_VAR_VALUE("max_uploads_global", 0);
|
||||
CMD2_VAR_VALUE("max_downloads_div", 1);
|
||||
CMD2_VAR_VALUE("max_downloads_global", 0);
|
||||
|
||||
ADD_COMMAND_VALUE_TRI_KB("download_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_down_throttle_i64), rak::make_mem_fun(torrent::down_throttle_global(), &torrent::Throttle::max_rate));
|
||||
ADD_COMMAND_VALUE_TRI_KB("upload_rate", rak::make_mem_fun(control->ui(), &ui::Root::set_up_throttle_i64), rak::make_mem_fun(torrent::up_throttle_global(), &torrent::Throttle::max_rate));
|
||||
|
||||
ADD_COMMAND_VOID("get_up_rate", rak::make_mem_fun(torrent::up_rate(), &torrent::Rate::rate));
|
||||
ADD_COMMAND_VOID("get_up_total", rak::make_mem_fun(torrent::up_rate(), &torrent::Rate::total));
|
||||
ADD_COMMAND_VOID("get_down_rate", rak::make_mem_fun(torrent::down_rate(), &torrent::Rate::rate));
|
||||
ADD_COMMAND_VOID("get_down_total", rak::make_mem_fun(torrent::down_rate(), &torrent::Rate::total));
|
||||
|
||||
ADD_VARIABLE_VALUE("tracker_numwant", -1);
|
||||
// TODO: Move the logic into some libtorrent function.
|
||||
CMD2_ANY ("throttle.global_up.rate", std::tr1::bind(&torrent::Rate::rate, torrent::up_rate()));
|
||||
CMD2_ANY ("throttle.global_up.total", std::tr1::bind(&torrent::Rate::total, torrent::up_rate()));
|
||||
CMD2_ANY ("throttle.global_up.max_rate", std::tr1::bind(&torrent::Throttle::max_rate, torrent::up_throttle_global()));
|
||||
CMD2_ANY_VALUE_V ("throttle.global_up.max_rate.set", std::tr1::bind(&ui::Root::set_up_throttle_i64, control->ui(), std::tr1::placeholders::_2));
|
||||
CMD2_ANY ("throttle.global_down.rate", std::tr1::bind(&torrent::Rate::rate, torrent::down_rate()));
|
||||
CMD2_ANY ("throttle.global_down.total", std::tr1::bind(&torrent::Rate::total, torrent::down_rate()));
|
||||
CMD2_ANY ("throttle.global_down.max_rate", std::tr1::bind(&torrent::Throttle::max_rate, torrent::down_throttle_global()));
|
||||
CMD2_ANY_VALUE_V ("throttle.global_down.max_rate.set", std::tr1::bind(&ui::Root::set_down_throttle_i64, control->ui(), std::tr1::placeholders::_2));
|
||||
|
||||
CMD2_ANY_LIST("throttle_up", std::tr1::bind(&apply_throttle, std::tr1::placeholders::_2, true));
|
||||
CMD2_ANY_LIST("throttle_down", std::tr1::bind(&apply_throttle, std::tr1::placeholders::_2, false));
|
||||
@@ -476,26 +484,27 @@ initialize_command_network() {
|
||||
|
||||
CMD2_ANY_STRING ("network.scgi.open_port", std::tr1::bind(&apply_scgi, std::tr1::placeholders::_2, 1));
|
||||
CMD2_ANY_STRING ("network.scgi.open_local", std::tr1::bind(&apply_scgi, std::tr1::placeholders::_2, 2));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("network.scgi.dont_route", "bool|const", int64_t()));
|
||||
CMD2_VAR_BOOL ("network.scgi.dont_route", false);
|
||||
|
||||
ADD_COMMAND_STRING_UN("xmlrpc_dialect", std::ptr_fun(&apply_xmlrpc_dialect));
|
||||
ADD_COMMAND_VALUE_TRI("xmlrpc_size_limit", std::ptr_fun(&rpc::XmlRpc::set_size_limit), rak::ptr_fun(&rpc::XmlRpc::size_limit));
|
||||
CMD2_ANY_STRING ("network.xmlrpc.dialect.set", std::tr1::bind(&apply_xmlrpc_dialect, std::tr1::placeholders::_2));
|
||||
CMD2_ANY ("network.xmlrpc.size_limit", std::tr1::bind(&rpc::XmlRpc::size_limit));
|
||||
CMD2_ANY_VALUE_V ("network.xmlrpc.size_limit.set", std::tr1::bind(&rpc::XmlRpc::set_size_limit, std::tr1::placeholders::_2));
|
||||
|
||||
ADD_COMMAND_VALUE_TRI("hash_read_ahead", std::ptr_fun(&apply_hash_read_ahead), rak::ptr_fun(torrent::hash_read_ahead));
|
||||
ADD_COMMAND_VALUE_TRI("hash_interval", std::ptr_fun(&apply_hash_interval), rak::ptr_fun(torrent::hash_interval));
|
||||
ADD_COMMAND_VALUE_TRI("hash_max_tries", std::ptr_fun(&torrent::set_hash_max_tries), rak::ptr_fun(&torrent::hash_max_tries));
|
||||
// ADD_COMMAND_VALUE_TRI("hash_read_ahead", std::ptr_fun(&apply_hash_read_ahead), rak::ptr_fun(torrent::hash_read_ahead));
|
||||
// ADD_COMMAND_VALUE_TRI("hash_interval", std::ptr_fun(&apply_hash_interval), rak::ptr_fun(torrent::hash_interval));
|
||||
// ADD_COMMAND_VALUE_TRI("hash_max_tries", std::ptr_fun(&torrent::set_hash_max_tries), rak::ptr_fun(&torrent::hash_max_tries));
|
||||
|
||||
ADD_COMMAND_VALUE_UN("enable_trackers", std::ptr_fun(&apply_enable_trackers));
|
||||
ADD_COMMAND_STRING_UN("encoding_list", std::ptr_fun(&apply_encoding_list));
|
||||
CMD2_ANY_VALUE ("trackers.enable", std::tr1::bind(&apply_enable_trackers, int64_t(1)));
|
||||
CMD2_ANY_VALUE ("trackers.disable", std::tr1::bind(&apply_enable_trackers, int64_t(0)));
|
||||
CMD2_VAR_VALUE ("trackers.numwant", -1);
|
||||
CMD2_VAR_BOOL ("trackers.use_udp", true);
|
||||
|
||||
ADD_VARIABLE_VALUE("dht_port", 6881);
|
||||
ADD_COMMAND_STRING_UN("dht", rak::make_mem_fun(control->dht_manager(), &core::DhtManager::set_start));
|
||||
ADD_COMMAND_STRING_UN("dht_add_node", std::ptr_fun(&apply_dht_add_node));
|
||||
ADD_COMMAND_VOID("dht_statistics", rak::make_mem_fun(control->dht_manager(), &core::DhtManager::dht_statistics));
|
||||
ADD_COMMAND_STRING_TRI("dht_throttle", rak::make_mem_fun(control->dht_manager(), &core::DhtManager::set_throttle_name), rak::make_mem_fun(control->dht_manager(), &core::DhtManager::throttle_name));
|
||||
|
||||
ADD_VARIABLE_BOOL("peer_exchange", true);
|
||||
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("log.handshake", "bool|const", int64_t()));
|
||||
rpc::commands.call("method.insert", rpc::create_object_list("log.tracker", "string|const", ""));
|
||||
// CMD2_ANY_V ("dht.enable", std::tr1::bind(&core::DhtManager::set_start, control->dht_manager()));
|
||||
// CMD2_ANY_V ("dht.disable", std::tr1::bind(&core::DhtManager::set_stop, control->dht_manager()));
|
||||
CMD2_ANY_STRING_V("dht.mode", std::tr1::bind(&core::DhtManager::set_start, control->dht_manager(), std::tr1::placeholders::_2));
|
||||
CMD2_VAR_VALUE ("dht.port", int64_t(6881));
|
||||
CMD2_ANY_STRING ("dht.add_node", std::tr1::bind(&apply_dht_add_node, std::tr1::placeholders::_2));
|
||||
CMD2_ANY ("dht.statistics", std::tr1::bind(&core::DhtManager::dht_statistics, control->dht_manager()));
|
||||
CMD2_ANY ("dht.throttle.name", std::tr1::bind(&core::DhtManager::throttle_name, control->dht_manager()));
|
||||
CMD2_ANY_STRING_V("dht.throttle.name.set", std::tr1::bind(&core::DhtManager::set_throttle_name, control->dht_manager(), std::tr1::placeholders::_2));
|
||||
}
|
||||
|
||||
@@ -108,8 +108,8 @@ DownloadFactory::DownloadFactory(Manager* m) :
|
||||
m_taskLoad.set_slot(rak::mem_fn(this, &DownloadFactory::receive_load));
|
||||
m_taskCommit.set_slot(rak::mem_fn(this, &DownloadFactory::receive_commit));
|
||||
|
||||
m_variables["connection_leech"] = rpc::call_command_void("get_connection_leech");
|
||||
m_variables["connection_seed"] = rpc::call_command_void("get_connection_seed");
|
||||
m_variables["connection_leech"] = rpc::call_command_void("connection_leech");
|
||||
m_variables["connection_seed"] = rpc::call_command_void("connection_seed");
|
||||
m_variables["directory"] = rpc::call_command_void("get_directory");
|
||||
m_variables["tied_to_file"] = torrent::Object((int64_t)false);
|
||||
}
|
||||
@@ -251,20 +251,20 @@ DownloadFactory::receive_success() {
|
||||
if (!rtorrent->has_key_string("custom4")) rtorrent->insert_key("custom4", std::string());
|
||||
if (!rtorrent->has_key_string("custom5")) rtorrent->insert_key("custom5", std::string());
|
||||
|
||||
rpc::call_command("d.set_uploads_max", rpc::call_command_void("get_max_uploads"), rpc::make_target(download));
|
||||
rpc::call_command("d.set_peers_min", rpc::call_command_void("get_min_peers"), rpc::make_target(download));
|
||||
rpc::call_command("d.set_peers_max", rpc::call_command_void("get_max_peers"), rpc::make_target(download));
|
||||
rpc::call_command("d.set_tracker_numwant", rpc::call_command_void("get_tracker_numwant"), rpc::make_target(download));
|
||||
rpc::call_command("d.set_uploads_max", rpc::call_command_void("max_uploads"), rpc::make_target(download));
|
||||
rpc::call_command("d.set_peers_min", rpc::call_command_void("min_peers"), rpc::make_target(download));
|
||||
rpc::call_command("d.set_peers_max", rpc::call_command_void("max_peers"), rpc::make_target(download));
|
||||
rpc::call_command("d.set_tracker_numwant", rpc::call_command_void("trackers.numwant"), rpc::make_target(download));
|
||||
|
||||
if (rpc::call_command_value("d.get_complete", rpc::make_target(download)) != 0) {
|
||||
if (rpc::call_command_value("get_min_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_min", rpc::call_command_void("get_min_peers_seed"), rpc::make_target(download));
|
||||
if (rpc::call_command_value("min_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_min", rpc::call_command_void("min_peers_seed"), rpc::make_target(download));
|
||||
|
||||
if (rpc::call_command_value("get_max_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_max", rpc::call_command_void("get_max_peers_seed"), rpc::make_target(download));
|
||||
if (rpc::call_command_value("max_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_max", rpc::call_command_void("max_peers_seed"), rpc::make_target(download));
|
||||
}
|
||||
|
||||
if (!rpc::call_command_value("get_use_udp_trackers"))
|
||||
if (!rpc::call_command_value("trackers.use_udp"))
|
||||
download->enable_udp_trackers(false);
|
||||
|
||||
if (rpc::call_command_value("system.file.max_size") > 0)
|
||||
@@ -287,7 +287,7 @@ DownloadFactory::receive_success() {
|
||||
if (!m_session && m_variables["tied_to_file"].as_value())
|
||||
rpc::call_command("d.set_tied_to_file", m_uri.empty() ? m_variables["tied_file"] : m_uri, rpc::make_target(download));
|
||||
|
||||
rpc::call_command("d.peer_exchange.set", rpc::call_command_value("get_peer_exchange"), rpc::make_target(download));
|
||||
rpc::call_command("d.peer_exchange.set", rpc::call_command_value("protocol.pex"), rpc::make_target(download));
|
||||
|
||||
torrent::resume_load_addresses(*download->download(), resumeObject);
|
||||
torrent::resume_load_file_priorities(*download->download(), resumeObject);
|
||||
|
||||
@@ -579,11 +579,11 @@ DownloadList::confirm_finished(Download* download) {
|
||||
rpc::call_command("d.set_connection_current", rpc::call_command_void("d.get_connection_seed", rpc::make_target(download)), rpc::make_target(download));
|
||||
download->set_priority(download->priority());
|
||||
|
||||
if (rpc::call_command_value("d.get_peers_min", rpc::make_target(download)) == rpc::call_command_value("get_min_peers") && rpc::call_command_value("get_min_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_min", rpc::call_command_void("get_min_peers_seed"), rpc::make_target(download));
|
||||
if (rpc::call_command_value("d.get_peers_min", rpc::make_target(download)) == rpc::call_command_value("min_peers") && rpc::call_command_value("min_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_min", rpc::call_command_void("min_peers_seed"), rpc::make_target(download));
|
||||
|
||||
if (rpc::call_command_value("d.get_peers_max", rpc::make_target(download)) == rpc::call_command_value("get_max_peers") && rpc::call_command_value("get_max_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_max", rpc::call_command_void("get_max_peers_seed"), rpc::make_target(download));
|
||||
if (rpc::call_command_value("d.get_peers_max", rpc::make_target(download)) == rpc::call_command_value("max_peers") && rpc::call_command_value("max_peers_seed") >= 0)
|
||||
rpc::call_command("d.set_peers_max", rpc::call_command_void("max_peers_seed"), rpc::make_target(download));
|
||||
|
||||
// Do this before the slots are called in case one of them closes
|
||||
// the download.
|
||||
|
||||
+3
-3
@@ -257,11 +257,11 @@ void
|
||||
Manager::listen_open() {
|
||||
// This stuff really should be moved outside of manager, make it
|
||||
// part of the init script.
|
||||
if (!rpc::call_command_value("get_port_open"))
|
||||
if (!rpc::call_command_value("port_open"))
|
||||
return;
|
||||
|
||||
int portFirst, portLast;
|
||||
torrent::Object portRange = rpc::call_command_void("get_port_range");
|
||||
torrent::Object portRange = rpc::call_command_void("port_range");
|
||||
|
||||
if (portRange.is_string()) {
|
||||
if (std::sscanf(portRange.as_string().c_str(), "%i-%i", &portFirst, &portLast) != 2)
|
||||
@@ -276,7 +276,7 @@ Manager::listen_open() {
|
||||
if (portFirst > portLast || portLast >= (1 << 16))
|
||||
throw torrent::input_error("Invalid port range.");
|
||||
|
||||
if (rpc::call_command_value("get_port_random")) {
|
||||
if (rpc::call_command_value("port_random")) {
|
||||
int boundary = portFirst + random() % (portLast - portFirst + 1);
|
||||
|
||||
if (torrent::connection_manager()->listen_open(boundary, portLast) ||
|
||||
|
||||
+35
-5
@@ -91,7 +91,7 @@ parse_options(Control* c, int argc, char** argv) {
|
||||
optionParser.insert_option('b', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "network.bind_address.set"));
|
||||
optionParser.insert_option('d', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "directory"));
|
||||
optionParser.insert_option('i', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "ip"));
|
||||
optionParser.insert_option('p', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "port_range"));
|
||||
optionParser.insert_option('p', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "port_range.set"));
|
||||
optionParser.insert_option('s', sigc::bind<0>(sigc::ptr_fun(&rpc::call_command_set_string), "session"));
|
||||
|
||||
optionParser.insert_option('O', sigc::ptr_fun(&rpc::parse_command_single_std));
|
||||
@@ -312,12 +312,12 @@ main(int argc, char** argv) {
|
||||
//
|
||||
// List of cleaned up files:
|
||||
// - command_download.cc
|
||||
// * command_dynamic.cc
|
||||
// / command_events.cc
|
||||
// - command_dynamic.cc
|
||||
// - command_events.cc
|
||||
// - command_file.cc
|
||||
// - command_helpers.cc
|
||||
// * command_local.cc
|
||||
// - command_network.cc
|
||||
// - command_local.cc
|
||||
// * command_network.cc
|
||||
// - command_object.cc
|
||||
// - command_peer.cc
|
||||
// - command_scheduler.cc
|
||||
@@ -356,6 +356,15 @@ main(int argc, char** argv) {
|
||||
"method.insert = get_receive_buffer_size,redirect|const,network.receive_buffer.size\n"
|
||||
"method.insert = set_receive_buffer_size,redirect|const,network.receive_buffer.size.set\n"
|
||||
|
||||
"method.insert = get_up_rate,redirect|const,throttle.global_up.rate\n"
|
||||
"method.insert = get_up_total,redirect|const,throttle.global_up.total\n"
|
||||
"method.insert = get_upload_rate,redirect|const,throttle.global_up.max_rate\n"
|
||||
"method.insert = set_upload_rate,redirect|const,throttle.global_up.max_rate.set\n"
|
||||
"method.insert = get_down_rate,redirect|const,throttle.global_down.rate\n"
|
||||
"method.insert = get_down_total,redirect|const,throttle.global_down.total\n"
|
||||
"method.insert = get_download_rate,redirect|const,throttle.global_down.max_rate\n"
|
||||
"method.insert = set_download_rate,redirect|const,throttle.global_down.max_rate.set\n"
|
||||
|
||||
"method.insert = bind, redirect|const,network.bind_address.set\n"
|
||||
"method.insert = set_bind,redirect|const,network.bind_address.set\n"
|
||||
"method.insert = get_bind,redirect|const,network.bind_address\n"
|
||||
@@ -375,6 +384,21 @@ main(int argc, char** argv) {
|
||||
"method.insert = set_scgi_dont_route,redirect|const,network.scgi.dont_route.set\n"
|
||||
"method.insert = get_scgi_dont_route,redirect|const,network.scgi.dont_route\n"
|
||||
|
||||
"method.insert = xmlrpc_dialect, redirect|const,network.xmlrpc.size_limit.set\n"
|
||||
|
||||
"method.insert = get_connection_leech,redirect|const,connection_leech\n"
|
||||
"method.insert = set_connection_leech,redirect|const,connection_leech.set\n"
|
||||
"method.insert = get_connection_seed,redirect|const,connection_seed\n"
|
||||
"method.insert = set_connection_seed,redirect|const,connection_seed.set\n"
|
||||
|
||||
"method.insert = dht,redirect|const,dht.mode\n"
|
||||
"method.insert = dht_add_node, redirect|const,dht.add_node\n"
|
||||
"method.insert = dht_statistics, redirect|const,dht.statistics\n"
|
||||
"method.insert = get_dht_port, redirect|const,dht.port\n"
|
||||
"method.insert = set_dht_port, redirect|const,dht.port\n"
|
||||
"method.insert = get_dht_throttle,redirect|const,dht.throttle\n"
|
||||
"method.insert = set_dht_throttle,redirect|const,dht.throttle.set\n"
|
||||
|
||||
"method.insert = d.get_hash,redirect|const,d.hash\n"
|
||||
"method.insert = d.get_local_id,redirect|const,d.local_id\n"
|
||||
"method.insert = d.get_local_id_html,redirect|const,d.local_id_html\n"
|
||||
@@ -392,6 +416,12 @@ main(int argc, char** argv) {
|
||||
"method.insert = d.get_down_total,redirect|const,d.down.total\n"
|
||||
"method.insert = d.get_skip_rate,redirect|const,d.skip.rate\n"
|
||||
"method.insert = d.get_skip_total,redirect|const,d.skip.total\n"
|
||||
|
||||
// Functions that might not get depracted as they are nice for
|
||||
// configuration files, and thus might do with just some
|
||||
// cleanup.
|
||||
"method.insert = upload_rate,redirect|const,throttle.global_up.max_rate.set\n"
|
||||
"method.insert = download_rate,redirect|const,throttle.global_down.max_rate.set\n"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -166,8 +166,8 @@ Root::set_down_throttle(unsigned int throttle) {
|
||||
|
||||
torrent::down_throttle_global()->set_max_rate(throttle * 1024);
|
||||
|
||||
unsigned int div = std::max<int>(rpc::call_command_value("get_max_downloads_div"), 0);
|
||||
unsigned int global = std::max<int>(rpc::call_command_value("get_max_downloads_global"), 0);
|
||||
unsigned int div = std::max<int>(rpc::call_command_value("max_downloads_div"), 0);
|
||||
unsigned int global = std::max<int>(rpc::call_command_value("max_downloads_global"), 0);
|
||||
|
||||
if (throttle == 0 || div == 0) {
|
||||
torrent::set_max_download_unchoked(global);
|
||||
@@ -196,8 +196,8 @@ Root::set_up_throttle(unsigned int throttle) {
|
||||
|
||||
torrent::up_throttle_global()->set_max_rate(throttle * 1024);
|
||||
|
||||
unsigned int div = std::max<int>(rpc::call_command_value("get_max_uploads_div"), 0);
|
||||
unsigned int global = std::max<int>(rpc::call_command_value("get_max_uploads_global"), 0);
|
||||
unsigned int div = std::max<int>(rpc::call_command_value("max_uploads_div"), 0);
|
||||
unsigned int global = std::max<int>(rpc::call_command_value("max_uploads_global"), 0);
|
||||
|
||||
if (throttle == 0 || div == 0) {
|
||||
torrent::set_max_unchoked(global);
|
||||
|
||||
Reference in New Issue
Block a user