more boost types cleanup and handling of deprecated macos libcrypto (#1072)

more boost types cleanup and handling of deprecated macos libcrypto. more granular TORRENT_MACOS_DEPRECATED_LIBCRYPTO
This commit is contained in:
Alden Torres 2016-09-07 17:51:18 -04:00 committed by Arvid Norberg
parent 4c53d7b2da
commit 01e9810f7a
24 changed files with 171 additions and 96 deletions

View File

@ -79,7 +79,7 @@ install:
- 'if [[ $toolset == "gcc-arm" ]]; then - 'if [[ $toolset == "gcc-arm" ]]; then
echo "using gcc : arm : ccache armv8l-linux-gnueabihf-g++ : <cxxflags>\"-std=c++11 -fsigned-char -march=armv8-a+crc -mfpu=crypto-neon-fp-armv8 -DTORRENT_FORCE_ARM_CRC32\" <linkflags>-lm ;" >> ~/user-config.jam; echo "using gcc : arm : ccache armv8l-linux-gnueabihf-g++ : <cxxflags>\"-std=c++11 -fsigned-char -march=armv8-a+crc -mfpu=crypto-neon-fp-armv8 -DTORRENT_FORCE_ARM_CRC32\" <linkflags>-lm ;" >> ~/user-config.jam;
fi;' fi;'
- 'echo "using darwin : : ccache clang++ : <cflags>-std=c11 <cxxflags>-std=c++11 <compileflags>-Wno-deprecated-declarations ;" >> ~/user-config.jam' - 'echo "using darwin : : ccache clang++ : <cflags>-std=c11 <cxxflags>-std=c++11 ;" >> ~/user-config.jam'
- 'echo "using python : 2.7 ;" >> ~/user-config.jam' - 'echo "using python : 2.7 ;" >> ~/user-config.jam'
- if [ "$docs" == "1" ]; then rst2html.py --version; fi - if [ "$docs" == "1" ]; then rst2html.py --version; fi

View File

@ -33,6 +33,22 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_OPENSSL_HPP_INCLUDED #ifndef TORRENT_OPENSSL_HPP_INCLUDED
#define TORRENT_OPENSSL_HPP_INCLUDED #define TORRENT_OPENSSL_HPP_INCLUDED
#ifdef TORRENT_USE_LIBCRYPTO
#include "libtorrent/config.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <openssl/opensslv.h> // for OPENSSL_VERSION_NUMBER
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#if defined __APPLE__ \
&& MAC_OS_X_VERSION_MIN_REQUIRED >= 1070 \
&& OPENSSL_VERSION_NUMBER <= 0x009081dfL
#define TORRENT_MACOS_DEPRECATED_LIBCRYPTO 1
#endif
#endif // TORRENT_USE_LIBCRYPTO
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
// all of OpenSSL causes warnings, so we just have to disable them // all of OpenSSL causes warnings, so we just have to disable them

View File

@ -105,11 +105,7 @@ namespace libtorrent
address_v4 broadcast_address() const address_v4 broadcast_address() const
{ {
error_code ec; error_code ec;
#if BOOST_VERSION < 104700
return address_v4(socket->local_endpoint(ec).address().to_v4().to_ulong() | ((~netmask.to_ulong()) & 0xffffffff));
#else
return address_v4::broadcast(socket->local_endpoint(ec).address().to_v4(), netmask); return address_v4::broadcast(socket->local_endpoint(ec).address().to_v4(), netmask);
#endif
} }
}; };

View File

@ -39,7 +39,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/config.hpp> #include <boost/config.hpp>
#include <boost/asio/detail/config.hpp> #include <boost/asio/detail/config.hpp>
#include <boost/version.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/aux_/disable_warnings_pop.hpp"

View File

@ -211,4 +211,3 @@ namespace libtorrent
} }
#endif // TORRENT_DEBUG_HPP_INCLUDED #endif // TORRENT_DEBUG_HPP_INCLUDED

View File

@ -54,4 +54,3 @@ namespace libtorrent
} }
#endif #endif

View File

@ -111,4 +111,3 @@ namespace libtorrent
file m_file; file m_file;
}; };
} }

View File

@ -85,11 +85,11 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_SOCKTYPE_SSL_FORWARD_RET(x, def) \ #define TORRENT_SOCKTYPE_SSL_FORWARD_RET(x, def) \
case socket_type_int_impl<ssl_stream<tcp::socket>>::value: \ case socket_type_int_impl<ssl_stream<tcp::socket>>::value: \
return get<ssl_stream<tcp::socket> >()->x; \ return get<ssl_stream<tcp::socket>>()->x; \
case socket_type_int_impl<ssl_stream<socks5_stream>>::value: \ case socket_type_int_impl<ssl_stream<socks5_stream>>::value: \
return get<ssl_stream<socks5_stream> >()->x; \ return get<ssl_stream<socks5_stream>>()->x; \
case socket_type_int_impl<ssl_stream<http_stream>>::value: \ case socket_type_int_impl<ssl_stream<http_stream>>::value: \
return get<ssl_stream<http_stream> >()->x; \ return get<ssl_stream<http_stream>>()->x; \
case socket_type_int_impl<ssl_stream<utp_stream>>::value: \ case socket_type_int_impl<ssl_stream<utp_stream>>::value: \
return get<ssl_stream<utp_stream>>()->x; return get<ssl_stream<utp_stream>>()->x;

