trivial cleanup and minor changes (#1033)

This commit is contained in:
Alden Torres 2016-08-26 00:14:11 -04:00 committed by Arvid Norberg
parent a9c0db0bf7
commit c05e29c48e
27 changed files with 30 additions and 125 deletions

View File

@ -301,6 +301,7 @@ namespace libtorrent
// a list of hostname and port pairs, representing DHT nodes to be added
// to the session (if DHT is enabled). The hostname may be an IP address.
std::vector<std::pair<std::string, int>> dht_nodes;
std::string name;
// the path where the torrent is or will be stored.

View File

@ -57,7 +57,6 @@ inline void openssl_set_tlsext_hostname(SSL* s, char const* name)
#endif
}
#if BOOST_VERSION >= 104700
#if OPENSSL_VERSION_NUMBER >= 0x90812f
inline void openssl_set_tlsext_servername_callback(SSL_CTX* ctx
@ -82,7 +81,6 @@ inline GENERAL_NAME* openssl_general_name_value(GENERAL_NAMES* gens, int i)
}
#endif // OPENSSL_VERSION_NUMBER
#endif // BOOST_VERSION
}
}
@ -92,4 +90,3 @@ inline GENERAL_NAME* openssl_general_name_value(GENERAL_NAMES* gens, int i)
#endif // TORRENT_USE_OPENSSL
#endif // TORRENT_OPENSSL_HPP_INCLUDED

View File

@ -40,13 +40,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/error_code.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/shared_ptr.hpp>
#include <boost/function/function3.hpp>
#include <list>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <list>
namespace libtorrent
{

View File

@ -38,14 +38,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/debug.hpp"
#include "libtorrent/buffer.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/version.hpp>
#include <boost/asio/buffer.hpp>
#include <deque>
#include <vector>
#include <string.h> // for memcpy
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/asio/buffer.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent

View File

@ -38,7 +38,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/span.hpp"
#include <string>
#include <array>
namespace libtorrent
{
@ -80,4 +79,3 @@ namespace libtorrent
}
#endif // TORRENT_HEX_HPP_INCLUDED

View File

@ -51,11 +51,6 @@ namespace libtorrent
class torrent;
struct peer_request;
namespace detail
{
struct session_impl;
}
class TORRENT_EXTRA_EXPORT http_seed_connection
: public web_connection_base
{

View File

@ -40,15 +40,11 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/kademlia/observer.hpp>
#include <libtorrent/kademlia/msg.hpp>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <vector>
#include <map>
#include <boost/optional.hpp>
#include <boost/function/function1.hpp>
#include <boost/function/function2.hpp>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/intrusive_ptr.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent { namespace dht
@ -101,4 +97,3 @@ struct find_data_observer : traversal_observer
} } // namespace libtorrent::dht
#endif // FIND_DATA_050323_HPP

View File

@ -39,10 +39,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/span.hpp>
#include <libtorrent/kademlia/types.hpp>
#include <vector>
#include <exception>
#include <array>
namespace libtorrent { namespace dht
{

View File

@ -39,10 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/address.hpp>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/pool/pool.hpp>
#include <boost/intrusive_ptr.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent {
@ -177,4 +174,3 @@ typedef boost::intrusive_ptr<observer> observer_ptr;
} }
#endif

View File

@ -40,10 +40,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <tuple>
#include <array>
#include "libtorrent/aux_/disable_warnings_push.hpp"
//#include <boost/utility.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include <libtorrent/kademlia/node_id.hpp>
#include <libtorrent/kademlia/node_entry.hpp>
#include <libtorrent/session_settings.hpp>
@ -336,4 +332,3 @@ private:
} } // namespace libtorrent::dht
#endif // ROUTING_TABLE_HPP

View File

@ -42,12 +42,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/address.hpp>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/noncopyable.hpp>
#include <boost/intrusive_ptr.hpp>
#include <functional>
#include <boost/pool/pool.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
namespace libtorrent { struct dht_lookup; }

View File

@ -39,7 +39,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <algorithm>
#include <vector>
#include <bitset>
#include <utility>
#include <cstdint>
#include <tuple>

View File

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

View File

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

View File

@ -44,12 +44,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/io_service.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/type_traits/aligned_storage.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#ifdef TORRENT_USE_OPENSSL
#include "libtorrent/ssl_stream.hpp"
#endif

View File

