diff --git a/src/command_helpers.h b/src/command_helpers.h index 07d06eda..b6d47f71 100644 --- a/src/command_helpers.h +++ b/src/command_helpers.h @@ -7,6 +7,25 @@ void initialize_commands(); +// +// Aliases with CMD_* for the below +// + +#define CMD_ANY(key, slot) CMD2_ANY(key, slot) +#define CMD_ANY_P(key, slot) CMD2_ANY_P(key, slot) +#define CMD_REDIRECT(key, slot) CMD2_REDIRECT(key, slot) +#define CMD_REDIRECT_NO_EXPORT(key, slot) CMD2_REDIRECT_NO_EXPORT(key, slot) +#define CMD_ANY_STRING(key, slot) CMD2_ANY_STRING(key, slot) +#define CMD_ANY_STRING_V(key, slot) CMD2_ANY_STRING_V(key, slot) +#define CMD_ANY_LIST(key, slot) CMD2_ANY_LIST(key, slot) +#define CMD_VAR_VALUE(key, value) CMD2_VAR_VALUE(key, value) +#define CMD_VAR_BOOL(key, value) CMD2_VAR_BOOL(key, value) +#define CMD_VAR_STRING(key, value) CMD2_VAR_STRING(key, value) +#define CMD_VAR_C_STRING(key, value) CMD2_VAR_C_STRING(key, value) +#define CMD_VAR_LIST(key) CMD2_VAR_LIST(key) +#define CMD_ANY_V(key, slot) CMD2_ANY_V(key, slot) +#define CMD_ANY_VALUE_V(key, slot) CMD2_ANY_VALUE_V(key, slot) + // // New std::function based command_base helper functions: // @@ -115,7 +134,6 @@ void initialize_commands(); #define CMD2_REDIRECT_TRACKER(from_key, to_key) \ rpc::commands.create_redirect(from_key, to_key, rpc::CommandMap::flag_public_rpc | rpc::CommandMap::flag_tracker_target | rpc::CommandMap::flag_dont_delete); - // // Conversion of return types: // diff --git a/src/command_local.cc b/src/command_local.cc index cf0620c7..d85b0f41 100644 --- a/src/command_local.cc +++ b/src/command_local.cc @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -191,139 +192,149 @@ initialize_command_local() { torrent::FileManager* fileManager = torrent::file_manager(); if (rpc::call_command_value("method.use_deprecated") == 1) { - CMD2_ANY_LIST ("file.append", std::bind(&cmd_file_append, std::placeholders::_2)); + CMD_ANY_LIST ("file.append", std::bind(&cmd_file_append, std::placeholders::_2)); } - CMD2_ANY ("system.hostname", std::bind(&system_hostname)); - CMD2_ANY ("system.pid", std::bind(&getpid)); + CMD_ANY ("system.hostname", std::bind(&system_hostname)); + CMD_ANY ("system.pid", std::bind(&getpid)); - CMD2_VAR_C_STRING("system.api_version", (int64_t)API_VERSION); - CMD2_VAR_C_STRING("system.client_version", PACKAGE_VERSION); - CMD2_VAR_C_STRING("system.library_version", torrent::runtime::version()); + CMD_VAR_C_STRING("system.api_version", (int64_t)API_VERSION); + CMD_VAR_C_STRING("system.client_version", PACKAGE_VERSION); + CMD_VAR_C_STRING("system.library_version", torrent::runtime::version()); - CMD2_VAR_VALUE ("system.file.allocate", 0); - CMD2_VAR_VALUE ("system.file.max_size", (int64_t)512 << 30); - CMD2_VAR_VALUE ("system.file.split_size", -1); - CMD2_VAR_STRING ("system.file.split_suffix", ".part"); + CMD_VAR_VALUE ("system.file.allocate", 0); + CMD_VAR_VALUE ("system.file.max_size", (int64_t)512 << 30); + CMD_VAR_VALUE ("system.file.split_size", -1); + CMD_VAR_STRING ("system.file.split_suffix", ".part"); - CMD2_ANY ("system.file_status_cache.size", std::bind(&utils::FileStatusCache::size, + CMD_ANY ("system.file_status_cache.size", std::bind(&utils::FileStatusCache::size, (utils::FileStatusCache::base_type*)control->core()->file_status_cache())); - CMD2_ANY_V ("system.file_status_cache.prune", std::bind(&utils::FileStatusCache::prune, control->core()->file_status_cache())); + CMD_ANY_V ("system.file_status_cache.prune", std::bind(&utils::FileStatusCache::prune, control->core()->file_status_cache())); - CMD2_VAR_BOOL ("file.prioritize_toc", 0); - CMD2_VAR_LIST ("file.prioritize_toc.first"); - CMD2_VAR_LIST ("file.prioritize_toc.last"); + CMD_VAR_BOOL ("file.prioritize_toc", 0); + CMD_VAR_LIST ("file.prioritize_toc.first"); + CMD_VAR_LIST ("file.prioritize_toc.last"); - CMD2_ANY ("system.files.advise_random", std::bind(&FM_t::advise_random, fileManager)); - CMD2_ANY_VALUE_V ("system.files.advise_random.set", std::bind(&FM_t::set_advise_random, fileManager, std::placeholders::_2)); - CMD2_ANY ("system.files.advise_random.hashing", std::bind(&FM_t::advise_random_hashing, fileManager)); - CMD2_ANY_VALUE_V ("system.files.advise_random.hashing.set", std::bind(&FM_t::set_advise_random_hashing, fileManager, std::placeholders::_2)); - CMD2_ANY ("system.files.session.fdatasync", [](auto, auto) { return session_thread::manager()->use_fsyncdisk(); }); - CMD2_ANY_VALUE_V ("system.files.session.fdatasync.set", [](auto, auto& value) { return session_thread::manager()->set_use_fsyncdisk(value); }); + CMD_ANY ("system.files.advise_random", std::bind(&FM_t::advise_random, fileManager)); + CMD_ANY_VALUE_V ("system.files.advise_random.set", std::bind(&FM_t::set_advise_random, fileManager, std::placeholders::_2)); + CMD_ANY ("system.files.advise_random.hashing", std::bind(&FM_t::advise_random_hashing, fileManager)); + CMD_ANY_VALUE_V ("system.files.advise_random.hashing.set", std::bind(&FM_t::set_advise_random_hashing, fileManager, std::placeholders::_2)); + CMD_ANY ("system.files.session.fdatasync", [](auto, auto) { return session_thread::manager()->use_fsyncdisk(); }); + CMD_ANY_VALUE_V ("system.files.session.fdatasync.set", [](auto, auto& value) { return session_thread::manager()->set_use_fsyncdisk(value); }); - CMD2_ANY ("system.files.opened_counter", std::bind(&FM_t::files_opened_counter, fileManager)); - CMD2_ANY ("system.files.closed_counter", std::bind(&FM_t::files_closed_counter, fileManager)); - CMD2_ANY ("system.files.failed_counter", std::bind(&FM_t::files_failed_counter, fileManager)); + CMD_ANY ("system.files.opened_counter", std::bind(&FM_t::files_opened_counter, fileManager)); + CMD_ANY ("system.files.closed_counter", std::bind(&FM_t::files_closed_counter, fileManager)); + CMD_ANY ("system.files.failed_counter", std::bind(&FM_t::files_failed_counter, fileManager)); - CMD2_ANY_STRING ("system.env", std::bind(&system_env, std::placeholders::_2)); + CMD_ANY_STRING ("system.env", [](auto, auto& str) { return system_env(str); }); - CMD2_ANY ("system.time", []([[maybe_unused]] auto t, [[maybe_unused]] auto o) -> torrent::Object { - return torrent::this_thread::cached_seconds().count(); - }); - CMD2_ANY ("system.time_seconds", []([[maybe_unused]] auto t, [[maybe_unused]] auto o) -> torrent::Object { - return torrent::utils::cast_seconds(torrent::utils::time_since_epoch()).count(); - }); - CMD2_ANY ("system.time_usec", []([[maybe_unused]] auto t, [[maybe_unused]] auto o) -> torrent::Object { - return torrent::utils::time_since_epoch().count(); - }); + CMD_ANY ("system.time", [](auto, auto) { return torrent::this_thread::cached_seconds().count(); }); + CMD_ANY ("system.time_seconds", [](auto, auto) { return torrent::utils::cast_seconds(torrent::utils::time_since_epoch()).count(); }); + CMD_ANY ("system.time_usec", [](auto, auto) { return torrent::utils::time_since_epoch().count(); }); - CMD2_ANY_VALUE_V ("system.umask.set", std::bind(&umask, std::placeholders::_2)); + CMD_ANY_VALUE_V ("system.umask.set", [](auto, auto& value) { return ::umask(value); }); - CMD2_VAR_BOOL ("system.daemon", false); + CMD_VAR_BOOL ("system.daemon", false); - CMD2_ANY_V ("system.shutdown.normal", std::bind(&Control::receive_normal_shutdown, control)); - CMD2_ANY_V ("system.shutdown.quick", std::bind(&Control::receive_quick_shutdown, control)); - CMD2_REDIRECT_NO_EXPORT("system.shutdown", "system.shutdown.normal"); + CMD_ANY_V ("system.shutdown.normal", [](auto, auto) { control->receive_normal_shutdown(); }); + CMD_ANY_V ("system.shutdown.quick", [](auto, auto) { control->receive_quick_shutdown(); }); - CMD2_ANY ("system.cwd", std::bind(&system_get_cwd)); - CMD2_ANY_STRING ("system.cwd.set", std::bind(&system_set_cwd, std::placeholders::_2)); + CMD_REDIRECT_NO_EXPORT("system.shutdown", "system.shutdown.normal"); - CMD2_ANY ("pieces.sync.always_safe", std::bind(&CM_t::safe_sync, chunkManager)); - CMD2_ANY_VALUE_V ("pieces.sync.always_safe.set", std::bind(&CM_t::set_safe_sync, chunkManager, std::placeholders::_2)); - CMD2_ANY ("pieces.sync.safe_free_diskspace", std::bind(&CM_t::safe_free_diskspace, chunkManager)); - CMD2_ANY ("pieces.sync.timeout", std::bind(&CM_t::timeout_sync, chunkManager)); - CMD2_ANY_VALUE_V ("pieces.sync.timeout.set", std::bind(&CM_t::set_timeout_sync, chunkManager, std::placeholders::_2)); - CMD2_ANY ("pieces.sync.timeout_safe", std::bind(&CM_t::timeout_safe_sync, chunkManager)); - CMD2_ANY_VALUE_V ("pieces.sync.timeout_safe.set", std::bind(&CM_t::set_timeout_safe_sync, chunkManager, std::placeholders::_2)); - CMD2_ANY ("pieces.sync.queue_size", std::bind(&CM_t::sync_queue_size, chunkManager)); + CMD_ANY ("system.cwd", [](auto, auto) { return system_get_cwd(); }); + CMD_ANY_STRING ("system.cwd.set", [](auto, auto& str) { return system_set_cwd(str); }); - CMD2_ANY ("pieces.preload.type", std::bind(&CM_t::preload_type, chunkManager)); - CMD2_ANY_VALUE_V ("pieces.preload.type.set", std::bind(&CM_t::set_preload_type, chunkManager, std::placeholders::_2)); - CMD2_ANY ("pieces.preload.min_size", std::bind(&CM_t::preload_min_size, chunkManager)); - CMD2_ANY_VALUE_V ("pieces.preload.min_size.set", std::bind(&CM_t::set_preload_min_size, chunkManager, std::placeholders::_2)); - CMD2_ANY ("pieces.preload.min_rate", std::bind(&CM_t::preload_required_rate, chunkManager)); - CMD2_ANY_VALUE_V ("pieces.preload.min_rate.set", std::bind(&CM_t::set_preload_required_rate, chunkManager, std::placeholders::_2)); + CMD_ANY ("system.sockets.size", [](auto, auto) { return torrent::runtime::socket_manager()->size(); }); + CMD_ANY ("system.sockets.max_size", [](auto, auto) { return torrent::runtime::socket_manager()->max_size(); }); + CMD_ANY_VALUE_V ("system.sockets.max_size.set", [](auto, auto& value) { return torrent::runtime::socket_manager()->set_max_size_and_adjust(value); }); - CMD2_ANY ("pieces.memory.current", std::bind(&CM_t::memory_usage, chunkManager)); - CMD2_ANY ("pieces.memory.sync_queue", std::bind(&CM_t::sync_queue_memory_usage, chunkManager)); - CMD2_ANY ("pieces.memory.block_count", std::bind(&CM_t::memory_block_count, chunkManager)); - CMD2_ANY ("pieces.memory.max", std::bind(&CM_t::max_memory_usage, chunkManager)); - CMD2_ANY_VALUE_V ("pieces.memory.max.set", std::bind(&CM_t::set_max_memory_usage, chunkManager, std::placeholders::_2)); - CMD2_ANY ("pieces.stats_preloaded", std::bind(&CM_t::stats_preloaded, chunkManager)); - CMD2_ANY ("pieces.stats_not_preloaded", std::bind(&CM_t::stats_not_preloaded, chunkManager)); + CMD_ANY ("system.sockets.generic.size", [](auto, auto) { return torrent::runtime::socket_manager()->category_managed_size(torrent::runtime::category_generic); }); + CMD_ANY ("system.sockets.generic.max_size", [](auto, auto) { return torrent::runtime::socket_manager()->category_max_size(torrent::runtime::category_generic); }); + CMD_ANY ("system.sockets.http.size", [](auto, auto) { return torrent::runtime::socket_manager()->category_managed_size(torrent::runtime::category_http); }); + CMD_ANY ("system.sockets.http.max_size", [](auto, auto) { return torrent::runtime::socket_manager()->category_max_size(torrent::runtime::category_http); }); + CMD_ANY ("system.sockets.internal.size", [](auto, auto) { return torrent::runtime::socket_manager()->category_managed_size(torrent::runtime::category_internal); }); + CMD_ANY ("system.sockets.internal.max_size",[](auto, auto) { return torrent::runtime::socket_manager()->category_max_size(torrent::runtime::category_internal); }); + CMD_ANY ("system.sockets.scgi.size", [](auto, auto) { return torrent::runtime::socket_manager()->category_managed_size(torrent::runtime::category_scgi); }); + CMD_ANY ("system.sockets.scgi.max_size", [](auto, auto) { return torrent::runtime::socket_manager()->category_max_size(torrent::runtime::category_scgi); }); + CMD_ANY ("system.sockets.files.size", [](auto, auto) { return torrent::runtime::socket_manager()->category_managed_size(torrent::runtime::category_files); }); + CMD_ANY ("system.sockets.files.max_size", [](auto, auto) { return torrent::runtime::socket_manager()->category_max_size(torrent::runtime::category_files); }); - CMD2_ANY ("pieces.stats.total_size", std::bind(&apply_pieces_stats_total_size)); + CMD_ANY ("pieces.sync.always_safe", std::bind(&CM_t::safe_sync, chunkManager)); + CMD_ANY_VALUE_V ("pieces.sync.always_safe.set", std::bind(&CM_t::set_safe_sync, chunkManager, std::placeholders::_2)); + CMD_ANY ("pieces.sync.safe_free_diskspace", std::bind(&CM_t::safe_free_diskspace, chunkManager)); + CMD_ANY ("pieces.sync.timeout", std::bind(&CM_t::timeout_sync, chunkManager)); + CMD_ANY_VALUE_V ("pieces.sync.timeout.set", std::bind(&CM_t::set_timeout_sync, chunkManager, std::placeholders::_2)); + CMD_ANY ("pieces.sync.timeout_safe", std::bind(&CM_t::timeout_safe_sync, chunkManager)); + CMD_ANY_VALUE_V ("pieces.sync.timeout_safe.set", std::bind(&CM_t::set_timeout_safe_sync, chunkManager, std::placeholders::_2)); + CMD_ANY ("pieces.sync.queue_size", std::bind(&CM_t::sync_queue_size, chunkManager)); - CMD2_ANY ("pieces.hash.queue_size", std::bind(&torrent::main_thread::hash_queue_size)); - CMD2_VAR_BOOL ("pieces.hash.on_completion", true); + CMD_ANY ("pieces.preload.type", std::bind(&CM_t::preload_type, chunkManager)); + CMD_ANY_VALUE_V ("pieces.preload.type.set", std::bind(&CM_t::set_preload_type, chunkManager, std::placeholders::_2)); + CMD_ANY ("pieces.preload.min_size", std::bind(&CM_t::preload_min_size, chunkManager)); + CMD_ANY_VALUE_V ("pieces.preload.min_size.set", std::bind(&CM_t::set_preload_min_size, chunkManager, std::placeholders::_2)); + CMD_ANY ("pieces.preload.min_rate", std::bind(&CM_t::preload_required_rate, chunkManager)); + CMD_ANY_VALUE_V ("pieces.preload.min_rate.set", std::bind(&CM_t::set_preload_required_rate, chunkManager, std::placeholders::_2)); - CMD2_VAR_STRING ("directory.default", "./"); + CMD_ANY ("pieces.memory.current", std::bind(&CM_t::memory_usage, chunkManager)); + CMD_ANY ("pieces.memory.sync_queue", std::bind(&CM_t::sync_queue_memory_usage, chunkManager)); + CMD_ANY ("pieces.memory.block_count", std::bind(&CM_t::memory_block_count, chunkManager)); + CMD_ANY ("pieces.memory.max", std::bind(&CM_t::max_memory_usage, chunkManager)); + CMD_ANY_VALUE_V ("pieces.memory.max.set", std::bind(&CM_t::set_max_memory_usage, chunkManager, std::placeholders::_2)); + CMD_ANY ("pieces.stats_preloaded", std::bind(&CM_t::stats_preloaded, chunkManager)); + CMD_ANY ("pieces.stats_not_preloaded", std::bind(&CM_t::stats_not_preloaded, chunkManager)); - CMD2_VAR_STRING ("session.name", ""); - CMD2_ANY ("session.path", [](auto, auto) { return session_thread::manager()->path(); }); - CMD2_ANY_STRING_V("session.path.set", [](auto, auto& str) { return session_thread::manager()->set_path(str); }); - CMD2_ANY ("session.use_lock", [](auto, auto) { return session_thread::manager()->use_lock(); }); - CMD2_ANY_VALUE_V ("session.use_lock.set", [](auto, auto& value) { return session_thread::manager()->set_use_lock(value); }); - CMD2_VAR_BOOL ("session.on_completion", true); + CMD_ANY ("pieces.stats.total_size", std::bind(&apply_pieces_stats_total_size)); - CMD2_ANY_V ("session.save", [dList](auto, auto) { return dList->session_save(); }); + CMD_ANY ("pieces.hash.queue_size", std::bind(&torrent::main_thread::hash_queue_size)); + CMD_VAR_BOOL ("pieces.hash.on_completion", true); - CMD2_ANY ("magnet.path", [](auto, auto) { return control->core()->magnet_path(); }); - CMD2_ANY_STRING_V("magnet.path.set", [](auto, auto& str) { return control->core()->set_magnet_path(str); }); + CMD_VAR_STRING ("directory.default", "./"); + + CMD_VAR_STRING ("session.name", ""); + CMD_ANY ("session.path", [](auto, auto) { return session_thread::manager()->path(); }); + CMD_ANY_STRING_V("session.path.set", [](auto, auto& str) { return session_thread::manager()->set_path(str); }); + CMD_ANY ("session.use_lock", [](auto, auto) { return session_thread::manager()->use_lock(); }); + CMD_ANY_VALUE_V ("session.use_lock.set", [](auto, auto& value) { return session_thread::manager()->set_use_lock(value); }); + CMD_VAR_BOOL ("session.on_completion", true); + + CMD_ANY_V ("session.save", [dList](auto, auto) { return dList->session_save(); }); + + CMD_ANY ("magnet.path", [](auto, auto) { return control->core()->magnet_path(); }); + CMD_ANY_STRING_V("magnet.path.set", [](auto, auto& str) { return control->core()->set_magnet_path(str); }); #ifdef HAVE_LUA rpc::LuaEngine* lua_engine = control->lua_engine(); - CMD2_ANY ("lua.execute", std::bind(&rpc::execute_lua, lua_engine, std::placeholders::_1, std::placeholders::_2, 0)); - CMD2_ANY ("lua.execute.str", std::bind(&rpc::execute_lua, lua_engine, std::placeholders::_1, std::placeholders::_2, rpc::LuaEngine::flag_string)); + CMD_ANY ("lua.execute", std::bind(&rpc::execute_lua, lua_engine, std::placeholders::_1, std::placeholders::_2, 0)); + CMD_ANY ("lua.execute.str", std::bind(&rpc::execute_lua, lua_engine, std::placeholders::_1, std::placeholders::_2, rpc::LuaEngine::flag_string)); #endif -#define CMD2_EXECUTE(key, flags) \ - CMD2_ANY(key, std::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::placeholders::_2, flags)); +#define CMD_EXECUTE(key, flags) \ + CMD_ANY(key, std::bind(&rpc::ExecFile::execute_object, &rpc::execFile, std::placeholders::_2, flags)); - CMD2_EXECUTE ("execute", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw); - CMD2_EXECUTE ("execute.throw", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw); - CMD2_EXECUTE ("execute.throw.bg", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw | rpc::ExecFile::flag_background); - CMD2_EXECUTE ("execute.nothrow", rpc::ExecFile::flag_expand_tilde); - CMD2_EXECUTE ("execute.nothrow.bg", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_background); - CMD2_EXECUTE ("execute.raw", rpc::ExecFile::flag_throw); - CMD2_EXECUTE ("execute.raw.bg", rpc::ExecFile::flag_throw | rpc::ExecFile::flag_background); - CMD2_EXECUTE ("execute.raw_nothrow", 0); - CMD2_EXECUTE ("execute.raw_nothrow.bg", rpc::ExecFile::flag_background); - CMD2_EXECUTE ("execute.capture", rpc::ExecFile::flag_throw | rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture); - CMD2_EXECUTE ("execute.capture_nothrow", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture); + CMD_EXECUTE ("execute", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw); + CMD_EXECUTE ("execute.throw", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw); + CMD_EXECUTE ("execute.throw.bg", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_throw | rpc::ExecFile::flag_background); + CMD_EXECUTE ("execute.nothrow", rpc::ExecFile::flag_expand_tilde); + CMD_EXECUTE ("execute.nothrow.bg", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_background); + CMD_EXECUTE ("execute.raw", rpc::ExecFile::flag_throw); + CMD_EXECUTE ("execute.raw.bg", rpc::ExecFile::flag_throw | rpc::ExecFile::flag_background); + CMD_EXECUTE ("execute.raw_nothrow", 0); + CMD_EXECUTE ("execute.raw_nothrow.bg", rpc::ExecFile::flag_background); + CMD_EXECUTE ("execute.capture", rpc::ExecFile::flag_throw | rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture); + CMD_EXECUTE ("execute.capture_nothrow", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture); // TODO: Convert to new command types: *rpc::command_base::argument(0) = "placeholder.0"; *rpc::command_base::argument(1) = "placeholder.1"; *rpc::command_base::argument(2) = "placeholder.2"; *rpc::command_base::argument(3) = "placeholder.3"; - CMD2_ANY_P("argument.0", std::bind(&rpc::command_base::argument_ref, 0)); - CMD2_ANY_P("argument.1", std::bind(&rpc::command_base::argument_ref, 1)); - CMD2_ANY_P("argument.2", std::bind(&rpc::command_base::argument_ref, 2)); - CMD2_ANY_P("argument.3", std::bind(&rpc::command_base::argument_ref, 3)); + CMD_ANY_P("argument.0", std::bind(&rpc::command_base::argument_ref, 0)); + CMD_ANY_P("argument.1", std::bind(&rpc::command_base::argument_ref, 1)); + CMD_ANY_P("argument.2", std::bind(&rpc::command_base::argument_ref, 2)); + CMD_ANY_P("argument.3", std::bind(&rpc::command_base::argument_ref, 3)); - CMD2_ANY_LIST ("group.insert", std::bind(&group_insert, std::placeholders::_2)); + CMD_ANY_LIST ("group.insert", std::bind(&group_insert, std::placeholders::_2)); rpc::rpc.mark_safe("system.api_version"); rpc::rpc.mark_safe("system.client_version"); @@ -332,6 +343,19 @@ initialize_command_local() { rpc::rpc.mark_safe("system.file.split_size"); rpc::rpc.mark_safe("system.file.split_suffix"); + rpc::rpc.mark_safe("system.sockets.size"); + rpc::rpc.mark_safe("system.sockets.max_size"); + rpc::rpc.mark_safe("system.sockets.generic.size"); + rpc::rpc.mark_safe("system.sockets.generic.max_size"); + rpc::rpc.mark_safe("system.sockets.http.size"); + rpc::rpc.mark_safe("system.sockets.http.max_size"); + rpc::rpc.mark_safe("system.sockets.internal.size"); + rpc::rpc.mark_safe("system.sockets.internal.max_size"); + rpc::rpc.mark_safe("system.sockets.scgi.size"); + rpc::rpc.mark_safe("system.sockets.scgi.max_size"); + rpc::rpc.mark_safe("system.sockets.files.size"); + rpc::rpc.mark_safe("system.sockets.files.max_size"); + rpc::rpc.mark_safe("directory.default"); rpc::rpc.mark_safe("session.path"); rpc::rpc.mark_safe("session.use_lock"); diff --git a/src/command_network.cc b/src/command_network.cc index d0bfeacc..aeab36b3 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -263,7 +263,7 @@ initialize_command_network() { CMD2_ANY_VALUE_V ("network.send_buffer.size.set", [nw_config](auto, auto& value) { return nw_config->set_send_buffer_size(value); }); CMD2_ANY ("network.receive_buffer.size", [nw_config](auto, auto) { return nw_config->receive_buffer_size(); }); CMD2_ANY_VALUE_V ("network.receive_buffer.size.set", [nw_config](auto, auto& value) { return nw_config->set_receive_buffer_size(value); }); - CMD2_ANY_STRING ("network.tos.set", [](auto, auto& str) { return apply_tos(str); }); + CMD2_ANY_STRING ("network.tos.set", [](auto, auto& str) { return apply_tos(str); }); CMD2_ANY ("network.bind_address", [nw_config](auto, auto) { return nw_config->bind_address_best_match_str(); }); CMD2_ANY_STRING_V("network.bind_address.set", [nw_config](auto, auto& str) { return nw_config->set_bind_address_str(str); }); @@ -286,9 +286,6 @@ initialize_command_network() { CMD2_ANY ("network.max_open_files", [file_manager](auto, auto) { return file_manager->max_open_files(); }); CMD2_ANY_VALUE_V ("network.max_open_files.set", [file_manager](auto, auto& value) { return file_manager->set_max_open_files(value); }); CMD2_ANY ("network.total_handshakes", [](auto, auto) { return torrent::runtime::total_handshakes(); }); - CMD2_ANY ("network.open_sockets", [](auto, auto) { return torrent::runtime::socket_manager()->size(); }); - CMD2_ANY ("network.max_open_sockets", [](auto, auto) { return torrent::runtime::socket_manager()->max_size(); }); - CMD2_ANY_VALUE_V ("network.max_open_sockets.set", [](auto, auto& value) { return torrent::runtime::socket_manager()->set_max_size_and_adjust(value); }); CMD2_ANY_STRING ("network.scgi.open_port", std::bind(&apply_scgi, std::placeholders::_2, 1)); CMD2_ANY_STRING ("network.scgi.open_local", std::bind(&apply_scgi, std::placeholders::_2, 2)); @@ -329,10 +326,9 @@ initialize_command_network() { rpc::rpc.mark_safe("network.http.max_host_connections"); rpc::rpc.mark_safe("network.http.max_total_connections"); + rpc::rpc.mark_safe("network.total_handshakes"); rpc::rpc.mark_safe("network.open_files"); rpc::rpc.mark_safe("network.max_open_files"); - rpc::rpc.mark_safe("network.max_open_sockets"); - rpc::rpc.mark_safe("network.total_handshakes"); rpc::rpc.mark_safe("network.send_buffer.size"); rpc::rpc.mark_safe("network.receive_buffer.size"); diff --git a/src/main.cc b/src/main.cc index 6fc782cf..d844a972 100644 --- a/src/main.cc +++ b/src/main.cc @@ -296,56 +296,63 @@ main(int argc, char** argv) { // Functions that might not get depracted as they are nice for // configuration files, and thus might do with just some // cleanup. - CMD2_REDIRECT("upload_rate", "throttle.global_up.max_rate.set_kb"); - CMD2_REDIRECT("download_rate", "throttle.global_down.max_rate.set_kb"); + CMD_REDIRECT("upload_rate", "throttle.global_up.max_rate.set_kb"); + CMD_REDIRECT("download_rate", "throttle.global_down.max_rate.set_kb"); - CMD2_REDIRECT("ratio.enable", "group.seeding.ratio.enable"); - CMD2_REDIRECT("ratio.disable", "group.seeding.ratio.disable"); - CMD2_REDIRECT("ratio.min", "group.seeding.ratio.min"); - CMD2_REDIRECT("ratio.max", "group.seeding.ratio.max"); - CMD2_REDIRECT("ratio.upload", "group.seeding.ratio.upload"); - CMD2_REDIRECT("ratio.min.set", "group.seeding.ratio.min.set"); - CMD2_REDIRECT("ratio.max.set", "group.seeding.ratio.max.set"); - CMD2_REDIRECT("ratio.upload.set", "group.seeding.ratio.upload.set"); + CMD_REDIRECT("ratio.enable", "group.seeding.ratio.enable"); + CMD_REDIRECT("ratio.disable", "group.seeding.ratio.disable"); + CMD_REDIRECT("ratio.min", "group.seeding.ratio.min"); + CMD_REDIRECT("ratio.max", "group.seeding.ratio.max"); + CMD_REDIRECT("ratio.upload", "group.seeding.ratio.upload"); + CMD_REDIRECT("ratio.min.set", "group.seeding.ratio.min.set"); + CMD_REDIRECT("ratio.max.set", "group.seeding.ratio.max.set"); + CMD_REDIRECT("ratio.upload.set", "group.seeding.ratio.upload.set"); - CMD2_REDIRECT("encryption", "protocol.encryption.set"); + CMD_REDIRECT("encryption", "protocol.encryption.set"); - CMD2_REDIRECT("check_hash", "pieces.hash.on_completion.set"); + CMD_REDIRECT("check_hash", "pieces.hash.on_completion.set"); - CMD2_REDIRECT("connection_leech", "protocol.connection.leech.set"); - CMD2_REDIRECT("connection_seed", "protocol.connection.seed.set"); + CMD_REDIRECT("connection_leech", "protocol.connection.leech.set"); + CMD_REDIRECT("connection_seed", "protocol.connection.seed.set"); - CMD2_REDIRECT("min_peers", "throttle.min_peers.normal.set"); - CMD2_REDIRECT("max_peers", "throttle.max_peers.normal.set"); - CMD2_REDIRECT("min_peers_seed", "throttle.min_peers.seed.set"); - CMD2_REDIRECT("max_peers_seed", "throttle.max_peers.seed.set"); + CMD_REDIRECT("min_peers", "throttle.min_peers.normal.set"); + CMD_REDIRECT("max_peers", "throttle.max_peers.normal.set"); + CMD_REDIRECT("min_peers_seed", "throttle.min_peers.seed.set"); + CMD_REDIRECT("max_peers_seed", "throttle.max_peers.seed.set"); - CMD2_REDIRECT("min_uploads", "throttle.min_uploads.set"); - CMD2_REDIRECT("max_uploads", "throttle.max_uploads.set"); - CMD2_REDIRECT("min_downloads", "throttle.min_downloads.set"); - CMD2_REDIRECT("max_downloads", "throttle.max_downloads.set"); + CMD_REDIRECT("min_uploads", "throttle.min_uploads.set"); + CMD_REDIRECT("max_uploads", "throttle.max_uploads.set"); + CMD_REDIRECT("min_downloads", "throttle.min_downloads.set"); + CMD_REDIRECT("max_downloads", "throttle.max_downloads.set"); - CMD2_REDIRECT("max_uploads_div", "throttle.max_uploads.div.set"); - CMD2_REDIRECT("max_uploads_global", "throttle.max_uploads.global.set"); - CMD2_REDIRECT("max_downloads_div", "throttle.max_downloads.div.set"); - CMD2_REDIRECT("max_downloads_global", "throttle.max_downloads.global.set"); + CMD_REDIRECT("max_uploads_div", "throttle.max_uploads.div.set"); + CMD_REDIRECT("max_uploads_global", "throttle.max_uploads.global.set"); + CMD_REDIRECT("max_downloads_div", "throttle.max_downloads.div.set"); + CMD_REDIRECT("max_downloads_global", "throttle.max_downloads.global.set"); - CMD2_REDIRECT("directory", "directory.default.set"); - CMD2_REDIRECT("session", "session.path.set"); + CMD_REDIRECT("directory", "directory.default.set"); + CMD_REDIRECT("session", "session.path.set"); - CMD2_REDIRECT("scgi_port", "network.scgi.open_port"); - CMD2_REDIRECT("scgi_local", "network.scgi.open_local"); + CMD_REDIRECT("scgi_port", "network.scgi.open_port"); + CMD_REDIRECT("scgi_local", "network.scgi.open_local"); - CMD2_REDIRECT("to_gm_time", "convert.gm_time"); - CMD2_REDIRECT("to_gm_date", "convert.gm_date"); - CMD2_REDIRECT("to_time", "convert.time"); - CMD2_REDIRECT("to_date", "convert.date"); - CMD2_REDIRECT("to_elapsed_time", "convert.elapsed_time"); - CMD2_REDIRECT("to_kb", "convert.kb"); - CMD2_REDIRECT("to_mb", "convert.mb"); - CMD2_REDIRECT("to_xb", "convert.xb"); - CMD2_REDIRECT("to_throttle", "convert.throttle"); + CMD_REDIRECT("to_gm_time", "convert.gm_time"); + CMD_REDIRECT("to_gm_date", "convert.gm_date"); + CMD_REDIRECT("to_time", "convert.time"); + CMD_REDIRECT("to_date", "convert.date"); + CMD_REDIRECT("to_elapsed_time", "convert.elapsed_time"); + CMD_REDIRECT("to_kb", "convert.kb"); + CMD_REDIRECT("to_mb", "convert.mb"); + CMD_REDIRECT("to_xb", "convert.xb"); + CMD_REDIRECT("to_throttle", "convert.throttle"); + // TODO: Deprecate these at some point a while after 1.1 release. + + CMD_REDIRECT("network.open_sockets", "system.sockets.size"); + CMD_REDIRECT("network.max_open_sockets", "system.sockets.max_size"); + CMD_REDIRECT("network.max_open_sockets.set", "system.sockets.max_size.set"); + + rpc::rpc.mark_safe("network.max_open_sockets"); // if (rpc::call_command_value("method.use_intermediate") == 1) { @@ -354,41 +361,41 @@ main(int argc, char** argv) { // } if (rpc::call_command_value("method.use_deprecated") == 1) { - CMD2_REDIRECT("execute2", "execute"); - CMD2_REDIRECT("schedule2", "schedule"); - CMD2_REDIRECT("schedule_remove2", "schedule.remove"); + CMD_REDIRECT("execute2", "execute"); + CMD_REDIRECT("schedule2", "schedule"); + CMD_REDIRECT("schedule_remove2", "schedule.remove"); // TODO: Remove file.append when cleaning these up. - CMD2_REDIRECT("bind", "network.bind_address.set"); - CMD2_REDIRECT("ip", "network.local_address.set"); - CMD2_REDIRECT("port_range", "network.port_range.set"); + CMD_REDIRECT("bind", "network.bind_address.set"); + CMD_REDIRECT("ip", "network.local_address.set"); + CMD_REDIRECT("port_range", "network.port_range.set"); // TODO: Check if dht is on by default. - CMD2_REDIRECT("dht", "dht.mode.set"); + CMD_REDIRECT("dht", "dht.mode.set"); - CMD2_REDIRECT("port_random", "network.port_random.set"); - CMD2_REDIRECT("proxy_address", "network.proxy_address.set"); + CMD_REDIRECT("port_random", "network.port_random.set"); + CMD_REDIRECT("proxy_address", "network.proxy_address.set"); - CMD2_REDIRECT("key_layout", "keys.layout.set"); + CMD_REDIRECT("key_layout", "keys.layout.set"); - CMD2_REDIRECT("torrent_list_layout", "ui.torrent_list.layout.set"); + CMD_REDIRECT("torrent_list_layout", "ui.torrent_list.layout.set"); CMD2_VAR_STRING("dht.throttle.name", "deprecated"); rpc::rpc.mark_safe("dht.throttle.name"); - CMD2_REDIRECT("network.http.max_open", "network.http.max_total_connections"); - CMD2_REDIRECT("network.http.max_open.set", "network.http.max_total_connections.set"); + CMD_REDIRECT("network.http.max_open", "network.http.max_total_connections"); + CMD_REDIRECT("network.http.max_open.set", "network.http.max_total_connections.set"); // Users should check their setups to see if they need to modify their use of these options. - CMD2_REDIRECT("max_memory_usage", "pieces.memory.max.set"); - CMD2_REDIRECT("encoding_list", "encoding.add"); + CMD_REDIRECT("max_memory_usage", "pieces.memory.max.set"); + CMD_REDIRECT("encoding_list", "encoding.add"); - CMD2_ANY_STRING_V("encoding.add", [](auto, auto) { + CMD_ANY_STRING_V("encoding.add", [](auto, auto) { lt_log_print(torrent::LOG_WARN, "The 'encoding.add' command is deprecated and does nothing."); }); - CMD2_ANY_LIST ("throttle.ip", []( auto, auto) { + CMD_ANY_LIST("throttle.ip", []( auto, auto) { lt_log_print(torrent::LOG_WARN, "The 'throttle.ip' command is deprecated and does nothing."); return torrent::Object(); });