View File

@ -41,7 +41,7 @@ inline libtorrent::aux::proxy_settings make_proxy_settings(
using namespace libtorrent; using namespace libtorrent;
aux::proxy_settings ps; aux::proxy_settings ps;
ps.type = boost::uint8_t(proxy_type); ps.type = std::uint8_t(proxy_type);
ps.proxy_hostnames = false; ps.proxy_hostnames = false;
// this IP and ports are specific to test_http_connection.cpp // this IP and ports are specific to test_http_connection.cpp
if (proxy_type != settings_pack::none) if (proxy_type != settings_pack::none)
@ -55,4 +55,3 @@ inline libtorrent::aux::proxy_settings make_proxy_settings(
} }
#endif #endif

View File

@ -85,8 +85,8 @@ TORRENT_TEST(optimistic_unchoke)
auto ses = std::make_shared<lt::session>(std::ref(pack), std::ref(ios)); auto ses = std::make_shared<lt::session>(std::ref(pack), std::ref(ios));
ses->async_add_torrent(atp); ses->async_add_torrent(atp);
std::vector<std::shared_ptr<sim::asio::io_service> > io_service; std::vector<std::shared_ptr<sim::asio::io_service>> io_service;
std::vector<std::shared_ptr<peer_conn> > peers; std::vector<std::shared_ptr<peer_conn>> peers;
print_alerts(*ses); print_alerts(*ses);
@ -129,7 +129,7 @@ TORRENT_TEST(optimistic_unchoke)
char const* msg_str[] = {"choke", "unchoke"}; char const* msg_str[] = {"choke", "unchoke"};
lt::time_duration d = lt::clock_type::now() - start_time; lt::time_duration d = lt::clock_type::now() - start_time;
std::uint32_t const millis = boost::uint32_t( std::uint32_t const millis = std::uint32_t(
lt::duration_cast<lt::milliseconds>(d).count()); lt::duration_cast<lt::milliseconds>(d).count());
printf("\x1b[35m%4d.%03d: [%d] %s (%d ms)\x1b[0m\n" printf("\x1b[35m%4d.%03d: [%d] %s (%d ms)\x1b[0m\n"
, millis / 1000, millis % 1000, i, msg_str[msg] , millis / 1000, millis % 1000, i, msg_str[msg]
@ -168,4 +168,3 @@ TORRENT_TEST(optimistic_unchoke)
TEST_CHECK(std::abs(unchoke_duration - average_unchoke_time) < 1500); TEST_CHECK(std::abs(unchoke_duration - average_unchoke_time) < 1500);
} }
} }

View File