@ -45,7 +45,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/version.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
@ -99,12 +98,6 @@ namespace libtorrent
class bt_peer_connection;
struct listen_socket_t;
namespace aux
{
struct piece_checker_data;
}
struct time_critical_piece
{
// when this piece was first requested
@ -1189,9 +1182,7 @@ namespace libtorrent
#ifdef TORRENT_USE_OPENSSL
boost::shared_ptr<boost::asio::ssl::context> m_ssl_ctx;
#if BOOST_VERSION >= 104700
bool verify_peer_cert(bool preverified, boost::asio::ssl::verify_context& ctx);
#endif
void init_ssl(std::string const& cert);
#endif

View File

@ -414,7 +414,7 @@ namespace libtorrent
// for the piece. Note that the string is not 0-terminated.
int piece_size(int index) const { return m_files.piece_size(index); }
sha1_hash hash_for_piece(int index) const;
char const* hash_for_piece_ptr(int index) const
char const* hash_for_piece_ptr(int const index) const
{
TORRENT_ASSERT(index >= 0);
TORRENT_ASSERT(index < m_files.num_pieces());

View File

@ -336,7 +336,7 @@ namespace libtorrent
// piece(s). Divide this number by 1000 to get the fraction.
//
// For example, if ``distributed_full_copies`` is 2 and
// ``distrbuted_fraction`` is 500, it means that the rarest pieces have
// ``distributed_fraction`` is 500, it means that the rarest pieces have
// only 2 copies among the peers this torrent is connected to, and that
// 50% of all the pieces have more than two copies.
//

View File

@ -30,8 +30,6 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#include <boost/version.hpp>
#include "libtorrent/config.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
@ -40,16 +38,13 @@ POSSIBILITY OF SUCH DAMAGE.
#include <pthread.h>
#endif
#include <boost/asio/ip/host_name.hpp>
#include <boost/asio/ip/multicast.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#ifdef TORRENT_WINDOWS
#include <iphlpapi.h> // for if_nametoindex
#endif
#include <functional>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/enum_net.hpp"

View File

@ -33,6 +33,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/chained_buffer.hpp"
#include "libtorrent/assert.hpp"
#include <cstring> // for memcpy
namespace libtorrent
{
void chained_buffer::pop_front(int bytes_to_pop)
@ -123,7 +125,7 @@ namespace libtorrent
TORRENT_ASSERT(is_single_thread());
char* insert = allocate_appendix(s);
if (insert == nullptr) return nullptr;
memcpy(insert, buf, s);
std::memcpy(insert, buf, s);
return insert;
}

View File

@ -41,8 +41,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/hex.hpp> // to_hex
#endif
#include <vector>
namespace libtorrent { namespace dht
{
@ -178,4 +176,3 @@ void find_data::done()
}
} } // namespace libtorrent::dht

View File

@ -222,4 +222,3 @@ void item::assign(entry v, span<char const> salt
}
} } // namespace libtorrent::dht

View File

@ -32,14 +32,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include <cstdint>
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/make_shared.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp"
#include "libtorrent/bdecode.hpp"
#include "libtorrent/read_resume_data.hpp"
#include "libtorrent/add_torrent_params.hpp"
#include "libtorrent/announce_entry.hpp"
#include "libtorrent/socket_io.hpp" // for read_*_endpoint()
#include "libtorrent/hasher.hpp"
#include "libtorrent/torrent_info.hpp"
@ -340,4 +335,3 @@ namespace libtorrent
return read_resume_data(rd, ec);
}
}

View File

