From 0c16163e71e03ccfeb488589e12b7c18d11a1183 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 29 Jan 2011 12:13:49 +0000 Subject: [PATCH] fix build with no extensions support --- include/libtorrent/bt_peer_connection.hpp | 12 +++++++----- include/libtorrent/torrent_handle.hpp | 1 - src/bt_peer_connection.cpp | 6 ++++-- src/logger.cpp | 2 +- src/lt_trackers.cpp | 3 +++ src/metadata_transfer.cpp | 3 +++ src/peer_connection.cpp | 2 ++ src/smart_ban.cpp | 3 +++ src/torrent.cpp | 2 ++ src/torrent_handle.cpp | 2 ++ src/ut_metadata.cpp | 3 +++ src/ut_pex.cpp | 3 +++ 12 files changed, 33 insertions(+), 9 deletions(-) diff --git a/include/libtorrent/bt_peer_connection.hpp b/include/libtorrent/bt_peer_connection.hpp index 6373cc089..e4617696b 100644 --- a/include/libtorrent/bt_peer_connection.hpp +++ b/include/libtorrent/bt_peer_connection.hpp @@ -170,13 +170,12 @@ namespace libtorrent virtual void get_specific_peer_info(peer_info& p) const; virtual bool in_handshake() const; - bool supports_holepunch() const { return m_holepunch_id != 0; } - void write_holepunch_msg(int type, tcp::endpoint const& ep, int error); - #ifndef TORRENT_DISABLE_EXTENSIONS - bool support_extensions() const { return m_supports_extensions; } + bool supports_holepunch() const { return m_holepunch_id != 0; } #endif + bool support_extensions() const { return m_supports_extensions; } + // the message handlers are called // each time a recv() returns some new // data, the last time it will be called @@ -205,7 +204,9 @@ namespace libtorrent void on_have_none(int received); void on_reject_request(int received); void on_allowed_fast(int received); +#ifndef TORRENT_DISABLE_ENCRYPTION void on_holepunch(); +#endif void on_extended(int received); @@ -229,6 +230,7 @@ namespace libtorrent void write_extensions(); void write_upload_only(); void write_share_mode(); + void write_holepunch_msg(int type, tcp::endpoint const& ep, int error); #endif void write_metadata(std::pair req); void write_metadata_request(std::pair req); @@ -397,11 +399,11 @@ private: int m_share_mode_id; char m_reserved_bits[8]; +#endif // this is set to true if the handshake from // the peer indicated that it supports the // extension protocol bool m_supports_extensions:1; -#endif bool m_supports_dht_port:1; bool m_supports_fast:1; diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index cd3325228..63fbc7af3 100644 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -64,7 +64,6 @@ namespace libtorrent namespace aux { struct session_impl; - struct checker_impl; } struct torrent_plugin; diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index 49ba8da67..9c165c236 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -1439,6 +1439,7 @@ namespace libtorrent // -------- RENDEZVOUS --------- // ----------------------------- +#ifndef TORRENT_DISABLE_EXTENSIONS void bt_peer_connection::on_holepunch() { INVARIANT_CHECK; @@ -1622,6 +1623,7 @@ namespace libtorrent send_buffer(buf, ptr - buf); } +#endif // TORRENT_DISABLE_EXTENSIONS // ----------------------------- // --------- EXTENDED ---------- @@ -1749,7 +1751,6 @@ namespace libtorrent ++i; } if (is_disconnecting()) return; -#endif // upload_only if (lazy_entry const* m = root.dict_find_dict("m")) @@ -1757,6 +1758,7 @@ namespace libtorrent m_upload_only_id = m->dict_find_int_value("upload_only", 0); m_holepunch_id = m->dict_find_int_value("ut_holepunch", 0); } +#endif // there is supposed to be a remote listen port int listen_port = root.dict_find_int_value("p"); @@ -3013,7 +3015,7 @@ namespace libtorrent , (recv_buffer[5] & 0x10) ? "extension " : ""); #endif -#ifndef DISABLE_EXTENSIONS +#ifndef TORRENT_DISABLE_EXTENSIONS std::memcpy(m_reserved_bits, recv_buffer.begin, 8); if ((recv_buffer[5] & 0x10)) m_supports_extensions = true; diff --git a/src/logger.cpp b/src/logger.cpp index f47ac7a77..aaf0082fb 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -49,7 +49,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/entry.hpp" #include "libtorrent/peer_request.hpp" -#if TORRENT_USE_IOSTREAM +#if TORRENT_USE_IOSTREAM && !defined TORRENT_DISABLE_EXTENSIONS #include #include "libtorrent/file.hpp" diff --git a/src/lt_trackers.cpp b/src/lt_trackers.cpp index 446f83652..806a8bf6e 100644 --- a/src/lt_trackers.cpp +++ b/src/lt_trackers.cpp @@ -32,6 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/pch.hpp" +#ifndef TORRENT_DISABLE_EXTENSIONS + #ifdef _MSC_VER #pragma warning(push, 1) #endif @@ -348,4 +350,5 @@ namespace libtorrent } +#endif diff --git a/src/metadata_transfer.cpp b/src/metadata_transfer.cpp index daccb8b90..6955548ee 100644 --- a/src/metadata_transfer.cpp +++ b/src/metadata_transfer.cpp @@ -32,6 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/pch.hpp" +#ifndef TORRENT_DISABLE_EXTENSIONS + #ifdef _MSC_VER #pragma warning(push, 1) #endif @@ -589,4 +591,5 @@ namespace libtorrent } +#endif diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 642ffea96..a97aae7cf 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -3274,6 +3274,7 @@ namespace libtorrent if (m_holepunch_mode) fast_reconnect(true); +#ifndef TORRENT_DISABLE_EXTENSIONS if ((!m_socket->get() || !m_ses.m_settings.enable_outgoing_tcp) && m_peer_info && m_peer_info->supports_holepunch @@ -3285,6 +3286,7 @@ namespace libtorrent if (p) p->write_holepunch_msg(bt_peer_connection::hp_rendezvous, remote(), 0); } +#endif disconnect(e, 1); return; diff --git a/src/smart_ban.cpp b/src/smart_ban.cpp index 2146b6132..50a53535a 100644 --- a/src/smart_ban.cpp +++ b/src/smart_ban.cpp @@ -32,6 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/pch.hpp" +#ifndef TORRENT_DISABLE_EXTENSIONS + #ifdef _MSC_VER #pragma warning(push, 1) #endif @@ -313,4 +315,5 @@ namespace libtorrent } +#endif diff --git a/src/torrent.cpp b/src/torrent.cpp index fd54eac1b..caef15122 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -315,8 +315,10 @@ namespace libtorrent return ret; } +#ifndef TORRENT_DISABLE_EXTENSIONS // defined in ut_pex.cpp bool was_introduced_by(peer_plugin const*, tcp::endpoint const&); +#endif torrent::torrent( session_impl& ses diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index f25192f52..a4c81361c 100644 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -328,6 +328,7 @@ namespace libtorrent TORRENT_ASYNC_CALL2(rename_file, index, new_name); } +#ifndef TORRENT_DISABLE_EXTENSIONS void torrent_handle::add_extension( boost::function(torrent*, void*)> const& ext , void* userdata) @@ -335,6 +336,7 @@ namespace libtorrent INVARIANT_CHECK; TORRENT_ASYNC_CALL2(add_extension, ext, userdata); } +#endif bool torrent_handle::set_metadata(char const* metadata, int size) const { diff --git a/src/ut_metadata.cpp b/src/ut_metadata.cpp index 74812b0e9..ce258965d 100644 --- a/src/ut_metadata.cpp +++ b/src/ut_metadata.cpp @@ -32,6 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/pch.hpp" +#ifndef TORRENT_DISABLE_EXTENSIONS + #ifdef _MSC_VER #pragma warning(push, 1) #endif @@ -538,4 +540,5 @@ namespace libtorrent } +#endif diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index 70e28b815..5bf1615b8 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -32,6 +32,8 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/pch.hpp" +#ifndef TORRENT_DISABLE_EXTENSIONS + #ifdef _MSC_VER #pragma warning(push, 1) #endif @@ -582,4 +584,5 @@ namespace libtorrent } } +#endif