@ -84,7 +84,7 @@ int get_cache_size(lt::session& ses)
ses.post_session_stats(); ses.post_session_stats();
std::vector<alert*> alerts; std::vector<alert*> alerts;
ses.pop_alerts(&alerts); ses.pop_alerts(&alerts);
boost::int64_t cache_size = -1; std::int64_t cache_size = -1;
for (auto const a : alerts) for (auto const a : alerts)
{ {
if (auto const* st = alert_cast<session_stats_alert>(a)) if (auto const* st = alert_cast<session_stats_alert>(a))
@ -146,4 +146,3 @@ std::unique_ptr<sim::asio::io_service> make_io_service(sim::simulation& sim, int
return std::unique_ptr<sim::asio::io_service>(new sim::asio::io_service( return std::unique_ptr<sim::asio::io_service>(new sim::asio::io_service(
sim, lt::address_v4::from_string(ep))); sim, lt::address_v4::from_string(ep)));
} }

View File

@ -258,27 +258,27 @@ namespace libtorrent
++m_outstanding_operations; ++m_outstanding_operations;
} }
void broadcast_socket::send(char const* buffer, int size, error_code& ec, int flags) void broadcast_socket::send(char const* buffer, int const size
, error_code& ec, int const flags)
{ {
bool all_fail = true; bool all_fail = true;
error_code e; error_code e;
for (std::list<socket_entry>::iterator i = m_unicast_sockets.begin() for (auto& s : m_unicast_sockets)
, end(m_unicast_sockets.end()); i != end; ++i)
{ {
if (!i->socket) continue; if (!s.socket) continue;
i->socket->send_to(boost::asio::buffer(buffer, size), m_multicast_endpoint, 0, e); s.socket->send_to(boost::asio::buffer(buffer, size), m_multicast_endpoint, 0, e);
// if the user specified the broadcast flag, send one to the broadcast // if the user specified the broadcast flag, send one to the broadcast
// address as well // address as well
if ((flags & broadcast_socket::flag_broadcast) && i->can_broadcast()) if ((flags & broadcast_socket::flag_broadcast) && s.can_broadcast())
i->socket->send_to(boost::asio::buffer(buffer, size) s.socket->send_to(boost::asio::buffer(buffer, size)
, udp::endpoint(i->broadcast_address(), m_multicast_endpoint.port()), 0, e); , udp::endpoint(s.broadcast_address(), m_multicast_endpoint.port()), 0, e);
if (e) if (e)
{ {
i->socket->close(e); s.socket->close(e);
i->socket.reset(); s.socket.reset();
} }
else else
{ {
@ -286,15 +286,14 @@ namespace libtorrent
} }
} }
for (std::list<socket_entry>::iterator i = m_sockets.begin() for (auto& s : m_sockets)
, end(m_sockets.end()); i != end; ++i)
{ {
if (!i->socket) continue; if (!s.socket) continue;
i->socket->send_to(boost::asio::buffer(buffer, size), m_multicast_endpoint, 0, e); s.socket->send_to(boost::asio::buffer(buffer, size), m_multicast_endpoint, 0, e);
if (e) if (e)
{ {
i->socket->close(e); s.socket->close(e);
i->socket.reset(); s.socket.reset();
} }
else else
{ {

View File

@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/hasher.hpp" #include "libtorrent/hasher.hpp"
#include "libtorrent/error_code.hpp" #include "libtorrent/error_code.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/aux_/openssl.hpp"
#if TORRENT_USE_CRYPTOAPI #if TORRENT_USE_CRYPTOAPI
namespace namespace
@ -64,6 +65,11 @@ namespace
namespace libtorrent namespace libtorrent
{ {
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
hasher::hasher() hasher::hasher()
{ {
#ifdef TORRENT_USE_LIBGCRYPT #ifdef TORRENT_USE_LIBGCRYPT
@ -233,4 +239,8 @@ namespace libtorrent
gcry_md_close(m_context); gcry_md_close(m_context);
#endif #endif
} }
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif
} }

View File

@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/hasher512.hpp" #include "libtorrent/hasher512.hpp"
#include "libtorrent/error_code.hpp" #include "libtorrent/error_code.hpp"
#include "libtorrent/assert.hpp" #include "libtorrent/assert.hpp"
#include "libtorrent/aux_/openssl.hpp"
#if TORRENT_USE_CRYPTOAPI #if TORRENT_USE_CRYPTOAPI
namespace namespace
@ -64,6 +65,11 @@ namespace
namespace libtorrent namespace libtorrent
{ {
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
hasher512::hasher512() hasher512::hasher512()
{ {
#ifdef TORRENT_USE_LIBGCRYPT #ifdef TORRENT_USE_LIBGCRYPT
@ -221,4 +227,8 @@ namespace libtorrent
gcry_md_close(m_context); gcry_md_close(m_context);
#endif #endif
} }
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif
} }

View File

@ -57,8 +57,8 @@ namespace libtorrent
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
if (ssl_context) if (ssl_context)
{ {
s.instantiate<ssl_stream<utp_stream> >(ios, ssl_context); s.instantiate<ssl_stream<utp_stream>>(ios, ssl_context);
str = &s.get<ssl_stream<utp_stream> >()->next_layer(); str = &s.get<ssl_stream<utp_stream>>()->next_layer();
} }
else else
#endif #endif
@ -84,7 +84,7 @@ namespace libtorrent
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
if (ssl_context) if (ssl_context)
{ {
s.instantiate<ssl_stream<tcp::socket> >(ios, ssl_context); s.instantiate<ssl_stream<tcp::socket>>(ios, ssl_context);
} }
else else
#endif #endif
@ -99,8 +99,8 @@ namespace libtorrent
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
if (ssl_context) if (ssl_context)
{ {
s.instantiate<ssl_stream<http_stream> >(ios, ssl_context); s.instantiate<ssl_stream<http_stream>>(ios, ssl_context);
str = &s.get<ssl_stream<http_stream> >()->next_layer(); str = &s.get<ssl_stream<http_stream>>()->next_layer();
} }
else else
#endif #endif
@ -121,8 +121,8 @@ namespace libtorrent
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
if (ssl_context) if (ssl_context)
{ {
s.instantiate<ssl_stream<socks5_stream> >(ios, ssl_context); s.instantiate<ssl_stream<socks5_stream>>(ios, ssl_context);
str = &s.get<ssl_stream<socks5_stream> >()->next_layer(); str = &s.get<ssl_stream<socks5_stream>>()->next_layer();
} }
else else
#endif #endif
@ -145,4 +145,3 @@ namespace libtorrent
} }
} }

View File

@ -90,7 +90,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb
, m_log_cb(log) , m_log_cb(log)
#endif #endif
, m_broadcast_timer(ios) , m_broadcast_timer(ios)
, m_cookie((random(0x7fffffff) ^ boost::uintptr_t(this)) & 0x7fffffff) , m_cookie((random(0x7fffffff) ^ std::uintptr_t(this)) & 0x7fffffff)
, m_disabled(false) , m_disabled(false)
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
, m_disabled6(false) , m_disabled6(false)

View File

@ -330,7 +330,7 @@ namespace libtorrent
TORRENT_ASSERT(!ec); TORRENT_ASSERT(!ec);
if (ec || v.iov_len == 0) return; if (ec || v.iov_len == 0) return;
boost::int64_t ret = f.writev(file_offset, &v, 1, ec); std::int64_t ret = f.writev(file_offset, &v, 1, ec);
TORRENT_ASSERT(ec || ret == v.iov_len); TORRENT_ASSERT(ec || ret == v.iov_len);
if (ec || ret != v.iov_len) return; if (ec || ret != v.iov_len) return;
@ -409,11 +409,10 @@ namespace libtorrent
slot = i->second; slot = i->second;
write_uint32(slot, ptr); write_uint32(slot, ptr);
} }
memset(ptr, 0, m_header_size - (ptr - reinterpret_cast<char*>(header.get()))); std::memset(ptr, 0, m_header_size - (ptr - reinterpret_cast<char*>(header.get())));
file::iovec_t b = {header.get(), size_t(m_header_size) }; file::iovec_t b = {header.get(), size_t(m_header_size) };
m_file.writev(0, &b, 1, ec); m_file.writev(0, &b, 1, ec);
if (ec) return; if (ec) return;
} }
} }

