merged encryption settings fix from RC_0_16

This commit is contained in:
Arvid Norberg 2013-05-08 05:43:17 +00:00
parent fd44cdbba5
commit 7745a2831d
2 changed files with 7 additions and 11 deletions

View File

@ -20,6 +20,7 @@
* fix uTP edge case where udp socket buffer fills up * fix uTP edge case where udp socket buffer fills up
* fix nagle implementation in uTP * fix nagle implementation in uTP
* fix encryption level handle invalid values
* add a number of missing functions to the python binding * add a number of missing functions to the python binding
* fix typo in Jamfile for building shared libraries * fix typo in Jamfile for building shared libraries
* prevent tracker exchange for magnet links before metadata is received * prevent tracker exchange for magnet links before metadata is received

View File

@ -474,20 +474,15 @@ namespace libtorrent
// write the verification constant and crypto field // write the verification constant and crypto field
int encrypt_size = sizeof(msg) - 512 + pad_size - 40; int encrypt_size = sizeof(msg) - 512 + pad_size - 40;
int crypto_provide = 0; pe_settings::enc_level crypto_provide = m_ses.get_pe_settings().allowed_enc_level;
pe_settings::enc_level const& allowed_enc_level = m_ses.get_pe_settings().allowed_enc_level;
if (allowed_enc_level == pe_settings::both) // this is an invalid setting, but let's just make the best of the situation
crypto_provide = 0x03; if ((crypto_provide & pe_settings::both) == 0) crypto_provide = pe_settings::both;
else if (allowed_enc_level == pe_settings::rc4)
crypto_provide = 0x02;
else if (allowed_enc_level == pe_settings::plaintext)
crypto_provide = 0x01;
#ifdef TORRENT_VERBOSE_LOGGING #ifdef TORRENT_VERBOSE_LOGGING
char const* level[] = {"plaintext", "rc4", "plaintext rc4"}; char const* level[] = {"plaintext", "rc4", "plaintext rc4"};
peer_log(" crypto provide : [ %s ]" peer_log(" crypto provide : [ %s ]"
, level[allowed_enc_level-1]); , level[crypto_provide-1]);
#endif #endif
write_pe_vc_cryptofield(ptr, encrypt_size, crypto_provide, pad_size); write_pe_vc_cryptofield(ptr, encrypt_size, crypto_provide, pad_size);