@ -257,7 +257,7 @@ namespace aux {
#endif
}
#if defined TORRENT_USE_OPENSSL && BOOST_VERSION >= 104700 && OPENSSL_VERSION_NUMBER >= 0x90812f
#if defined TORRENT_USE_OPENSSL && OPENSSL_VERSION_NUMBER >= 0x90812f
namespace {
// when running bittorrent over SSL, the SNI (server name indication)
// extension is used to know which torrent the incoming connection is
@ -415,13 +415,11 @@ namespace aux {
error_code ec;
#ifdef TORRENT_USE_OPENSSL
m_ssl_ctx.set_verify_mode(boost::asio::ssl::context::verify_none, ec);
#if BOOST_VERSION >= 104700
#if OPENSSL_VERSION_NUMBER >= 0x90812f
aux::openssl_set_tlsext_servername_callback(m_ssl_ctx.native_handle()
, servername_callback);
aux::openssl_set_tlsext_servername_arg(m_ssl_ctx.native_handle(), this);
#endif // OPENSSL_VERSION_NUMBER
#endif // BOOST_VERSION
#endif
#ifndef TORRENT_DISABLE_DHT

View File

@ -176,7 +176,7 @@ namespace libtorrent
METRIC(net, recv_tracker_bytes)
// the number of sockets currently waiting for upload and download
// bandwidht from the rate limiter.
// bandwidth from the rate limiter.
METRIC(net, limiter_up_queue)
METRIC(net, limiter_down_queue)

View File

@ -54,10 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
#ifdef TORRENT_USE_OPENSSL
#include "libtorrent/ssl_stream.hpp"
#include <boost/asio/ssl/context.hpp>
#include <openssl/rand.h>
#if BOOST_VERSION >= 104700
#include <boost/asio/ssl/verify_context.hpp>
#endif // BOOST_VERSION
#endif // TORRENT_USE_OPENSSL
#include "libtorrent/aux_/disable_warnings_pop.hpp"
@ -1481,7 +1478,6 @@ namespace libtorrent
#ifdef TORRENT_USE_OPENSSL
#if BOOST_VERSION >= 104700
bool torrent::verify_peer_cert(bool preverified, boost::asio::ssl::verify_context& ctx)
{
// if the cert wasn't signed by the correct CA, fail the verification
@ -1573,7 +1569,6 @@ namespace libtorrent
return false;
#endif
}
#endif // BOOST_VERSION
void torrent::init_ssl(std::string const& cert)
{
@ -1590,7 +1585,6 @@ namespace libtorrent
TORRENT_ASSERT(RAND_status() == 1);
#if BOOST_VERSION >= 104700
// create the SSL context for this torrent. We need to
// inject the root certificate, and no other, to
// verify other peers against
@ -1683,10 +1677,6 @@ namespace libtorrent
m_ssl_ctx = ctx;
// tell the client we need a cert for this torrent
alerts().emplace_alert<torrent_need_cert_alert>(get_handle());
#else
set_error(boost::asio::error::operation_not_supported, torrent_status::error_file_ssl_ctx);
pause();
#endif
}
#endif // TORRENT_OPENSSL
@ -5694,11 +5684,6 @@ namespace libtorrent
{
if (!m_ssl_ctx) return;
#if BOOST_VERSION < 105400
if (alerts().should_post<torrent_error_alert>())
alerts().emplace_alert<torrent_error_alert>(get_handle()
, error_code(boost::system::errc::not_supported, generic_category()), "[certificate]");
#else
boost::asio::const_buffer certificate_buf(certificate.c_str(), certificate.size());
using boost::asio::ssl::context;
@ -5725,7 +5710,6 @@ namespace libtorrent
if (alerts().should_post<torrent_error_alert>())
alerts().emplace_alert<torrent_error_alert>(get_handle(), ec, "[dh params]");
}
#endif // BOOST_VERSION
}
#endif
@ -6905,7 +6889,7 @@ namespace libtorrent
(void)ret;
TORRENT_ASSERT(ret);
#if defined TORRENT_USE_OPENSSL && BOOST_VERSION >= 104700
#if defined TORRENT_USE_OPENSSL
if (is_ssl_torrent())
{
// for ssl sockets, set the hostname
@ -7096,7 +7080,6 @@ namespace libtorrent
// INVARIANT_CHECK;
#ifdef TORRENT_USE_OPENSSL
#if BOOST_VERSION >= 104700
if (is_ssl_torrent())
{
// if this is an SSL torrent, don't allow non SSL peers on it
@ -7144,13 +7127,6 @@ namespace libtorrent
return false;
}
}
#else // BOOST_VERSION
if (is_ssl_torrent())
{
p->disconnect(boost::asio::error::operation_not_supported, op_bittorrent);
return false;
}
#endif
#else // TORRENT_USE_OPENSSL
if (is_ssl_torrent())
{

View File

@ -1075,7 +1075,7 @@ namespace libtorrent
}
bool torrent_info::parse_info_section(bdecode_node const& info
, error_code& ec, int flags)
, error_code& ec, int const flags)
{
TORRENT_UNUSED(flags);
if (info.type() != bdecode_node::dict_t)
@ -1129,7 +1129,7 @@ namespace libtorrent
if (name.empty()) name = aux::to_hex(m_info_hash);
// extract file list
bdecode_node files_node = info.dict_find_list("files");
bdecode_node const files_node = info.dict_find_list("files");
if (!files_node)
{
// if there's no list of files, there has to be a length
@ -1264,13 +1264,12 @@ namespace libtorrent
bool torrent_info::add_merkle_nodes(std::map<int, sha1_hash> const& subtree
, int piece)
, int const piece)
{
INVARIANT_CHECK;
int n = m_merkle_first_leaf + piece;
typedef std::map<int, sha1_hash>::const_iterator iter;
iter it = subtree.find(n);
auto const it = subtree.find(n);
if (it == subtree.end()) return false;
sha1_hash h = it->second;
@ -1282,7 +1281,7 @@ namespace libtorrent
{
int const sibling = merkle_get_sibling(n);
int const parent = merkle_get_parent(n);
iter const sibling_hash = subtree.find(sibling);
auto const sibling_hash = subtree.find(sibling);
if (sibling_hash == subtree.end())
return false;
to_add[n] = h;
@ -1306,17 +1305,16 @@ namespace libtorrent
// the nodes and piece hash matched the root-hash
// insert them into our tree
for (std::map<int, sha1_hash>::iterator i = to_add.begin()
, end(to_add.end()); i != end; ++i)
for (auto const& i : to_add)
{
m_merkle_tree[i->first] = i->second;
m_merkle_tree[i.first] = i.second;
}
return true;
}
// builds a list of nodes that are required to verify
// the given piece
std::map<int, sha1_hash> torrent_info::build_merkle_list(int piece) const
std::map<int, sha1_hash> torrent_info::build_merkle_list(int const piece) const
{
INVARIANT_CHECK;
@ -1338,7 +1336,7 @@ namespace libtorrent
}
bool torrent_info::parse_torrent_file(bdecode_node const& torrent_file
, error_code& ec, int flags)
, error_code& ec, int const flags)
{
if (torrent_file.type() != bdecode_node::dict_t)
{