View File

@ -5888,10 +5888,17 @@ namespace libtorrent
#endif #endif
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
// add this RTT to the PRNG seed, to add more unpredictability // add this RTT to the PRNG seed, to add more unpredictability
std::uint64_t now = total_microseconds(completed - m_connect); std::uint64_t now = total_microseconds(completed - m_connect);
// assume 12 bits of entropy (i.e. about 8 milliseconds) // assume 12 bits of entropy (i.e. about 8 milliseconds)
RAND_add(&now, 8, 1.5); RAND_add(&now, 8, 1.5);
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif
#endif #endif
// if t is nullptr, we better not be connecting, since // if t is nullptr, we better not be connecting, since

View File

@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp" #include "libtorrent/config.hpp"
#include "libtorrent/random.hpp" #include "libtorrent/random.hpp"
#include "libtorrent/error_code.hpp" #include "libtorrent/error_code.hpp"
#include "libtorrent/aux_/openssl.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp" #include "libtorrent/aux_/disable_warnings_push.hpp"
@ -94,6 +95,10 @@ namespace libtorrent
CryptReleaseContext(prov, 0); CryptReleaseContext(prov, 0);
#elif defined TORRENT_USE_LIBCRYPTO #elif defined TORRENT_USE_LIBCRYPTO
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
int r = RAND_bytes(reinterpret_cast<unsigned char*>(buffer.data()) int r = RAND_bytes(reinterpret_cast<unsigned char*>(buffer.data())
, int(buffer.size())); , int(buffer.size()));
if (r != 1) if (r != 1)
@ -104,6 +109,9 @@ namespace libtorrent
std::terminate(); std::terminate();
#endif #endif
} }
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif
#else #else
std::uint32_t s = random(0xffffffff); std::uint32_t s = random(0xffffffff);
std::independent_bits_engine<std::mt19937, 8, std::uint8_t> generator(s); std::independent_bits_engine<std::mt19937, 8, std::uint8_t> generator(s);

View File

