diff --git a/src/command_network.cc b/src/command_network.cc index 477d0087..e4a2b2da 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -192,47 +192,51 @@ initialize_command_network() { CMD2_VAR_STRING ("protocol.choke_heuristics.down.leech", "download_leech"); CMD2_VAR_STRING ("protocol.choke_heuristics.down.seed", "download_leech"); - CMD2_ANY ("network.http.cacert", [http_stack](auto, auto) { return http_stack->http_cacert(); }); - CMD2_ANY_STRING_V("network.http.cacert.set", [http_stack](auto, auto& str) { return http_stack->set_http_cacert(str); }); - CMD2_ANY ("network.http.capath", [http_stack](auto, auto) { return http_stack->http_capath(); }); - CMD2_ANY_STRING_V("network.http.capath.set", [http_stack](auto, auto& str) { return http_stack->set_http_capath(str); }); - CMD2_ANY ("network.http.dns_cache_timeout", [http_stack](auto, auto) { return http_stack->dns_timeout(); }); - CMD2_ANY_VALUE_V ("network.http.dns_cache_timeout.set", [http_stack](auto, auto& value) { return http_stack->set_dns_timeout(value); }); - CMD2_ANY ("network.http.current_open", [http_stack](auto, auto) { return http_stack->active(); }); - CMD2_ANY ("network.http.max_open", [http_stack](auto, auto) { return http_stack->max_active(); }); - CMD2_ANY_VALUE_V ("network.http.max_open.set", [http_stack](auto, auto& value) { return http_stack->set_max_active(value); }); - CMD2_ANY ("network.http.proxy_address", [http_stack](auto, auto) { return http_stack->http_proxy(); }); - CMD2_ANY_STRING_V("network.http.proxy_address.set", [http_stack](auto, auto& str) { return http_stack->set_http_proxy(str); }); - CMD2_ANY ("network.http.ssl_verify_host", [http_stack](auto, auto) { return http_stack->ssl_verify_host(); }); - CMD2_ANY_VALUE_V ("network.http.ssl_verify_host.set", [http_stack](auto, auto& value) { return http_stack->set_ssl_verify_host(value); }); - CMD2_ANY ("network.http.ssl_verify_peer", [http_stack](auto, auto) { return http_stack->ssl_verify_peer(); }); - CMD2_ANY_VALUE_V ("network.http.ssl_verify_peer.set", [http_stack](auto, auto& value) { return http_stack->set_ssl_verify_peer(value); }); + CMD2_ANY ("network.http.cacert", [http_stack](auto, auto) { return http_stack->http_cacert(); }); + CMD2_ANY_STRING_V("network.http.cacert.set", [http_stack](auto, auto& str) { return http_stack->set_http_cacert(str); }); + CMD2_ANY ("network.http.capath", [http_stack](auto, auto) { return http_stack->http_capath(); }); + CMD2_ANY_STRING_V("network.http.capath.set", [http_stack](auto, auto& str) { return http_stack->set_http_capath(str); }); + CMD2_ANY ("network.http.dns_cache_timeout", [http_stack](auto, auto) { return http_stack->dns_timeout(); }); + CMD2_ANY_VALUE_V ("network.http.dns_cache_timeout.set", [http_stack](auto, auto& value) { return http_stack->set_dns_timeout(value); }); + CMD2_ANY ("network.http.current_open", [http_stack](auto, auto) { return http_stack->size(); }); + CMD2_ANY ("network.http.max_cache_connections", [http_stack](auto, auto) { return http_stack->max_cache_connections(); }); + CMD2_ANY_VALUE_V ("network.http.max_cache_connections.set", [http_stack](auto, auto& value) { return http_stack->set_max_cache_connections(value); }); + CMD2_ANY ("network.http.max_host_connections", [http_stack](auto, auto) { return http_stack->max_host_connections(); }); + CMD2_ANY_VALUE_V ("network.http.max_host_connections.set", [http_stack](auto, auto& value) { return http_stack->set_max_host_connections(value); }); + CMD2_ANY ("network.http.max_total_connections", [http_stack](auto, auto) { return http_stack->max_total_connections(); }); + CMD2_ANY_VALUE_V ("network.http.max_total_connections.set", [http_stack](auto, auto& value) { return http_stack->set_max_total_connections(value); }); + CMD2_ANY ("network.http.proxy_address", [http_stack](auto, auto) { return http_stack->http_proxy(); }); + CMD2_ANY_STRING_V("network.http.proxy_address.set", [http_stack](auto, auto& str) { return http_stack->set_http_proxy(str); }); + CMD2_ANY ("network.http.ssl_verify_host", [http_stack](auto, auto) { return http_stack->ssl_verify_host(); }); + CMD2_ANY_VALUE_V ("network.http.ssl_verify_host.set", [http_stack](auto, auto& value) { return http_stack->set_ssl_verify_host(value); }); + CMD2_ANY ("network.http.ssl_verify_peer", [http_stack](auto, auto) { return http_stack->ssl_verify_peer(); }); + CMD2_ANY_VALUE_V ("network.http.ssl_verify_peer.set", [http_stack](auto, auto& value) { return http_stack->set_ssl_verify_peer(value); }); - CMD2_ANY ("network.send_buffer.size", std::bind(&torrent::net::NetworkConfig::send_buffer_size, network_config)); - CMD2_ANY_VALUE_V ("network.send_buffer.size.set", std::bind(&torrent::net::NetworkConfig::set_send_buffer_size, network_config, std::placeholders::_2)); - CMD2_ANY ("network.receive_buffer.size", std::bind(&torrent::net::NetworkConfig::receive_buffer_size, network_config)); - CMD2_ANY_VALUE_V ("network.receive_buffer.size.set", std::bind(&torrent::net::NetworkConfig::set_receive_buffer_size, network_config, std::placeholders::_2)); - CMD2_ANY_STRING ("network.tos.set", std::bind(&apply_tos, std::placeholders::_2)); + CMD2_ANY ("network.send_buffer.size", [network_config](auto, auto) { return network_config->send_buffer_size(); }); + CMD2_ANY_VALUE_V ("network.send_buffer.size.set", [network_config](auto, auto& value) { return network_config->set_send_buffer_size(value); }); + CMD2_ANY ("network.receive_buffer.size", [network_config](auto, auto) { return network_config->receive_buffer_size(); }); + CMD2_ANY_VALUE_V ("network.receive_buffer.size.set", [network_config](auto, auto& value) { return network_config->set_receive_buffer_size(value); }); + CMD2_ANY_STRING ("network.tos.set", [](auto, auto& str) { return apply_tos(str); }); - CMD2_ANY ("network.bind_address", std::bind(&torrent::net::NetworkConfig::bind_address_best_match_str, network_config)); - CMD2_ANY_STRING_V("network.bind_address.set", std::bind(&core::Manager::set_bind_address, control->core(), std::placeholders::_2)); - CMD2_ANY ("network.bind_address.ipv4", std::bind(&torrent::net::NetworkConfig::bind_inet_address_str, network_config)); - CMD2_ANY_STRING_V("network.bind_address.ipv4.set", std::bind(&core::Manager::set_bind_inet_address, control->core(), std::placeholders::_2)); - CMD2_ANY ("network.bind_address.ipv6", std::bind(&torrent::net::NetworkConfig::bind_inet6_address_str, network_config)); - CMD2_ANY_STRING_V("network.bind_address.ipv6.set", std::bind(&core::Manager::set_bind_inet6_address, control->core(), std::placeholders::_2)); + CMD2_ANY ("network.bind_address", [network_config](auto, auto) { return network_config->bind_address_best_match_str(); }); + CMD2_ANY_STRING_V("network.bind_address.set", [](auto, auto& str) { return control->core()->set_bind_address(str); }); + CMD2_ANY ("network.bind_address.ipv4", [network_config](auto, auto) { return network_config->bind_inet_address_str(); }); + CMD2_ANY_STRING_V("network.bind_address.ipv4.set", [](auto, auto& str) { return control->core()->set_bind_inet_address(str); }); + CMD2_ANY ("network.bind_address.ipv6", [network_config](auto, auto) { return network_config->bind_inet6_address_str(); }); + CMD2_ANY_STRING_V("network.bind_address.ipv6.set", [](auto, auto& str) { return control->core()->set_bind_inet6_address(str); }); - CMD2_ANY ("network.local_address", std::bind(&torrent::net::NetworkConfig::local_address_str, network_config)); - CMD2_ANY_STRING_V("network.local_address.set", std::bind(&core::Manager::set_local_address, control->core(), std::placeholders::_2)); - CMD2_ANY ("network.proxy_address", std::bind(&torrent::net::NetworkConfig::proxy_address_str, network_config)); - CMD2_ANY_STRING_V("network.proxy_address.set", std::bind(&core::Manager::set_proxy_address, control->core(), std::placeholders::_2)); + CMD2_ANY ("network.local_address", [network_config](auto, auto) { return network_config->local_address_str(); }); + CMD2_ANY_STRING_V("network.local_address.set", [](auto, auto& str) { return control->core()->set_local_address(str); }); + CMD2_ANY ("network.proxy_address", [network_config](auto, auto) { return network_config->proxy_address_str(); }); + CMD2_ANY_STRING_V("network.proxy_address.set", [](auto, auto& str) { return control->core()->set_proxy_address(str); }); - CMD2_ANY ("network.open_files", std::bind(&torrent::FileManager::open_files, file_manager)); - CMD2_ANY ("network.max_open_files", std::bind(&torrent::FileManager::max_open_files, file_manager)); - CMD2_ANY_VALUE_V ("network.max_open_files.set", std::bind(&torrent::FileManager::set_max_open_files, file_manager, std::placeholders::_2)); - CMD2_ANY ("network.total_handshakes", std::bind(&torrent::total_handshakes)); - CMD2_ANY ("network.open_sockets", std::bind(&torrent::ConnectionManager::size, cm)); - CMD2_ANY ("network.max_open_sockets", std::bind(&torrent::ConnectionManager::max_size, cm)); - CMD2_ANY_VALUE_V ("network.max_open_sockets.set", std::bind(&torrent::ConnectionManager::set_max_size, cm, std::placeholders::_2)); + CMD2_ANY ("network.open_files", [file_manager](auto, auto) { return file_manager->open_files(); }); + 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::total_handshakes(); }); + CMD2_ANY ("network.open_sockets", [cm](auto, auto) { return cm->size(); }); + CMD2_ANY ("network.max_open_sockets", [cm](auto, auto) { return cm->max_size(); }); + CMD2_ANY_VALUE_V ("network.max_open_sockets.set", [cm](auto, auto& value) { return cm->set_max_size(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)); @@ -245,14 +249,14 @@ initialize_command_network() { CMD2_VAR_BOOL ("network.rpc.use_xmlrpc", true); CMD2_VAR_BOOL ("network.rpc.use_jsonrpc", true); - CMD2_ANY ("network.block.ipv4", std::bind(&torrent::net::NetworkConfig::is_block_ipv4, network_config)); - CMD2_ANY_VALUE_V ("network.block.ipv4.set", std::bind(&torrent::net::NetworkConfig::set_block_ipv4, network_config, std::placeholders::_2)); - CMD2_ANY ("network.block.ipv6", std::bind(&torrent::net::NetworkConfig::is_block_ipv6, network_config)); - CMD2_ANY_VALUE_V ("network.block.ipv6.set", std::bind(&torrent::net::NetworkConfig::set_block_ipv6, network_config, std::placeholders::_2)); - CMD2_ANY ("network.block.ipv4in6", std::bind(&torrent::net::NetworkConfig::is_block_ipv4in6, network_config)); - CMD2_ANY_VALUE_V ("network.block.ipv4in6.set", std::bind(&torrent::net::NetworkConfig::set_block_ipv4in6, network_config, std::placeholders::_2)); - CMD2_ANY ("network.block.outgoing", std::bind(&torrent::net::NetworkConfig::is_block_outgoing, network_config)); - CMD2_ANY_VALUE_V ("network.block.outgoing.set", std::bind(&torrent::net::NetworkConfig::set_block_outgoing, network_config, std::placeholders::_2)); - CMD2_ANY ("network.prefer.ipv6", std::bind(&torrent::net::NetworkConfig::is_prefer_ipv6, network_config)); - CMD2_ANY_VALUE_V ("network.prefer.ipv6.set", std::bind(&torrent::net::NetworkConfig::set_prefer_ipv6, network_config, std::placeholders::_2)); + CMD2_ANY ("network.block.ipv4", [network_config](auto, auto) { return network_config->is_block_ipv4(); }); + CMD2_ANY_VALUE_V ("network.block.ipv4.set", [network_config](auto, auto& value) { return network_config->set_block_ipv4(value); }); + CMD2_ANY ("network.block.ipv6", [network_config](auto, auto) { return network_config->is_block_ipv6(); }); + CMD2_ANY_VALUE_V ("network.block.ipv6.set", [network_config](auto, auto& value) { return network_config->set_block_ipv6(value); }); + CMD2_ANY ("network.block.ipv4in6", [network_config](auto, auto) { return network_config->is_block_ipv4in6(); }); + CMD2_ANY_VALUE_V ("network.block.ipv4in6.set", [network_config](auto, auto& value) { return network_config->set_block_ipv4in6(value); }); + CMD2_ANY ("network.block.outgoing", [network_config](auto, auto) { return network_config->is_block_outgoing(); }); + CMD2_ANY_VALUE_V ("network.block.outgoing.set", [network_config](auto, auto& value) { return network_config->set_block_outgoing(value); }); + CMD2_ANY ("network.prefer.ipv6", [network_config](auto, auto) { return network_config->is_prefer_ipv6(); }); + CMD2_ANY_VALUE_V ("network.prefer.ipv6.set", [network_config](auto, auto& value) { return network_config->set_prefer_ipv6(value); }); } diff --git a/src/control.cc b/src/control.cc index 3547f4b2..f6fd97b9 100644 --- a/src/control.cc +++ b/src/control.cc @@ -112,7 +112,7 @@ Control::is_shutdown_completed() { // TODO: We keep http requests in the queue for a while after, so improve this check to ignore // those. - if (torrent::net_thread::http_stack()->active() != 0 || !core()->http_queue()->empty()) + if (torrent::net_thread::http_stack()->size() != 0 || !core()->http_queue()->empty()) return false; return torrent::is_inactive(); diff --git a/src/display/utils.cc b/src/display/utils.cc index 384c3e36..ecb5eab9 100644 --- a/src/display/utils.cc +++ b/src/display/utils.cc @@ -410,8 +410,8 @@ print_status_extra(char* first, char* last) { torrent::resource_manager()->max_download_unchoked()); first = print_buffer(first, last, " [H %u/%u]", - torrent::net_thread::http_stack()->active(), - torrent::net_thread::http_stack()->max_active()); + torrent::net_thread::http_stack()->size(), + torrent::net_thread::http_stack()->max_total_connections()); first = print_buffer(first, last, " [S %i/%i/%i]", torrent::total_handshakes(), diff --git a/src/main.cc b/src/main.cc index cbf011ac..a64a9b0d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -418,6 +418,11 @@ main(int argc, char** argv) { CMD2_REDIRECT("torrent_list_layout", "ui.torrent_list.layout.set"); + // Deprecate: + + CMD2_REDIRECT("network.http.max_open", "network.http.max_total_connections"); + CMD2_REDIRECT("network.http.max_open.set", "network.http.max_total_connections.set"); + // Deprecated commands. Don't use these anymore. // // It has been so long that we now re-create these commands with the new (old by now) command