diff --git a/doc/rtorrent.1.xml b/doc/rtorrent.1.xml index 5fcb5aca..9d190f5f 100644 --- a/doc/rtorrent.1.xml +++ b/doc/rtorrent.1.xml @@ -483,6 +483,13 @@ between plaintext transmission and RC4 encryption, otherwise RC4 will be used). + + peer_exchange = yes | no + +Enable/disable peer exchange for torrents that aren't marked private. Disabled by default. + + + schedule = id,start,interval,command diff --git a/doc/rtorrent.rc b/doc/rtorrent.rc index e4271dc6..fd816715 100644 --- a/doc/rtorrent.rc +++ b/doc/rtorrent.rc @@ -74,6 +74,10 @@ # # encryption = allow_incoming,enable_retry,prefer_plaintext +# Enable peer exchange (for torrents not marked private) +# +# peer_exchange = yes + # # Do not modify the following parameters unless you know what you're doing. # diff --git a/src/command_download.cc b/src/command_download.cc index 1bf4c6f2..cdabc766 100644 --- a/src/command_download.cc +++ b/src/command_download.cc @@ -447,6 +447,9 @@ initialize_command_download() { ADD_CD_VALUE_UNI("peers_complete", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::peers_complete))); ADD_CD_VALUE_UNI("peers_accounted", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::peers_accounted))); + ADD_CD_VALUE_MEM_BI("peer_exchange", &core::Download::download, &torrent::Download::set_pex_enabled, &torrent::Download::pex_enabled); + ADD_CD_VALUE_UNI("private", rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::is_private))); + ADD_CD_VALUE_MEM_UNI("up_rate", &torrent::Download::mutable_up_rate, &torrent::Rate::rate); ADD_CD_VALUE_MEM_UNI("up_total", &torrent::Download::mutable_up_rate, &torrent::Rate::total); ADD_CD_VALUE_MEM_UNI("down_rate", &torrent::Download::mutable_down_rate, &torrent::Rate::rate); diff --git a/src/command_helpers.h b/src/command_helpers.h index 9ae16435..e5aa97e0 100644 --- a/src/command_helpers.h +++ b/src/command_helpers.h @@ -53,7 +53,7 @@ namespace rpc { // heap. This should reduce memory use and improve cache locality. #define COMMAND_SLOTS_SIZE 150 #define COMMAND_VARIABLES_SIZE 100 -#define COMMAND_DOWNLOAD_SLOTS_SIZE 100 +#define COMMAND_DOWNLOAD_SLOTS_SIZE 150 #define COMMAND_FILE_SLOTS_SIZE 20 #define COMMAND_FILE_ITR_SLOTS_SIZE 10 #define COMMAND_PEER_SLOTS_SIZE 20 diff --git a/src/command_network.cc b/src/command_network.cc index 988224d3..c129ccc3 100644 --- a/src/command_network.cc +++ b/src/command_network.cc @@ -320,6 +320,8 @@ initialize_command_network() { ADD_COMMAND_VALUE_UN("enable_trackers", std::ptr_fun(&apply_enable_trackers)); ADD_COMMAND_STRING_UN("encoding_list", std::ptr_fun(&apply_encoding_list)); + ADD_VARIABLE_BOOL("peer_exchange", false); + // Not really network stuff: ADD_VARIABLE_BOOL("handshake_log", false); ADD_VARIABLE_STRING("tracker_dump", ""); diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc index d6522907..9b102182 100644 --- a/src/core/download_factory.cc +++ b/src/core/download_factory.cc @@ -230,6 +230,8 @@ DownloadFactory::receive_success() { if (!m_session && m_variables["tied_to_file"].as_value()) rpc::call_command("d.set_tied_to_file", m_uri, rpc::make_target(download)); + rpc::call_command("d.set_peer_exchange", rpc::call_command_value("get_peer_exchange"), rpc::make_target(download)); + torrent::Object& resumeObject = root->has_key_map("libtorrent_resume") ? root->get_key("libtorrent_resume") : root->insert_key("libtorrent_resume", torrent::Object(torrent::Object::TYPE_MAP)); diff --git a/src/ui/download.cc b/src/ui/download.cc index 05fbdbdc..8a665197 100644 --- a/src/ui/download.cc +++ b/src/ui/download.cc @@ -162,6 +162,7 @@ Download::create_info() { element->push_back(""); element->push_column("Chunks:", te_variable_value("d.get_completed_chunks"), " / ", te_variable_value("d.get_size_chunks"), " * ", te_variable_value("d.get_chunk_size")); element->push_column("Priority:", te_variable_value("d.get_priority")); + element->push_column("Peer exchange:", display::text_element_branch(std::mem_fun(&torrent::Download::pex_enabled), te_string("enabled"), te_string("disabled"))); element->push_column("State changed:", te_variable_value("d.get_state_changed", value_base::flag_timer | value_base::flag_elapsed));