@ -156,7 +156,14 @@ namespace
// structures it allocates // structures it allocates
struct openssl_cleanup struct openssl_cleanup
{ {
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
~openssl_cleanup() { CRYPTO_cleanup_all_ex_data(); } ~openssl_cleanup() { CRYPTO_cleanup_all_ex_data(); }
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif
} openssl_global_destructor; } openssl_global_destructor;
} }
@ -254,6 +261,10 @@ namespace aux {
} }
#if defined TORRENT_USE_OPENSSL && OPENSSL_VERSION_NUMBER >= 0x90812f #if defined TORRENT_USE_OPENSSL && OPENSSL_VERSION_NUMBER >= 0x90812f
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
namespace { namespace {
// when running bittorrent over SSL, the SNI (server name indication) // when running bittorrent over SSL, the SNI (server name indication)
// extension is used to know which torrent the incoming connection is // extension is used to know which torrent the incoming connection is
@ -298,6 +309,9 @@ namespace aux {
return SSL_TLSEXT_ERR_OK; return SSL_TLSEXT_ERR_OK;
} }
} // anonymous namespace } // anonymous namespace
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif
#endif #endif
session_impl::session_impl(io_service& ios) session_impl::session_impl(io_service& ios)
@ -2552,11 +2566,18 @@ namespace aux {
TORRENT_ASSERT(is_single_thread()); TORRENT_ASSERT(is_single_thread());
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
// add the current time to the PRNG, to add more unpredictability // add the current time to the PRNG, to add more unpredictability
std::uint64_t now = clock_type::now().time_since_epoch().count(); std::uint64_t now = clock_type::now().time_since_epoch().count();
// assume 12 bits of entropy (i.e. about 8 milliseconds) // assume 12 bits of entropy (i.e. about 8 milliseconds)
RAND_add(&now, 8, 1.5); RAND_add(&now, 8, 1.5);
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif #endif
#endif // TORRENT_USE_OPENSSL
if (m_paused) if (m_paused)
{ {

View File

@ -48,7 +48,7 @@ namespace libtorrent
bool is_ssl(socket_type const& s) bool is_ssl(socket_type const& s)
{ {
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
#define CASE(t) case socket_type_int_impl<ssl_stream<t> >::value: #define CASE(t) case socket_type_int_impl<ssl_stream<t>>::value:
switch (s.type()) switch (s.type())
{ {
CASE(tcp::socket) CASE(tcp::socket)
@ -69,7 +69,7 @@ namespace libtorrent
{ {
return s.get<utp_stream>() != nullptr return s.get<utp_stream>() != nullptr
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
|| s.get<ssl_stream<utp_stream> >() != nullptr || s.get<ssl_stream<utp_stream>>() != nullptr
#endif #endif
; ;
} }
@ -79,7 +79,7 @@ namespace libtorrent
{ {
return s.get<i2p_stream>() != nullptr return s.get<i2p_stream>() != nullptr
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
|| s.get<ssl_stream<i2p_stream> >() != nullptr || s.get<ssl_stream<i2p_stream>>() != nullptr
#endif #endif
; ;
} }
@ -87,13 +87,17 @@ namespace libtorrent
void setup_ssl_hostname(socket_type& s, std::string const& hostname, error_code& ec) void setup_ssl_hostname(socket_type& s, std::string const& hostname, error_code& ec)
{ {
#if defined TORRENT_USE_OPENSSL && BOOST_VERSION >= 104700 #if defined TORRENT_USE_OPENSSL
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
// for SSL connections, make sure to authenticate the hostname // for SSL connections, make sure to authenticate the hostname
// of the certificate // of the certificate
#define CASE(t) case socket_type_int_impl<ssl_stream<t> >::value: \ #define CASE(t) case socket_type_int_impl<ssl_stream<t>>::value: \
s.get<ssl_stream<t> >()->set_verify_callback( \ s.get<ssl_stream<t>>()->set_verify_callback( \
boost::asio::ssl::rfc2818_verification(hostname), ec); \ boost::asio::ssl::rfc2818_verification(hostname), ec); \
ssl = s.get<ssl_stream<t> >()->native_handle(); \ ssl = s.get<ssl_stream<t>>()->native_handle(); \
ctx = SSL_get_SSL_CTX(ssl); \ ctx = SSL_get_SSL_CTX(ssl); \
break; break;
@ -128,6 +132,9 @@ namespace libtorrent
TORRENT_UNUSED(ec); TORRENT_UNUSED(ec);
TORRENT_UNUSED(hostname); TORRENT_UNUSED(hostname);
TORRENT_UNUSED(s); TORRENT_UNUSED(s);
#endif
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif #endif
} }
@ -330,8 +337,8 @@ namespace libtorrent
get<utp_stream>()->set_close_reason(code); get<utp_stream>()->set_close_reason(code);
break; break;
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
case socket_type_int_impl<ssl_stream<utp_stream> >::value: case socket_type_int_impl<ssl_stream<utp_stream>>::value:
get<ssl_stream<utp_stream> >()->lowest_layer().set_close_reason(code); get<ssl_stream<utp_stream>>()->lowest_layer().set_close_reason(code);
break; break;
#endif #endif
default: break; default: break;
@ -346,7 +353,7 @@ namespace libtorrent
return get<utp_stream>()->get_close_reason(); return get<utp_stream>()->get_close_reason();
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
case socket_type_int_impl<ssl_stream<utp_stream>>::value: case socket_type_int_impl<ssl_stream<utp_stream>>::value:
return get<ssl_stream<utp_stream> >()->lowest_layer().get_close_reason(); return get<ssl_stream<utp_stream>>()->lowest_layer().get_close_reason();
#endif #endif
default: return 0; default: return 0;
} }

View File

@ -1444,6 +1444,10 @@ namespace libtorrent
#endif #endif
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
bool torrent::verify_peer_cert(bool preverified, boost::asio::ssl::verify_context& ctx) bool torrent::verify_peer_cert(bool preverified, boost::asio::ssl::verify_context& ctx)
{ {
@ -1645,7 +1649,9 @@ namespace libtorrent
// tell the client we need a cert for this torrent // tell the client we need a cert for this torrent
alerts().emplace_alert<torrent_need_cert_alert>(get_handle()); alerts().emplace_alert<torrent_need_cert_alert>(get_handle());
} }
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif
#endif // TORRENT_OPENSSL #endif // TORRENT_OPENSSL
void torrent::construct_storage() void torrent::construct_storage()
@ -1908,9 +1914,9 @@ namespace libtorrent
for (std::vector<std::string>::iterator i = c.begin(), end(c.end()); for (std::vector<std::string>::iterator i = c.begin(), end(c.end());
i != end; ++i) i != end; ++i)
{ {
std::vector<std::shared_ptr<torrent> > ts = m_ses.find_collection(*i); std::vector<std::shared_ptr<torrent>> ts = m_ses.find_collection(*i);
for (std::vector<std::shared_ptr<torrent> >::iterator k = ts.begin() for (std::vector<std::shared_ptr<torrent>>::iterator k = ts.begin()
, end2(ts.end()); k != end2; ++k) , end2(ts.end()); k != end2; ++k)
{ {
// Only attempt to reuse files from torrents that are seeding. // Only attempt to reuse files from torrents that are seeding.
@ -5008,7 +5014,7 @@ namespace libtorrent
return m_picker->piece_priority(index); return m_picker->piece_priority(index);
} }
void torrent::prioritize_piece_list(std::vector<std::pair<int, int> > const& pieces) void torrent::prioritize_piece_list(std::vector<std::pair<int, int>> const& pieces)
{ {
INVARIANT_CHECK; INVARIANT_CHECK;
@ -5020,18 +5026,17 @@ namespace libtorrent
bool filter_updated = false; bool filter_updated = false;
bool was_finished = is_finished(); bool was_finished = is_finished();
for (std::vector<std::pair<int, int> >::const_iterator i = pieces.begin() for (auto const& p : pieces)
, end(pieces.end()); i != end; ++i)
{ {
TORRENT_ASSERT(i->second >= 0); TORRENT_ASSERT(p.second >= 0);
TORRENT_ASSERT(i->second <= 7); TORRENT_ASSERT(p.second <= 7);
TORRENT_ASSERT(i->first >= 0); TORRENT_ASSERT(p.first >= 0);
TORRENT_ASSERT(i->first < m_torrent_file->num_pieces()); TORRENT_ASSERT(p.first < m_torrent_file->num_pieces());
if (i->first < 0 || i->first >= m_torrent_file->num_pieces() || i->second < 0 || i->second > 7) if (p.first < 0 || p.first >= m_torrent_file->num_pieces() || p.second < 0 || p.second > 7)
continue; continue;
filter_updated |= m_picker->set_piece_priority(i->first, i->second); filter_updated |= m_picker->set_piece_priority(p.first, p.second);
TORRENT_ASSERT(num_have() >= m_picker->num_have_filtered()); TORRENT_ASSERT(num_have() >= m_picker->num_have_filtered());
} }
update_gauge(); update_gauge();
@ -5773,7 +5778,7 @@ namespace libtorrent
#endif #endif
peer_connection* peer = static_cast<peer_connection*>(web->peer_info.connection); peer_connection* peer = static_cast<peer_connection*>(web->peer_info.connection);
if (peer) if (peer != nullptr)
{ {
// if we have a connection for this web seed, we also need to // if we have a connection for this web seed, we also need to
// disconnect it and clear its reference to the peer_info object // disconnect it and clear its reference to the peer_info object
@ -6148,7 +6153,7 @@ namespace libtorrent
if (proxy_hostnames if (proxy_hostnames
&& (s->get<socks5_stream>() && (s->get<socks5_stream>()
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
|| s->get<ssl_stream<socks5_stream> >() || s->get<ssl_stream<socks5_stream>>()
#endif #endif
)) ))
{ {
@ -6156,7 +6161,7 @@ namespace libtorrent
// hostnames through it // hostnames through it
socks5_stream* str = socks5_stream* str =
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
ssl ? &s->get<ssl_stream<socks5_stream> >()->next_layer() : ssl ? &s->get<ssl_stream<socks5_stream>>()->next_layer() :
#endif #endif
s->get<socks5_stream>(); s->get<socks5_stream>();
TORRENT_ASSERT_VAL(str, s->type_name()); TORRENT_ASSERT_VAL(str, s->type_name());
@ -6698,7 +6703,7 @@ namespace libtorrent
} }
else else
{ {
torrent_peer* tp = static_cast<torrent_peer*>(info[j].peer); torrent_peer* tp = info[j].peer;
TORRENT_ASSERT(tp->in_use); TORRENT_ASSERT(tp->in_use);
if (tp->connection) if (tp->connection)
{ {
@ -7036,6 +7041,10 @@ namespace libtorrent
// INVARIANT_CHECK; // INVARIANT_CHECK;
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#endif
if (is_ssl_torrent()) if (is_ssl_torrent())
{ {
// if this is an SSL torrent, don't allow non SSL peers on it // if this is an SSL torrent, don't allow non SSL peers on it
@ -7083,6 +7092,9 @@ namespace libtorrent
return false; return false;
} }
} }
#ifdef TORRENT_MACOS_DEPRECATED_LIBCRYPTO
#pragma clang diagnostic pop
#endif
#else // TORRENT_USE_OPENSSL #else // TORRENT_USE_OPENSSL
if (is_ssl_torrent()) if (is_ssl_torrent())
{ {
@ -7724,10 +7736,10 @@ namespace libtorrent
TORRENT_ASSERT(index < int(m_trackers.size())); TORRENT_ASSERT(index < int(m_trackers.size()));
if (index >= int(m_trackers.size())) return -1; if (index >= int(m_trackers.size())) return -1;
while (index > 0 && m_trackers[index].tier == m_trackers[index-1].tier) while (index > 0 && m_trackers[index].tier == m_trackers[index - 1].tier)
{ {
using std::swap; using std::swap;
swap(m_trackers[index], m_trackers[index-1]); swap(m_trackers[index], m_trackers[index - 1]);
if (m_last_working_tracker == index) --m_last_working_tracker; if (m_last_working_tracker == index) --m_last_working_tracker;
else if (m_last_working_tracker == index - 1) ++m_last_working_tracker; else if (m_last_working_tracker == index - 1) ++m_last_working_tracker;
--index; --index;
@ -10153,7 +10165,7 @@ namespace libtorrent
, timed_out); , timed_out);
#endif #endif
// if requested is 0, it meants all blocks have been received, and // if requested is 0, it means all blocks have been received, and
// we're just waiting for it to flush them to disk. // we're just waiting for it to flush them to disk.
// if last_requested is recent enough, we should give it some // if last_requested is recent enough, we should give it some
// more time // more time

View File

@ -375,9 +375,9 @@ namespace libtorrent
namespace { namespace {
boost::uint32_t get_file_attributes(bdecode_node const& dict) std::uint32_t get_file_attributes(bdecode_node const& dict)
{ {
boost::uint32_t file_flags = 0; std::uint32_t file_flags = 0;
bdecode_node attr = dict.dict_find_string("attr"); bdecode_node attr = dict.dict_find_string("attr");
if (attr) if (attr)
{ {
@ -397,7 +397,7 @@ namespace libtorrent
// iterates an array of strings and returns the sum of the lengths of all // iterates an array of strings and returns the sum of the lengths of all
// strings + one additional character per entry (to account for the presumed // strings + one additional character per entry (to account for the presumed
// forward- or backslash to seaprate directory entries) // forward- or backslash to separate directory entries)
int path_length(bdecode_node const& p, error_code& ec) int path_length(bdecode_node const& p, error_code& ec)
{ {
int ret = 0; int ret = 0;
@ -426,11 +426,11 @@ namespace libtorrent
{ {
if (dict.type() != bdecode_node::dict_t) return false; if (dict.type() != bdecode_node::dict_t) return false;
boost::uint32_t file_flags = get_file_attributes(dict); std::uint32_t file_flags = get_file_attributes(dict);
// symlinks have an implied "size" of zero. i.e. they use up 0 bytes of // symlinks have an implied "size" of zero. i.e. they use up 0 bytes of
// the torrent payload space // the torrent payload space
boost::int64_t const file_size = (file_flags & file_storage::flag_symlink) std::int64_t const file_size = (file_flags & file_storage::flag_symlink)
? 0 ? 0
: dict.dict_find_int_value("length", -1); : dict.dict_find_int_value("length", -1);
if (file_size < 0 ) if (file_size < 0 )
@ -439,10 +439,9 @@ namespace libtorrent
return false; return false;
} }
boost::int64_t const mtime = dict.dict_find_int_value("mtime", 0); std::int64_t const mtime = dict.dict_find_int_value("mtime", 0);
std::string path = root_dir; std::string path = root_dir;
std::string path_element;
char const* filename = nullptr; char const* filename = nullptr;
int filename_len = 0; int filename_len = 0;
@ -1488,7 +1487,7 @@ namespace libtorrent
{ {
web_seed_entry ent(maybe_url_encode(url_seeds.string_value().to_string()) web_seed_entry ent(maybe_url_encode(url_seeds.string_value().to_string())
, web_seed_entry::url_seed); , web_seed_entry::url_seed);
if ((m_flags & multifile) && ent.url[ent.url.size()-1] != '/') ent.url += '/'; if ((m_flags & multifile) && ent.url[ent.url.size() - 1] != '/') ent.url += '/';
m_web_seeds.push_back(ent); m_web_seeds.push_back(ent);
} }
else if (url_seeds && url_seeds.type() == bdecode_node::list_t) else if (url_seeds && url_seeds.type() == bdecode_node::list_t)
@ -1502,7 +1501,7 @@ namespace libtorrent
if (url.string_length() == 0) continue; if (url.string_length() == 0) continue;
web_seed_entry ent(maybe_url_encode(url.string_value().to_string()) web_seed_entry ent(maybe_url_encode(url.string_value().to_string())
, web_seed_entry::url_seed); , web_seed_entry::url_seed);
if ((m_flags & multifile) && ent.url[ent.url.size()-1] != '/') ent.url += '/'; if ((m_flags & multifile) && ent.url[ent.url.size() - 1] != '/') ent.url += '/';
if (unique.count(ent.url)) continue; if (unique.count(ent.url)) continue;
unique.insert(ent.url); unique.insert(ent.url);
m_web_seeds.push_back(ent); m_web_seeds.push_back(ent);
@ -1675,4 +1674,3 @@ namespace libtorrent
#endif #endif
} }

View File

@ -98,7 +98,7 @@ sha1_hash rand_hash()
{ {
sha1_hash ret; sha1_hash ret;
for (int i = 0; i < 20; ++i) for (int i = 0; i < 20; ++i)
ret[i] = boost::uint8_t(lt::random(0xff)); ret[i] = std::uint8_t(lt::random(0xff));
return ret; return ret;
} }
@ -107,7 +107,7 @@ address rand_v6()
{ {
address_v6::bytes_type bytes; address_v6::bytes_type bytes;
for (int i = 0; i < int(bytes.size()); ++i) for (int i = 0; i < int(bytes.size()); ++i)
bytes[i] = boost::uint8_t(lt::random(0xff)); bytes[i] = std::uint8_t(lt::random(0xff));
return address_v6(bytes); return address_v6(bytes);
} }
#endif #endif
@ -542,7 +542,7 @@ int start_proxy(int proxy_type)
s.open(tcp::v4(), ec); s.open(tcp::v4(), ec);
if (ec) break; if (ec) break;
s.bind(tcp::endpoint(address::from_string("127.0.0.1") s.bind(tcp::endpoint(address::from_string("127.0.0.1")
, boost::uint16_t(port)), ec); , std::uint16_t(port)), ec);
} while (ec); } while (ec);
@ -749,7 +749,7 @@ std::shared_ptr<torrent_info> create_torrent(std::ostream* file
} }
std::vector<char> tmp; std::vector<char> tmp;
std::back_insert_iterator<std::vector<char> > out(tmp); std::back_insert_iterator<std::vector<char>> out(tmp);
entry tor = t.generate(); entry tor = t.generate();
@ -919,7 +919,7 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
std::fprintf(stderr, "%s: ses1: connecting peer port: %d\n" std::fprintf(stderr, "%s: ses1: connecting peer port: %d\n"
, time_now_string(), port); , time_now_string(), port);
tor1.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec) tor1.connect_peer(tcp::endpoint(address::from_string("127.0.0.1", ec)
, boost::uint16_t(port))); , std::uint16_t(port)));
if (ses3) if (ses3)
{ {
@ -941,11 +941,11 @@ setup_transfer(lt::session* ses1, lt::session* ses2, lt::session* ses3
std::fprintf(stderr, "ses3: connecting peer port: %d\n", port); std::fprintf(stderr, "ses3: connecting peer port: %d\n", port);
tor3.connect_peer(tcp::endpoint( tor3.connect_peer(tcp::endpoint(
address::from_string("127.0.0.1", ec), boost::uint16_t(port))); address::from_string("127.0.0.1", ec), std::uint16_t(port)));
std::fprintf(stderr, "ses3: connecting peer port: %d\n", port2); std::fprintf(stderr, "ses3: connecting peer port: %d\n", port2);
tor3.connect_peer(tcp::endpoint( tor3.connect_peer(tcp::endpoint(
address::from_string("127.0.0.1", ec) address::from_string("127.0.0.1", ec)
, boost::uint16_t(port2))); , std::uint16_t(port2)));
} }
} }
@ -967,7 +967,7 @@ int start_web_server(bool ssl, bool chunked_encoding, bool keepalive)
s.open(tcp::v4(), ec); s.open(tcp::v4(), ec);
if (ec) break; if (ec) break;
s.bind(tcp::endpoint(address::from_string("127.0.0.1") s.bind(tcp::endpoint(address::from_string("127.0.0.1")
, boost::uint16_t(port)), ec); , std::uint16_t(port)), ec);
} while (ec); } while (ec);
char buf[200]; char buf[200];
@ -996,7 +996,7 @@ void stop_web_server()
tcp::endpoint ep(char const* ip, int port) tcp::endpoint ep(char const* ip, int port)
{ {
error_code ec; error_code ec;
tcp::endpoint ret(address::from_string(ip, ec), boost::uint16_t(port)); tcp::endpoint ret(address::from_string(ip, ec), std::uint16_t(port));
TEST_CHECK(!ec); TEST_CHECK(!ec);
return ret; return ret;
} }