narrow the scope affected by TORRENT_DISABLE_EXTENSIONS to only disable the user extensions, but always support the extension message and the built-in extensions, like lt_donthave and seed_mode
This commit is contained in:
parent
8f0cf7e1a9
commit
b3856d3027
|
@ -444,7 +444,7 @@ namespace aux {
|
||||||
, std::vector<address> const& addresses, int port);
|
, std::vector<address> const& addresses, int port);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
torrent const* find_encrypted_torrent(
|
torrent const* find_encrypted_torrent(
|
||||||
sha1_hash const& info_hash, sha1_hash const& xor_mask) override;
|
sha1_hash const& info_hash, sha1_hash const& xor_mask) override;
|
||||||
|
|
||||||
|
@ -876,7 +876,7 @@ namespace aux {
|
||||||
// ordered by their queue position
|
// ordered by their queue position
|
||||||
aux::vector<torrent*, queue_position_t> m_download_queue;
|
aux::vector<torrent*, queue_position_t> m_download_queue;
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
// this maps obfuscated hashes to torrents. It's only
|
// this maps obfuscated hashes to torrents. It's only
|
||||||
// used when encryption is enabled
|
// used when encryption is enabled
|
||||||
torrent_map m_obfuscated_torrents;
|
torrent_map m_obfuscated_torrents;
|
||||||
|
|
|
@ -294,7 +294,7 @@ namespace aux {
|
||||||
virtual boost::asio::ssl::context* ssl_ctx() = 0 ;
|
virtual boost::asio::ssl::context* ssl_ctx() = 0 ;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
virtual torrent const* find_encrypted_torrent(
|
virtual torrent const* find_encrypted_torrent(
|
||||||
sha1_hash const& info_hash, sha1_hash const& xor_mask) = 0;
|
sha1_hash const& info_hash, sha1_hash const& xor_mask) = 0;
|
||||||
virtual void add_obfuscated_hash(sha1_hash const& obfuscated
|
virtual void add_obfuscated_hash(sha1_hash const& obfuscated
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace libtorrent {
|
||||||
|
|
||||||
~bt_peer_connection() override;
|
~bt_peer_connection() override;
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
bool supports_encryption() const
|
bool supports_encryption() const
|
||||||
{ return m_encrypted; }
|
{ return m_encrypted; }
|
||||||
bool rc4_encrypted() const
|
bool rc4_encrypted() const
|
||||||
|
@ -171,7 +171,7 @@ namespace libtorrent {
|
||||||
, std::size_t bytes_transferred) override;
|
, std::size_t bytes_transferred) override;
|
||||||
void on_receive_impl(std::size_t bytes_transferred);
|
void on_receive_impl(std::size_t bytes_transferred);
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
// next_barrier, buffers-to-prepend
|
// next_barrier, buffers-to-prepend
|
||||||
std::tuple<int, span<span<char const>>>
|
std::tuple<int, span<span<char const>>>
|
||||||
hit_send_barrier(span<span<char>> iovec) override;
|
hit_send_barrier(span<span<char>> iovec) override;
|
||||||
|
@ -181,8 +181,8 @@ namespace libtorrent {
|
||||||
bool in_handshake() const override;
|
bool in_handshake() const override;
|
||||||
bool packet_finished() const { return m_recv_buffer.packet_finished(); }
|
bool packet_finished() const { return m_recv_buffer.packet_finished(); }
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
bool supports_holepunch() const { return m_holepunch_id != 0; }
|
bool supports_holepunch() const { return m_holepunch_id != 0; }
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
void set_ut_pex(std::weak_ptr<ut_pex_peer_store> ut_pex)
|
void set_ut_pex(std::weak_ptr<ut_pex_peer_store> ut_pex)
|
||||||
{ m_ut_pex = std::move(ut_pex); }
|
{ m_ut_pex = std::move(ut_pex); }
|
||||||
bool was_introduced_by(tcp::endpoint const& ep) const
|
bool was_introduced_by(tcp::endpoint const& ep) const
|
||||||
|
@ -218,13 +218,11 @@ namespace libtorrent {
|
||||||
void on_have_none(int received);
|
void on_have_none(int received);
|
||||||
void on_reject_request(int received);
|
void on_reject_request(int received);
|
||||||
void on_allowed_fast(int received);
|
void on_allowed_fast(int received);
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
void on_holepunch();
|
void on_holepunch();
|
||||||
|
|
||||||
void on_extended(int received);
|
void on_extended(int received);
|
||||||
|
|
||||||
void on_extended_handshake();
|
void on_extended_handshake();
|
||||||
#endif
|
|
||||||
|
|
||||||
// the following functions appends messages
|
// the following functions appends messages
|
||||||
// to the send buffer
|
// to the send buffer
|
||||||
|
@ -241,11 +239,10 @@ namespace libtorrent {
|
||||||
void write_keepalive() override;
|
void write_keepalive() override;
|
||||||
void write_handshake();
|
void write_handshake();
|
||||||
void write_upload_only(bool enabled) override;
|
void write_upload_only(bool enabled) override;
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
void write_extensions();
|
void write_extensions();
|
||||||
void write_share_mode();
|
void write_share_mode();
|
||||||
void write_holepunch_msg(int type, tcp::endpoint const& ep, int error);
|
void write_holepunch_msg(int type, tcp::endpoint const& ep, int error);
|
||||||
#endif
|
|
||||||
// DHT extension
|
// DHT extension
|
||||||
void write_dht_port(int listen_port);
|
void write_dht_port(int listen_port);
|
||||||
|
|
||||||
|
@ -298,7 +295,7 @@ namespace libtorrent {
|
||||||
// will be invalid.
|
// will be invalid.
|
||||||
piece_block_progress downloading_piece_progress() const override;
|
piece_block_progress downloading_piece_progress() const override;
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
|
|
||||||
// if (is_local()), we are 'a' otherwise 'b'
|
// if (is_local()), we are 'a' otherwise 'b'
|
||||||
//
|
//
|
||||||
|
@ -327,7 +324,7 @@ namespace libtorrent {
|
||||||
template <typename Holder>
|
template <typename Holder>
|
||||||
void append_const_send_buffer(Holder holder, int size)
|
void append_const_send_buffer(Holder holder, int size)
|
||||||
{
|
{
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
if (!m_enc_handler.is_send_plaintext())
|
if (!m_enc_handler.is_send_plaintext())
|
||||||
{
|
{
|
||||||
// if we're encrypting this buffer, we need to make a copy
|
// if we're encrypting this buffer, we need to make a copy
|
||||||
|
@ -346,8 +343,8 @@ namespace libtorrent {
|
||||||
|
|
||||||
enum class state_t : std::uint8_t
|
enum class state_t : std::uint8_t
|
||||||
{
|
{
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
read_pe_dhkey = 0,
|
read_pe_dhkey,
|
||||||
read_pe_syncvc,
|
read_pe_syncvc,
|
||||||
read_pe_synchash,
|
read_pe_synchash,
|
||||||
read_pe_skey_vc,
|
read_pe_skey_vc,
|
||||||
|
@ -355,10 +352,8 @@ namespace libtorrent {
|
||||||
read_pe_pad,
|
read_pe_pad,
|
||||||
read_pe_ia,
|
read_pe_ia,
|
||||||
init_bt_handshake,
|
init_bt_handshake,
|
||||||
read_protocol_identifier,
|
|
||||||
#else
|
|
||||||
read_protocol_identifier = 0,
|
|
||||||
#endif
|
#endif
|
||||||
|
read_protocol_identifier,
|
||||||
read_info_hash,
|
read_info_hash,
|
||||||
read_peer_id,
|
read_peer_id,
|
||||||
|
|
||||||
|
@ -391,7 +386,7 @@ namespace libtorrent {
|
||||||
// only done once per connection
|
// only done once per connection
|
||||||
bool m_sent_allowed_fast:1;
|
bool m_sent_allowed_fast:1;
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
// this is set to true after the encryption method has been
|
// this is set to true after the encryption method has been
|
||||||
// successfully negotiated (either plaintext or rc4), to signal
|
// successfully negotiated (either plaintext or rc4), to signal
|
||||||
// automatic encryption/decryption.
|
// automatic encryption/decryption.
|
||||||
|
@ -441,7 +436,7 @@ namespace libtorrent {
|
||||||
|
|
||||||
std::vector<range> m_payloads;
|
std::vector<range> m_payloads;
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
// initialized during write_pe1_2_dhkey, and destroyed on
|
// initialized during write_pe1_2_dhkey, and destroyed on
|
||||||
// creation of m_enc_handler. Cannot reinitialize once
|
// creation of m_enc_handler. Cannot reinitialize once
|
||||||
// initialized.
|
// initialized.
|
||||||
|
@ -465,15 +460,12 @@ namespace libtorrent {
|
||||||
// the sync hash (hash("req1",secret)). Destroyed after the
|
// the sync hash (hash("req1",secret)). Destroyed after the
|
||||||
// sync step.
|
// sync step.
|
||||||
std::unique_ptr<sha1_hash> m_sync_hash;
|
std::unique_ptr<sha1_hash> m_sync_hash;
|
||||||
#endif // #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
|
||||||
// used to disconnect peer if sync points are not found within
|
// used to disconnect peer if sync points are not found within
|
||||||
// the maximum number of bytes
|
// the maximum number of bytes
|
||||||
int m_sync_bytes_read = 0;
|
int m_sync_bytes_read = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
// the message ID for upload only message
|
// the message ID for upload only message
|
||||||
// 0 if not supported
|
// 0 if not supported
|
||||||
std::uint8_t m_upload_only_id = 0;
|
std::uint8_t m_upload_only_id = 0;
|
||||||
|
@ -488,10 +480,11 @@ namespace libtorrent {
|
||||||
// 0 if not supported
|
// 0 if not supported
|
||||||
std::uint8_t m_share_mode_id = 0;
|
std::uint8_t m_share_mode_id = 0;
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
std::weak_ptr<ut_pex_peer_store> m_ut_pex;
|
std::weak_ptr<ut_pex_peer_store> m_ut_pex;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::array<char, 8> m_reserved_bits;
|
std::array<char, 8> m_reserved_bits;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,9 +160,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
// .. _`alert section`: reference-Alerts.html
|
// .. _`alert section`: reference-Alerts.html
|
||||||
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
|
@ -175,6 +172,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
||||||
// these are flags that can be returned by implemented_features()
|
// these are flags that can be returned by implemented_features()
|
||||||
// indicating which callbacks this plugin is interested in
|
// indicating which callbacks this plugin is interested in
|
||||||
using feature_flags_t = flags::bitfield_flag<std::uint8_t, struct feature_flags_tag>;
|
using feature_flags_t = flags::bitfield_flag<std::uint8_t, struct feature_flags_tag>;
|
||||||
|
@ -469,6 +468,9 @@ namespace libtorrent {
|
||||||
// no other plugin will have this function called.
|
// no other plugin will have this function called.
|
||||||
virtual bool write_request(peer_request const&) { return false; }
|
virtual bool write_request(peer_request const&) { return false; }
|
||||||
};
|
};
|
||||||
|
#endif // TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
||||||
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
|
|
||||||
struct TORRENT_EXPORT crypto_plugin
|
struct TORRENT_EXPORT crypto_plugin
|
||||||
{
|
{
|
||||||
|
@ -504,8 +506,8 @@ namespace libtorrent {
|
||||||
// advance the next step of decryption. default is 0
|
// advance the next step of decryption. default is 0
|
||||||
virtual std::tuple<int, int, int> decrypt(span<span<char>> /*receive_vec*/) = 0;
|
virtual std::tuple<int, int, int> decrypt(span<span<char>> /*receive_vec*/) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // TORRENT_DISABLE_ENCRYPTION
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // TORRENT_EXTENSIONS_HPP_INCLUDED
|
#endif // TORRENT_EXTENSIONS_HPP_INCLUDED
|
||||||
|
|
|
@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
|
|
||||||
#ifndef TORRENT_PE_CRYPTO_HPP_INCLUDED
|
#ifndef TORRENT_PE_CRYPTO_HPP_INCLUDED
|
||||||
#define TORRENT_PE_CRYPTO_HPP_INCLUDED
|
#define TORRENT_PE_CRYPTO_HPP_INCLUDED
|
||||||
|
|
|
@ -88,7 +88,7 @@ struct TORRENT_EXTRA_EXPORT receive_buffer
|
||||||
// This is the "current" packet.
|
// This is the "current" packet.
|
||||||
span<char const> get() const;
|
span<char const> get() const;
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
// returns the buffer from the current packet start position to the last
|
// returns the buffer from the current packet start position to the last
|
||||||
// received byte (possibly part of another packet)
|
// received byte (possibly part of another packet)
|
||||||
span<char> mutable_buffer();
|
span<char> mutable_buffer();
|
||||||
|
@ -159,7 +159,7 @@ private:
|
||||||
buffer m_recv_buffer;
|
buffer m_recv_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
// Wraps a receive_buffer to provide the ability to inject
|
// Wraps a receive_buffer to provide the ability to inject
|
||||||
// possibly authenticated crypto beneath the bittorrent protocol.
|
// possibly authenticated crypto beneath the bittorrent protocol.
|
||||||
// When authenticated crypto is in use the wrapped receive_buffer
|
// When authenticated crypto is in use the wrapped receive_buffer
|
||||||
|
|
|
@ -157,7 +157,7 @@ namespace libtorrent {
|
||||||
peer_source_flags_t peer_source() const
|
peer_source_flags_t peer_source() const
|
||||||
{ return peer_source_flags_t(source); }
|
{ return peer_source_flags_t(source); }
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
// Hints encryption support of torrent_peer. Only effective
|
// Hints encryption support of torrent_peer. Only effective
|
||||||
// for and when the outgoing encryption policy
|
// for and when the outgoing encryption policy
|
||||||
// allows both encrypted and non encrypted
|
// allows both encrypted and non encrypted
|
||||||
|
|
|
@ -41,6 +41,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace sim;
|
using namespace sim;
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
|
||||||
struct sim_config : sim::default_config
|
struct sim_config : sim::default_config
|
||||||
{
|
{
|
||||||
chrono::high_resolution_clock::duration hostname_lookup(
|
chrono::high_resolution_clock::duration hostname_lookup(
|
||||||
|
@ -104,3 +106,6 @@ TORRENT_TEST(dht_bootstrap)
|
||||||
TEST_CHECK(a.dict_find_int_value("bs", -1) == 1);
|
TEST_CHECK(a.dict_find_int_value("bs", -1) == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
TORRENT_TEST(disabled) {}
|
||||||
|
#endif // TORRENT_DISABLE_DHT
|
||||||
|
|
|
@ -218,7 +218,7 @@ TORRENT_TEST(dht_rate_limit)
|
||||||
TEST_EQUAL(cnt[counters::dht_messages_in_dropped]
|
TEST_EQUAL(cnt[counters::dht_messages_in_dropped]
|
||||||
+ cnt[counters::dht_ping_in], num_packets);
|
+ cnt[counters::dht_ping_in], num_packets);
|
||||||
|
|
||||||
#endif // #if !defined TORRENT_DISABLE_EXTENSIONS && !defined TORRENT_DISABLE_DHT
|
#endif // #if !defined TORRENT_DISABLE_DHT
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: put test here to take advantage of existing code, refactor
|
// TODO: put test here to take advantage of existing code, refactor
|
||||||
|
|
|
@ -30,9 +30,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
|
||||||
|
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
#include "setup_transfer.hpp" // for ep()
|
#include "setup_transfer.hpp" // for ep()
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
|
@ -210,5 +212,6 @@ TORRENT_TEST(dht_storage_infohashes_sample)
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
sim.run(ec);
|
sim.run(ec);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
TORRENT_TEST(disabled) {}
|
||||||
#endif // TORRENT_DISABLE_DHT
|
#endif // TORRENT_DISABLE_DHT
|
||||||
|
|
|
@ -44,6 +44,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
||||||
enum flags_t
|
enum flags_t
|
||||||
{
|
{
|
||||||
// disconnect immediately after receiving the metadata (to test that
|
// disconnect immediately after receiving the metadata (to test that
|
||||||
|
@ -210,4 +212,6 @@ TORRENT_TEST(ut_metadata_upload_only_disconnect_readd)
|
||||||
{
|
{
|
||||||
run_metadata_test(upload_only | disconnect | readd);
|
run_metadata_test(upload_only | disconnect | readd);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
TORRENT_TEST(disabled) {}
|
||||||
|
#endif // TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
|
@ -41,7 +41,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
#include "setup_swarm.hpp"
|
#include "setup_swarm.hpp"
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
|
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,14 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/string_util.hpp" // for search
|
#include "libtorrent/string_util.hpp" // for search
|
||||||
#include "libtorrent/aux_/generate_peer_id.hpp"
|
#include "libtorrent/aux_/generate_peer_id.hpp"
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
#include "libtorrent/pe_crypto.hpp"
|
#include "libtorrent/pe_crypto.hpp"
|
||||||
#include "libtorrent/hasher.hpp"
|
#include "libtorrent/hasher.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr std::size_t handshake_len = 68;
|
constexpr std::size_t handshake_len = 68;
|
||||||
|
@ -150,7 +150,7 @@ namespace {
|
||||||
, m_sent_bitfield(false)
|
, m_sent_bitfield(false)
|
||||||
, m_sent_handshake(false)
|
, m_sent_handshake(false)
|
||||||
, m_sent_allowed_fast(false)
|
, m_sent_allowed_fast(false)
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
, m_encrypted(false)
|
, m_encrypted(false)
|
||||||
, m_rc4_encrypted(false)
|
, m_rc4_encrypted(false)
|
||||||
, m_recv_buffer(peer_connection::m_recv_buffer)
|
, m_recv_buffer(peer_connection::m_recv_buffer)
|
||||||
|
@ -161,9 +161,7 @@ namespace {
|
||||||
peer_log(peer_log_alert::info, "CONSTRUCT", "bt_peer_connection");
|
peer_log(peer_log_alert::info, "CONSTRUCT", "bt_peer_connection");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
m_reserved_bits.fill(0);
|
m_reserved_bits.fill(0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::start()
|
void bt_peer_connection::start()
|
||||||
|
@ -178,7 +176,7 @@ namespace {
|
||||||
|
|
||||||
bt_peer_connection::~bt_peer_connection() = default;
|
bt_peer_connection::~bt_peer_connection() = default;
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
void bt_peer_connection::switch_send_crypto(std::shared_ptr<crypto_plugin> crypto)
|
void bt_peer_connection::switch_send_crypto(std::shared_ptr<crypto_plugin> crypto)
|
||||||
{
|
{
|
||||||
if (m_enc_handler.switch_send_crypto(std::move(crypto), send_buffer_size() - get_send_barrier()))
|
if (m_enc_handler.switch_send_crypto(std::move(crypto), send_buffer_size() - get_send_barrier()))
|
||||||
|
@ -211,7 +209,7 @@ namespace {
|
||||||
// packet, or at least back-to-back packets
|
// packet, or at least back-to-back packets
|
||||||
cork c_(*this);
|
cork c_(*this);
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
|
|
||||||
std::uint8_t out_policy = std::uint8_t(m_settings.get_int(settings_pack::out_enc_policy));
|
std::uint8_t out_policy = std::uint8_t(m_settings.get_int(settings_pack::out_enc_policy));
|
||||||
|
|
||||||
|
@ -304,13 +302,11 @@ namespace {
|
||||||
// will send their bitfield when the handshake
|
// will send their bitfield when the handshake
|
||||||
// is done
|
// is done
|
||||||
std::shared_ptr<torrent> t = associated_torrent().lock();
|
std::shared_ptr<torrent> t = associated_torrent().lock();
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
if (!t->share_mode())
|
if (!t->share_mode())
|
||||||
{
|
{
|
||||||
bool const upload_only_enabled = t->is_upload_only() && !t->super_seeding();
|
bool const upload_only_enabled = t->is_upload_only() && !t->super_seeding();
|
||||||
send_upload_only(upload_only_enabled);
|
send_upload_only(upload_only_enabled);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (m_sent_bitfield) return;
|
if (m_sent_bitfield) return;
|
||||||
|
|
||||||
|
@ -449,7 +445,7 @@ namespace {
|
||||||
if (is_utp(*get_socket())) p.flags |= peer_info::utp_socket;
|
if (is_utp(*get_socket())) p.flags |= peer_info::utp_socket;
|
||||||
if (is_ssl(*get_socket())) p.flags |= peer_info::ssl_socket;
|
if (is_ssl(*get_socket())) p.flags |= peer_info::ssl_socket;
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
if (m_encrypted)
|
if (m_encrypted)
|
||||||
{
|
{
|
||||||
p.flags |= m_rc4_encrypted
|
p.flags |= m_rc4_encrypted
|
||||||
|
@ -471,7 +467,7 @@ namespace {
|
||||||
return !m_sent_handshake;
|
return !m_sent_handshake;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
|
|
||||||
void bt_peer_connection::write_pe1_2_dhkey()
|
void bt_peer_connection::write_pe1_2_dhkey()
|
||||||
{
|
{
|
||||||
|
@ -671,7 +667,7 @@ namespace {
|
||||||
m_rc4->decrypt(buf);
|
m_rc4->decrypt(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#endif // #if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
|
|
||||||
void bt_peer_connection::write_handshake()
|
void bt_peer_connection::write_handshake()
|
||||||
{
|
{
|
||||||
|
@ -702,10 +698,8 @@ namespace {
|
||||||
*(ptr + 7) |= 0x01;
|
*(ptr + 7) |= 0x01;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
// we support extensions
|
// we support extensions
|
||||||
*(ptr + 5) |= 0x10;
|
*(ptr + 5) |= 0x10;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (m_settings.get_bool(settings_pack::support_merkle_torrents))
|
if (m_settings.get_bool(settings_pack::support_merkle_torrents))
|
||||||
{
|
{
|
||||||
|
@ -1327,7 +1321,6 @@ namespace {
|
||||||
// -------- RENDEZVOUS ---------
|
// -------- RENDEZVOUS ---------
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
void bt_peer_connection::on_holepunch()
|
void bt_peer_connection::on_holepunch()
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
@ -1540,13 +1533,11 @@ namespace {
|
||||||
|
|
||||||
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
}
|
}
|
||||||
#endif // TORRENT_DISABLE_EXTENSIONS
|
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
// --------- EXTENDED ----------
|
// --------- EXTENDED ----------
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
void bt_peer_connection::on_extended(int received)
|
void bt_peer_connection::on_extended(int received)
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
@ -1652,12 +1643,14 @@ namespace {
|
||||||
, "msg: %d size: %d", extended_id, m_recv_buffer.packet_size());
|
, "msg: %d size: %d", extended_id, m_recv_buffer.packet_size());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (auto const& e : m_extensions)
|
for (auto const& e : m_extensions)
|
||||||
{
|
{
|
||||||
if (e->on_extended(m_recv_buffer.packet_size() - 2, extended_id
|
if (e->on_extended(m_recv_buffer.packet_size() - 2, extended_id
|
||||||
, recv_buffer))
|
, recv_buffer))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
disconnect(errors::invalid_message, operation_t::bittorrent, 2);
|
disconnect(errors::invalid_message, operation_t::bittorrent, 2);
|
||||||
}
|
}
|
||||||
|
@ -1696,6 +1689,7 @@ namespace {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
for (auto i = m_extensions.begin();
|
for (auto i = m_extensions.begin();
|
||||||
!m_extensions.empty() && i != m_extensions.end();)
|
!m_extensions.empty() && i != m_extensions.end();)
|
||||||
{
|
{
|
||||||
|
@ -1707,6 +1701,7 @@ namespace {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
if (is_disconnecting()) return;
|
if (is_disconnecting()) return;
|
||||||
|
#endif
|
||||||
|
|
||||||
// upload_only
|
// upload_only
|
||||||
if (bdecode_node const m = root.dict_find_dict("m"))
|
if (bdecode_node const m = root.dict_find_dict("m"))
|
||||||
|
@ -1782,7 +1777,6 @@ namespace {
|
||||||
|
|
||||||
stats_counters().inc_stats_counter(counters::num_incoming_ext_handshake);
|
stats_counters().inc_stats_counter(counters::num_incoming_ext_handshake);
|
||||||
}
|
}
|
||||||
#endif // TORRENT_DISABLE_EXTENSIONS
|
|
||||||
|
|
||||||
bool bt_peer_connection::dispatch_message(int const received)
|
bool bt_peer_connection::dispatch_message(int const received)
|
||||||
{
|
{
|
||||||
|
@ -1833,9 +1827,7 @@ namespace {
|
||||||
case msg_have_none: on_have_none(received); break;
|
case msg_have_none: on_have_none(received); break;
|
||||||
case msg_reject_request: on_reject_request(received); break;
|
case msg_reject_request: on_reject_request(received); break;
|
||||||
case msg_allowed_fast: on_allowed_fast(received); break;
|
case msg_allowed_fast: on_allowed_fast(received); break;
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
case msg_extended: on_extended(received); break;
|
case msg_extended: on_extended(received); break;
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
@ -1880,7 +1872,6 @@ namespace {
|
||||||
|
|
||||||
void bt_peer_connection::write_upload_only(bool const enabled)
|
void bt_peer_connection::write_upload_only(bool const enabled)
|
||||||
{
|
{
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
|
@ -1902,12 +1893,8 @@ namespace {
|
||||||
send_buffer(msg);
|
send_buffer(msg);
|
||||||
|
|
||||||
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
#else
|
|
||||||
TORRENT_UNUSED(enabled);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
void bt_peer_connection::write_share_mode()
|
void bt_peer_connection::write_share_mode()
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
@ -1923,7 +1910,6 @@ namespace {
|
||||||
|
|
||||||
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void bt_peer_connection::write_keepalive()
|
void bt_peer_connection::write_keepalive()
|
||||||
{
|
{
|
||||||
|
@ -2073,7 +2059,6 @@ namespace {
|
||||||
stats_counters().inc_stats_counter(counters::num_outgoing_bitfield);
|
stats_counters().inc_stats_counter(counters::num_outgoing_bitfield);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
void bt_peer_connection::write_extensions()
|
void bt_peer_connection::write_extensions()
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
@ -2147,12 +2132,14 @@ namespace {
|
||||||
&& t->share_mode())
|
&& t->share_mode())
|
||||||
handshake["share_mode"] = 1;
|
handshake["share_mode"] = 1;
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
// loop backwards, to make the first extension be the last
|
// loop backwards, to make the first extension be the last
|
||||||
// to fill in the handshake (i.e. give the first extensions priority)
|
// to fill in the handshake (i.e. give the first extensions priority)
|
||||||
for (auto const& e : m_extensions)
|
for (auto const& e : m_extensions)
|
||||||
{
|
{
|
||||||
e->add_handshake(handshake);
|
e->add_handshake(handshake);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// make sure there are not conflicting extensions
|
// make sure there are not conflicting extensions
|
||||||
|
@ -2191,7 +2178,6 @@ namespace {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void bt_peer_connection::write_choke()
|
void bt_peer_connection::write_choke()
|
||||||
{
|
{
|
||||||
|
@ -2246,7 +2232,6 @@ namespace {
|
||||||
|
|
||||||
void bt_peer_connection::write_dont_have(piece_index_t const index)
|
void bt_peer_connection::write_dont_have(piece_index_t const index)
|
||||||
{
|
{
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
|
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
|
||||||
TORRENT_ASSERT(index >= piece_index_t(0));
|
TORRENT_ASSERT(index >= piece_index_t(0));
|
||||||
|
@ -2265,9 +2250,6 @@ namespace {
|
||||||
send_buffer(msg);
|
send_buffer(msg);
|
||||||
|
|
||||||
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
#else
|
|
||||||
TORRENT_UNUSED(index);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_peer_connection::write_piece(peer_request const& r, disk_buffer_holder buffer)
|
void bt_peer_connection::write_piece(peer_request const& r, disk_buffer_holder buffer)
|
||||||
|
@ -2370,7 +2352,7 @@ namespace {
|
||||||
// packet, or at least back-to-back packets
|
// packet, or at least back-to-back packets
|
||||||
cork c_(*this);
|
cork c_(*this);
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
if (!m_enc_handler.is_recv_plaintext())
|
if (!m_enc_handler.is_recv_plaintext())
|
||||||
{
|
{
|
||||||
int const consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred);
|
int const consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred);
|
||||||
|
@ -2428,7 +2410,7 @@ namespace {
|
||||||
|
|
||||||
span<char const> recv_buffer = m_recv_buffer.get();
|
span<char const> recv_buffer = m_recv_buffer.get();
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
// m_state is set to read_pe_dhkey in initial state
|
// m_state is set to read_pe_dhkey in initial state
|
||||||
// (read_protocol_identifier) for incoming, or in constructor
|
// (read_protocol_identifier) for incoming, or in constructor
|
||||||
// for outgoing
|
// for outgoing
|
||||||
|
@ -2949,7 +2931,7 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#endif // #if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
|
|
||||||
if (m_state == state_t::read_protocol_identifier)
|
if (m_state == state_t::read_protocol_identifier)
|
||||||
{
|
{
|
||||||
|
@ -2966,7 +2948,7 @@ namespace {
|
||||||
if (packet_size != 19 ||
|
if (packet_size != 19 ||
|
||||||
std::memcmp(recv_buffer.begin(), protocol_string, 20) != 0)
|
std::memcmp(recv_buffer.begin(), protocol_string, 20) != 0)
|
||||||
{
|
{
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
peer_log(peer_log_alert::info, "ENCRYPTION"
|
peer_log(peer_log_alert::info, "ENCRYPTION"
|
||||||
, "unrecognized protocol header");
|
, "unrecognized protocol header");
|
||||||
|
@ -3016,7 +2998,7 @@ namespace {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
TORRENT_ASSERT(m_state != state_t::read_pe_dhkey);
|
TORRENT_ASSERT(m_state != state_t::read_pe_dhkey);
|
||||||
|
|
||||||
if (!is_outgoing()
|
if (!is_outgoing()
|
||||||
|
@ -3070,11 +3052,10 @@ namespace {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
std::memcpy(m_reserved_bits.data(), recv_buffer.begin(), 8);
|
std::memcpy(m_reserved_bits.data(), recv_buffer.begin(), 8);
|
||||||
if (recv_buffer[5] & 0x10)
|
if (recv_buffer[5] & 0x10)
|
||||||
m_supports_extensions = true;
|
m_supports_extensions = true;
|
||||||
#endif
|
|
||||||
if (recv_buffer[7] & 0x01)
|
if (recv_buffer[7] & 0x01)
|
||||||
m_supports_dht_port = true;
|
m_supports_dht_port = true;
|
||||||
|
|
||||||
|
@ -3213,9 +3194,9 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_disconnecting()) return;
|
if (is_disconnecting()) return;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_supports_extensions) write_extensions();
|
if (m_supports_extensions) write_extensions();
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
peer_log(peer_log_alert::incoming_message, "HANDSHAKE", "connection ready");
|
peer_log(peer_log_alert::incoming_message, "HANDSHAKE", "connection ready");
|
||||||
|
@ -3224,7 +3205,7 @@ namespace {
|
||||||
if (peer_info_struct())
|
if (peer_info_struct())
|
||||||
t->clear_failcount(peer_info_struct());
|
t->clear_failcount(peer_info_struct());
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
// Toggle pe_support back to false if this is a
|
// Toggle pe_support back to false if this is a
|
||||||
// standard successful connection
|
// standard successful connection
|
||||||
if (is_outgoing() && !m_encrypted &&
|
if (is_outgoing() && !m_encrypted &&
|
||||||
|
@ -3351,7 +3332,7 @@ namespace {
|
||||||
TORRENT_ASSERT(!m_recv_buffer.packet_finished());
|
TORRENT_ASSERT(!m_recv_buffer.packet_finished());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
std::tuple<int, span<span<char const>>>
|
std::tuple<int, span<span<char const>>>
|
||||||
bt_peer_connection::hit_send_barrier(
|
bt_peer_connection::hit_send_barrier(
|
||||||
span<span<char>> iovec)
|
span<span<char>> iovec)
|
||||||
|
@ -3432,7 +3413,7 @@ namespace {
|
||||||
{
|
{
|
||||||
std::shared_ptr<torrent> t = associated_torrent().lock();
|
std::shared_ptr<torrent> t = associated_torrent().lock();
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPTION
|
||||||
TORRENT_ASSERT( (bool(m_state != state_t::read_pe_dhkey) || m_dh_key_exchange.get())
|
TORRENT_ASSERT( (bool(m_state != state_t::read_pe_dhkey) || m_dh_key_exchange.get())
|
||||||
|| !is_outgoing());
|
|| !is_outgoing());
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ namespace libtorrent {
|
||||||
, (tracker_req().event != tracker_request::none) ? event_string[tracker_req().event - 1] : ""
|
, (tracker_req().event != tracker_request::none) ? event_string[tracker_req().event - 1] : ""
|
||||||
, tracker_req().num_want);
|
, tracker_req().num_want);
|
||||||
url += str;
|
url += str;
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
if (settings.get_int(settings_pack::in_enc_policy) != settings_pack::pe_disabled
|
if (settings.get_int(settings_pack::in_enc_policy) != settings_pack::pe_disabled
|
||||||
&& settings.get_bool(settings_pack::announce_crypto_support))
|
&& settings.get_bool(settings_pack::announce_crypto_support))
|
||||||
url += "&supportcrypto=1";
|
url += "&supportcrypto=1";
|
||||||
|
|
|
@ -30,7 +30,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -411,4 +411,4 @@ std::size_t rc4_encrypt(unsigned char *out, std::size_t outlen, rc4 *state)
|
||||||
|
|
||||||
} // namespace libtorrent
|
} // namespace libtorrent
|
||||||
|
|
||||||
#endif // #if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#endif // TORRENT_DISABLE_ENCRYPION
|
||||||
|
|
|
@ -4275,7 +4275,7 @@ namespace libtorrent {
|
||||||
if (m_outgoing) m_counters.inc_stats_counter(counters::error_outgoing_peers);
|
if (m_outgoing) m_counters.inc_stats_counter(counters::error_outgoing_peers);
|
||||||
else m_counters.inc_stats_counter(counters::error_incoming_peers);
|
else m_counters.inc_stats_counter(counters::error_incoming_peers);
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
if (type() == connection_type::bittorrent && op != operation_t::connect)
|
if (type() == connection_type::bittorrent && op != operation_t::connect)
|
||||||
{
|
{
|
||||||
auto* bt = static_cast<bt_peer_connection*>(this);
|
auto* bt = static_cast<bt_peer_connection*>(this);
|
||||||
|
|
|
@ -315,7 +315,7 @@ bool bt_peer_connection_handle::support_extensions() const
|
||||||
|
|
||||||
bool bt_peer_connection_handle::supports_encryption() const
|
bool bt_peer_connection_handle::supports_encryption() const
|
||||||
{
|
{
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
std::shared_ptr<bt_peer_connection> pc = native_handle();
|
std::shared_ptr<bt_peer_connection> pc = native_handle();
|
||||||
TORRENT_ASSERT(pc);
|
TORRENT_ASSERT(pc);
|
||||||
return pc->supports_encryption();
|
return pc->supports_encryption();
|
||||||
|
@ -326,7 +326,7 @@ bool bt_peer_connection_handle::supports_encryption() const
|
||||||
|
|
||||||
void bt_peer_connection_handle::switch_send_crypto(std::shared_ptr<crypto_plugin> crypto)
|
void bt_peer_connection_handle::switch_send_crypto(std::shared_ptr<crypto_plugin> crypto)
|
||||||
{
|
{
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
std::shared_ptr<bt_peer_connection> pc = native_handle();
|
std::shared_ptr<bt_peer_connection> pc = native_handle();
|
||||||
TORRENT_ASSERT(pc);
|
TORRENT_ASSERT(pc);
|
||||||
pc->switch_send_crypto(std::move(crypto));
|
pc->switch_send_crypto(std::move(crypto));
|
||||||
|
@ -337,7 +337,7 @@ void bt_peer_connection_handle::switch_send_crypto(std::shared_ptr<crypto_plugin
|
||||||
|
|
||||||
void bt_peer_connection_handle::switch_recv_crypto(std::shared_ptr<crypto_plugin> crypto)
|
void bt_peer_connection_handle::switch_recv_crypto(std::shared_ptr<crypto_plugin> crypto)
|
||||||
{
|
{
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
std::shared_ptr<bt_peer_connection> pc = native_handle();
|
std::shared_ptr<bt_peer_connection> pc = native_handle();
|
||||||
TORRENT_ASSERT(pc);
|
TORRENT_ASSERT(pc);
|
||||||
pc->switch_recv_crypto(std::move(crypto));
|
pc->switch_recv_crypto(std::move(crypto));
|
||||||
|
|
|
@ -922,7 +922,7 @@ namespace libtorrent {
|
||||||
|
|
||||||
if (m_round_robin >= iter - m_peers.begin()) ++m_round_robin;
|
if (m_round_robin >= iter - m_peers.begin()) ++m_round_robin;
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
if (flags & pex_encryption) p->pe_support = true;
|
if (flags & pex_encryption) p->pe_support = true;
|
||||||
#endif
|
#endif
|
||||||
if (flags & pex_seed)
|
if (flags & pex_seed)
|
||||||
|
|
|
@ -150,7 +150,7 @@ span<char const> receive_buffer::get() const
|
||||||
return aux::typed_span<char const>(m_recv_buffer).subspan(m_recv_start, m_recv_pos);
|
return aux::typed_span<char const>(m_recv_buffer).subspan(m_recv_start, m_recv_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
span<char> receive_buffer::mutable_buffer()
|
span<char> receive_buffer::mutable_buffer()
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
@ -230,7 +230,7 @@ void receive_buffer::reset(int const packet_size)
|
||||||
m_packet_size = packet_size;
|
m_packet_size = packet_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
bool crypto_receive_buffer::packet_finished() const
|
bool crypto_receive_buffer::packet_finished() const
|
||||||
{
|
{
|
||||||
if (m_recv_pos == INT_MAX)
|
if (m_recv_pos == INT_MAX)
|
||||||
|
|
|
@ -4460,7 +4460,7 @@ namespace aux {
|
||||||
trigger_auto_manage();
|
trigger_auto_manage();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
torrent const* session_impl::find_encrypted_torrent(sha1_hash const& info_hash
|
torrent const* session_impl::find_encrypted_torrent(sha1_hash const& info_hash
|
||||||
, sha1_hash const& xor_mask)
|
, sha1_hash const& xor_mask)
|
||||||
{
|
{
|
||||||
|
@ -4803,7 +4803,7 @@ namespace aux {
|
||||||
|
|
||||||
m_torrents.insert(std::make_pair(params.info_hash, torrent_ptr));
|
m_torrents.insert(std::make_pair(params.info_hash, torrent_ptr));
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
static char const req2[4] = {'r', 'e', 'q', '2'};
|
static char const req2[4] = {'r', 'e', 'q', '2'};
|
||||||
hasher h(req2);
|
hasher h(req2);
|
||||||
h.update(params.info_hash);
|
h.update(params.info_hash);
|
||||||
|
@ -5191,7 +5191,7 @@ namespace aux {
|
||||||
m_torrents.erase(i);
|
m_torrents.erase(i);
|
||||||
tptr->removed();
|
tptr->removed();
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
static char const req2[4] = {'r', 'e', 'q', '2'};
|
static char const req2[4] = {'r', 'e', 'q', '2'};
|
||||||
hasher h(req2);
|
hasher h(req2);
|
||||||
h.update(tptr->info_hash());
|
h.update(tptr->info_hash());
|
||||||
|
@ -6092,13 +6092,13 @@ namespace aux {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
void session_impl::add_obfuscated_hash(sha1_hash const& obfuscated
|
void session_impl::add_obfuscated_hash(sha1_hash const& obfuscated
|
||||||
, std::weak_ptr<torrent> const& t)
|
, std::weak_ptr<torrent> const& t)
|
||||||
{
|
{
|
||||||
m_obfuscated_torrents.insert(std::make_pair(obfuscated, t.lock()));
|
m_obfuscated_torrents.insert(std::make_pair(obfuscated, t.lock()));
|
||||||
}
|
}
|
||||||
#endif // !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#endif // TORRENT_DISABLE_ENCRYPION
|
||||||
|
|
||||||
bool session_impl::is_listening() const
|
bool session_impl::is_listening() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -490,7 +490,7 @@ bool is_downloading_state(int const st)
|
||||||
aux::random_shuffle(ws.begin(), ws.end());
|
aux::random_shuffle(ws.begin(), ws.end());
|
||||||
for (auto& w : ws) m_web_seeds.push_back(std::move(w));
|
for (auto& w : ws) m_web_seeds.push_back(std::move(w));
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
static char const req2[4] = {'r', 'e', 'q', '2'};
|
static char const req2[4] = {'r', 'e', 'q', '2'};
|
||||||
hasher h(req2);
|
hasher h(req2);
|
||||||
h.update(m_torrent_file->info_hash());
|
h.update(m_torrent_file->info_hash());
|
||||||
|
|
|
@ -151,7 +151,7 @@ namespace libtorrent {
|
||||||
, fast_reconnects(0)
|
, fast_reconnects(0)
|
||||||
, trust_points(0)
|
, trust_points(0)
|
||||||
, source(static_cast<std::uint8_t>(src))
|
, source(static_cast<std::uint8_t>(src))
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
// assume no support in order to
|
// assume no support in order to
|
||||||
// prefer opening non-encrypted
|
// prefer opening non-encrypted
|
||||||
// connections. If it fails, we'll
|
// connections. If it fails, we'll
|
||||||
|
|
|
@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
||||||
namespace libtorrent {namespace {
|
namespace libtorrent { namespace {
|
||||||
|
|
||||||
const char extension_name[] = "ut_pex";
|
const char extension_name[] = "ut_pex";
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ namespace libtorrent {namespace {
|
||||||
// used as a rendezvous point in case direct
|
// used as a rendezvous point in case direct
|
||||||
// connections to the peer fail
|
// connections to the peer fail
|
||||||
pex_flags_t flags = p->is_seed() ? pex_seed : pex_flags_t{};
|
pex_flags_t flags = p->is_seed() ? pex_seed : pex_flags_t{};
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
flags |= p->supports_encryption() ? pex_encryption : pex_flags_t{};
|
flags |= p->supports_encryption() ? pex_encryption : pex_flags_t{};
|
||||||
#endif
|
#endif
|
||||||
flags |= is_utp(*p->get_socket()) ? pex_utp : pex_flags_t{};
|
flags |= is_utp(*p->get_socket()) ? pex_utp : pex_flags_t{};
|
||||||
|
@ -552,7 +552,7 @@ namespace libtorrent {namespace {
|
||||||
// used as a rendezvous point in case direct
|
// used as a rendezvous point in case direct
|
||||||
// connections to the peer fail
|
// connections to the peer fail
|
||||||
int flags = p->is_seed() ? 2 : 0;
|
int flags = p->is_seed() ? 2 : 0;
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
flags |= p->supports_encryption() ? 1 : 0;
|
flags |= p->supports_encryption() ? 1 : 0;
|
||||||
#endif
|
#endif
|
||||||
flags |= is_utp(*p->get_socket()) ? 4 : 0;
|
flags |= is_utp(*p->get_socket()) ? 4 : 0;
|
||||||
|
|
|
@ -30,8 +30,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
|
||||||
|
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/session.hpp"
|
#include "libtorrent/session.hpp"
|
||||||
#include "libtorrent/kademlia/dht_settings.hpp"
|
#include "libtorrent/kademlia/dht_settings.hpp"
|
||||||
|
@ -54,6 +52,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
#include "setup_transfer.hpp"
|
#include "setup_transfer.hpp"
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
|
||||||
using namespace lt;
|
using namespace lt;
|
||||||
using namespace lt::dht;
|
using namespace lt::dht;
|
||||||
|
|
||||||
|
@ -505,5 +505,6 @@ TORRENT_TEST(infohashes_sample_dist)
|
||||||
std::printf("infohashes set size: %d\n", int(infohash_set.size()));
|
std::printf("infohashes set size: %d\n", int(infohash_set.size()));
|
||||||
TEST_CHECK(infohash_set.size() > 500);
|
TEST_CHECK(infohash_set.size() > 500);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
TORRENT_TEST(dummy) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -283,11 +283,7 @@ void do_handshake(tcp::socket& s, sha1_hash const& ih, char* buffer)
|
||||||
|
|
||||||
// check for extension protocol support
|
// check for extension protocol support
|
||||||
bool const lt_extension_protocol = (extensions[5] & 0x10) != 0;
|
bool const lt_extension_protocol = (extensions[5] & 0x10) != 0;
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
TEST_CHECK(lt_extension_protocol == true);
|
TEST_CHECK(lt_extension_protocol == true);
|
||||||
#else
|
|
||||||
TEST_CHECK(lt_extension_protocol == false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// check for DHT support
|
// check for DHT support
|
||||||
bool const dht_support = (extensions[7] & 0x1) != 0;
|
bool const dht_support = (extensions[7] & 0x1) != 0;
|
||||||
|
@ -363,6 +359,7 @@ entry read_extension_handshake(tcp::socket& s, char* recv_buffer, int size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
void send_ut_metadata_msg(tcp::socket& s, int ut_metadata_msg, int type, int piece)
|
void send_ut_metadata_msg(tcp::socket& s, int ut_metadata_msg, int type, int piece)
|
||||||
{
|
{
|
||||||
std::vector<char> buf;
|
std::vector<char> buf;
|
||||||
|
@ -414,6 +411,7 @@ entry read_ut_metadata_msg(tcp::socket& s, char* recv_buffer, int size)
|
||||||
return bdecode(recv_buffer + 2, recv_buffer + len);
|
return bdecode(recv_buffer + 2, recv_buffer + len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
||||||
std::shared_ptr<torrent_info> setup_peer(tcp::socket& s, sha1_hash& ih
|
std::shared_ptr<torrent_info> setup_peer(tcp::socket& s, sha1_hash& ih
|
||||||
, std::shared_ptr<lt::session>& ses, bool incoming = true
|
, std::shared_ptr<lt::session>& ses, bool incoming = true
|
||||||
|
@ -794,7 +792,6 @@ TORRENT_TEST(multiple_have_all)
|
||||||
print_session_log(*ses);
|
print_session_log(*ses);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
|
||||||
// makes sure that pieces that are lost are not requested
|
// makes sure that pieces that are lost are not requested
|
||||||
TORRENT_TEST(dont_have)
|
TORRENT_TEST(dont_have)
|
||||||
{
|
{
|
||||||
|
@ -896,6 +893,43 @@ TORRENT_TEST(dont_have)
|
||||||
print_session_log(*ses);
|
print_session_log(*ses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TORRENT_TEST(extension_handshake)
|
||||||
|
{
|
||||||
|
using namespace lt::detail;
|
||||||
|
|
||||||
|
sha1_hash ih;
|
||||||
|
std::shared_ptr<lt::session> ses;
|
||||||
|
io_service ios;
|
||||||
|
tcp::socket s(ios);
|
||||||
|
std::shared_ptr<torrent_info> ti = setup_peer(s, ih, ses);
|
||||||
|
|
||||||
|
char recv_buffer[1000];
|
||||||
|
do_handshake(s, ih, recv_buffer);
|
||||||
|
print_session_log(*ses);
|
||||||
|
send_have_all(s);
|
||||||
|
print_session_log(*ses);
|
||||||
|
|
||||||
|
entry extensions;
|
||||||
|
send_extension_handshake(s, extensions);
|
||||||
|
|
||||||
|
extensions = read_extension_handshake(s, recv_buffer, sizeof(recv_buffer));
|
||||||
|
|
||||||
|
std::cout << extensions << '\n';
|
||||||
|
|
||||||
|
// these extensions are built-in
|
||||||
|
TEST_CHECK(extensions["m"]["lt_donthave"].integer() != 0);
|
||||||
|
TEST_CHECK(extensions["m"]["share_mode"].integer() != 0);
|
||||||
|
TEST_CHECK(extensions["m"]["upload_only"].integer() != 0);
|
||||||
|
TEST_CHECK(extensions["m"]["ut_holepunch"].integer() != 0);
|
||||||
|
|
||||||
|
// these require extensions to be enabled
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
TEST_CHECK(extensions["m"]["ut_metadata"].integer() != 0);
|
||||||
|
TEST_CHECK(extensions["m"]["ut_pex"].integer() != 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
// TEST metadata extension messages and edge cases
|
// TEST metadata extension messages and edge cases
|
||||||
|
|
||||||
// this tests sending a request for a metadata piece that's too high. This is
|
// this tests sending a request for a metadata piece that's too high. This is
|
||||||
|
@ -904,8 +938,6 @@ TORRENT_TEST(invalid_metadata_request)
|
||||||
{
|
{
|
||||||
using namespace lt::detail;
|
using namespace lt::detail;
|
||||||
|
|
||||||
std::cout << "\n === test invalid metadata ===\n" << std::endl;
|
|
||||||
|
|
||||||
sha1_hash ih;
|
sha1_hash ih;
|
||||||
std::shared_ptr<lt::session> ses;
|
std::shared_ptr<lt::session> ses;
|
||||||
io_service ios;
|
io_service ios;
|
||||||
|
@ -954,6 +986,8 @@ TORRENT_TEST(invalid_metadata_request)
|
||||||
|
|
||||||
print_session_log(*ses);
|
print_session_log(*ses);
|
||||||
}
|
}
|
||||||
|
#endif // TORRENT_DISABLE_EXTENSIONS
|
||||||
|
|
||||||
|
|
||||||
TORRENT_TEST(invalid_request)
|
TORRENT_TEST(invalid_request)
|
||||||
{
|
{
|
||||||
|
@ -1030,7 +1064,5 @@ TORRENT_TEST(incoming_have_all)
|
||||||
have_all_test(false);
|
have_all_test(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TORRENT_DISABLE_EXTENSIONS
|
|
||||||
|
|
||||||
// TODO: test sending invalid requests (out of bound piece index, offsets and
|
// TODO: test sending invalid requests (out of bound piece index, offsets and
|
||||||
// sizes)
|
// sizes)
|
||||||
|
|
|
@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "setup_transfer.hpp"
|
#include "setup_transfer.hpp"
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
|
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined TORRENT_DISABLE_ENCRYPION
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ constexpr flags_t expect_peer_connection = 6_bit;
|
||||||
constexpr flags_t dont_proxy_peers = 10_bit;
|
constexpr flags_t dont_proxy_peers = 10_bit;
|
||||||
constexpr flags_t dont_proxy_trackers = 11_bit;
|
constexpr flags_t dont_proxy_trackers = 11_bit;
|
||||||
|
|
||||||
session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, flags_t const flags)
|
session_proxy test_proxy(settings_pack::proxy_type_t proxy_type, flags_t flags)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_DISABLE_DHT
|
#ifdef TORRENT_DISABLE_DHT
|
||||||
// if DHT is disabled, we won't get any requests to it
|
// if DHT is disabled, we won't get any requests to it
|
||||||
|
|
|
@ -424,7 +424,9 @@ TORRENT_TEST(save_state_peer_id)
|
||||||
TEST_EQUAL(ses.get_settings().get_str(settings_pack::peer_fingerprint), "foobar");
|
TEST_EQUAL(ses.get_settings().get_str(settings_pack::peer_fingerprint), "foobar");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#if !defined TORRENT_DISABLE_LOGGING
|
||||||
|
|
||||||
|
#if !defined TORRENT_DISABLE_DHT
|
||||||
|
|
||||||
auto const count_dht_inits = [](session& ses)
|
auto const count_dht_inits = [](session& ses)
|
||||||
{
|
{
|
||||||
|
@ -496,6 +498,8 @@ TORRENT_TEST(init_dht_empty_bootstrap)
|
||||||
TEST_EQUAL(count, 1);
|
TEST_EQUAL(count, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // TORRENT_DISABLE_DHT
|
||||||
|
|
||||||
TORRENT_TEST(reopen_network_sockets)
|
TORRENT_TEST(reopen_network_sockets)
|
||||||
{
|
{
|
||||||
auto count_alerts = [](session& ses, int const listen, int const portmap)
|
auto count_alerts = [](session& ses, int const listen, int const portmap)
|
||||||
|
|
|
@ -604,16 +604,12 @@ void test_malicious_peer()
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
#endif // TORRENT_USE_OPENSSL
|
|
||||||
|
|
||||||
TORRENT_TEST(malicious_peer)
|
TORRENT_TEST(malicious_peer)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
|
||||||
test_malicious_peer();
|
test_malicious_peer();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
|
||||||
TORRENT_TEST(utp_config0) { test_ssl(0, true); }
|
TORRENT_TEST(utp_config0) { test_ssl(0, true); }
|
||||||
TORRENT_TEST(utp_config1) { test_ssl(1, true); }
|
TORRENT_TEST(utp_config1) { test_ssl(1, true); }
|
||||||
TORRENT_TEST(utp_config2) { test_ssl(2, true); }
|
TORRENT_TEST(utp_config2) { test_ssl(2, true); }
|
||||||
|
@ -633,5 +629,7 @@ TORRENT_TEST(tcp_config5) { test_ssl(5, false); }
|
||||||
TORRENT_TEST(tcp_config6) { test_ssl(6, false); }
|
TORRENT_TEST(tcp_config6) { test_ssl(6, false); }
|
||||||
TORRENT_TEST(tcp_config7) { test_ssl(7, false); }
|
TORRENT_TEST(tcp_config7) { test_ssl(7, false); }
|
||||||
TORRENT_TEST(tcp_config8) { test_ssl(8, false); }
|
TORRENT_TEST(tcp_config8) { test_ssl(8, false); }
|
||||||
#endif
|
#else
|
||||||
|
TORRENT_TEST(disabled) {}
|
||||||
|
#endif // TORRENT_USE_OPENSSL
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue