* Encrypted (obfuscated) handshake and connection support. Patch by

Josef Drexler, public domain as per earlier agreement.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@790 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-10-14 16:46:43 +00:00
parent eb7c0b5874
commit 1736c8eaf7
9 changed files with 203 additions and 1 deletions
+33
View File
@@ -228,6 +228,36 @@ apply_encoding_list(__UNUSED Control* m, const std::string& arg) {
torrent::encoding_list()->push_back(arg);
}
void
apply_encryption_options(const std::string& arg) {
rak::split_iterator_t<std::string> sitr = rak::split_iterator(arg, ',');
uint32_t options_mask = torrent::ConnectionManager::encryption_none;
while (sitr != rak::split_iterator(arg)) {
std::string opt = rak::trim(*sitr);
++sitr;
if (opt == "none")
options_mask = torrent::ConnectionManager::encryption_none;
else if (opt == "allow_incoming")
options_mask |= torrent::ConnectionManager::encryption_allow_incoming;
else if (opt == "try_outgoing")
options_mask |= torrent::ConnectionManager::encryption_try_outgoing;
else if (opt == "require")
options_mask |= torrent::ConnectionManager::encryption_require;
else if (opt == "require_RC4")
options_mask |= torrent::ConnectionManager::encryption_require_RC4;
else if (opt == "enable_retry")
options_mask |= torrent::ConnectionManager::encryption_enable_retry;
else if (opt == "prefer_plaintext")
options_mask |= torrent::ConnectionManager::encryption_prefer_plaintext;
else
throw torrent::input_error("Invalid encryption option '" + opt + "'.");
}
torrent::connection_manager()->set_encryption_options(options_mask);
}
void
apply_enable_trackers(Control* m, __UNUSED const std::string& arg) {
bool state = (arg != "no");
@@ -503,4 +533,7 @@ initialize_option_handler(Control* c) {
variables->insert("enable_trackers", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_enable_trackers, c)));
variables->insert("encoding_list", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::bind_ptr_fn(&apply_encoding_list, c)));
variables->insert("encryption_options", new utils::VariableStringSlot(rak::value_fn(std::string()), rak::ptr_fn(&apply_encryption_options)));
variables->insert("handshake_log", new utils::VariableBool(false));
}