mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-05 17:52:29 +00:00
Moved various socket options to NetworkConfig.
This commit is contained in:
+17
-18
@@ -30,18 +30,18 @@
|
||||
|
||||
torrent::Object
|
||||
apply_encryption(const torrent::Object::list_type& args) {
|
||||
uint32_t options_mask = torrent::ConnectionManager::encryption_none;
|
||||
uint32_t options_mask = torrent::net::NetworkConfig::encryption_none;
|
||||
|
||||
for (const auto& arg : args) {
|
||||
uint32_t opt = torrent::option_find_string(torrent::OPTION_ENCRYPTION, arg.as_string().c_str());
|
||||
|
||||
if (opt == torrent::ConnectionManager::encryption_none)
|
||||
options_mask = torrent::ConnectionManager::encryption_none;
|
||||
if (opt == torrent::net::NetworkConfig::encryption_none)
|
||||
options_mask = torrent::net::NetworkConfig::encryption_none;
|
||||
else
|
||||
options_mask |= opt;
|
||||
}
|
||||
|
||||
torrent::connection_manager()->set_encryption_options(options_mask);
|
||||
torrent::config::network_config()->set_encryption_options(options_mask);
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
@@ -53,7 +53,7 @@ apply_tos(const torrent::Object::string_type& arg) {
|
||||
if (!rpc::parse_whole_value_nothrow(arg.c_str(), &value, 16, 1))
|
||||
value = torrent::option_find_string(torrent::OPTION_IP_TOS, arg.c_str());
|
||||
|
||||
torrent::connection_manager()->set_priority(value);
|
||||
torrent::config::network_config()->set_priority(value);
|
||||
|
||||
return torrent::Object();
|
||||
}
|
||||
@@ -208,10 +208,10 @@ initialize_command_network() {
|
||||
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::ConnectionManager::send_buffer_size, cm));
|
||||
CMD2_ANY_VALUE_V ("network.send_buffer.size.set", std::bind(&torrent::ConnectionManager::set_send_buffer_size, cm, std::placeholders::_2));
|
||||
CMD2_ANY ("network.receive_buffer.size", std::bind(&torrent::ConnectionManager::receive_buffer_size, cm));
|
||||
CMD2_ANY_VALUE_V ("network.receive_buffer.size.set", std::bind(&torrent::ConnectionManager::set_receive_buffer_size, cm, std::placeholders::_2));
|
||||
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.bind_address", std::bind(&torrent::net::NetworkConfig::bind_address_str, network_config));
|
||||
@@ -240,13 +240,12 @@ 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::ConnectionManager::is_block_ipv4, cm));
|
||||
CMD2_ANY_VALUE_V ("network.block.ipv4.set", std::bind(&torrent::ConnectionManager::set_block_ipv4, cm, std::placeholders::_2));
|
||||
CMD2_ANY ("network.block.ipv6", std::bind(&torrent::ConnectionManager::is_block_ipv6, cm));
|
||||
CMD2_ANY_VALUE_V ("network.block.ipv6.set", std::bind(&torrent::ConnectionManager::set_block_ipv6, cm, std::placeholders::_2));
|
||||
CMD2_ANY ("network.block.ipv4in6", std::bind(&torrent::ConnectionManager::is_block_ipv4in6, cm));
|
||||
CMD2_ANY_VALUE_V ("network.block.ipv4in6.set", std::bind(&torrent::ConnectionManager::set_block_ipv4in6, cm, std::placeholders::_2));
|
||||
|
||||
CMD2_ANY ("network.prefer.ipv6", std::bind(&torrent::ConnectionManager::is_prefer_ipv6, cm));
|
||||
CMD2_ANY_VALUE_V ("network.prefer.ipv6.set", std::bind(&torrent::ConnectionManager::set_prefer_ipv6, cm, std::placeholders::_2));
|
||||
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.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));
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
#include "test/rpc/test_parse_options.h"
|
||||
|
||||
#include <array>
|
||||
#include <torrent/connection_manager.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/net/network_config.h>
|
||||
#include <torrent/utils/log.h>
|
||||
#include <torrent/utils/option_strings.h>
|
||||
|
||||
@@ -178,11 +178,11 @@ TestParseOptions::test_flag_libtorrent() {
|
||||
|
||||
void
|
||||
TestParseOptions::test_flags_libtorrent() {
|
||||
FLAGS_LT_ENCRYPTION_ASSERT("", torrent::ConnectionManager::encryption_none);
|
||||
FLAGS_LT_ENCRYPTION_ASSERT("none", torrent::ConnectionManager::encryption_none);
|
||||
FLAGS_LT_ENCRYPTION_ASSERT("require_rc4", torrent::ConnectionManager::encryption_require_RC4);
|
||||
FLAGS_LT_ENCRYPTION_ASSERT("require_RC4", torrent::ConnectionManager::encryption_require_RC4);
|
||||
FLAGS_LT_ENCRYPTION_ASSERT("require_RC4 | enable_retry", torrent::ConnectionManager::encryption_require_RC4 | torrent::ConnectionManager::encryption_enable_retry);
|
||||
FLAGS_LT_ENCRYPTION_ASSERT("", torrent::net::NetworkConfig::encryption_none);
|
||||
FLAGS_LT_ENCRYPTION_ASSERT("none", torrent::net::NetworkConfig::encryption_none);
|
||||
FLAGS_LT_ENCRYPTION_ASSERT("require_rc4", torrent::net::NetworkConfig::encryption_require_RC4);
|
||||
FLAGS_LT_ENCRYPTION_ASSERT("require_RC4", torrent::net::NetworkConfig::encryption_require_RC4);
|
||||
FLAGS_LT_ENCRYPTION_ASSERT("require_RC4 | enable_retry", torrent::net::NetworkConfig::encryption_require_RC4 | torrent::net::NetworkConfig::encryption_enable_retry);
|
||||
|
||||
FLAGS_LT_ENCRYPTION_ASSERT_ERROR("require_");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user