diff --git a/Jamfile b/Jamfile index cbbeb5cdf..3e7a503f9 100644 --- a/Jamfile +++ b/Jamfile @@ -720,6 +720,7 @@ local usage-requirements = # disable bogus deprecation warnings on msvc8 msvc:_SCL_SECURE_NO_DEPRECATE msvc:_CRT_SECURE_NO_DEPRECATE + off:TORRENT_DISABLE_LOGGING $(CXXFLAGS) $(LDFLAGS) diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index 0a03c3816..a0ca5d7c0 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -597,10 +597,13 @@ namespace libtorrent virtual void announce(sha1_hash const& ih, address const& addr, int port) override; virtual void outgoing_get_peers(sha1_hash const& target , sha1_hash const& sent_target, udp::endpoint const& ep) override; + +#ifndef TORRENT_DISABLE_LOGGING virtual void log(libtorrent::dht::dht_logger::module_t m, char const* fmt, ...) override TORRENT_FORMAT(3,4); virtual void log_packet(message_direction_t dir, char const* pkt, int len , udp::endpoint node) override; +#endif virtual bool on_dht_request(char const* query, int query_len , dht::msg const& request, entry& response) override; diff --git a/include/libtorrent/kademlia/dht_observer.hpp b/include/libtorrent/kademlia/dht_observer.hpp index 58da0c3a9..40d984151 100644 --- a/include/libtorrent/kademlia/dht_observer.hpp +++ b/include/libtorrent/kademlia/dht_observer.hpp @@ -41,6 +41,7 @@ namespace libtorrent { namespace dht { struct TORRENT_EXTRA_EXPORT dht_logger { +#ifndef TORRENT_DISABLE_LOGGING enum module_t { tracker, @@ -59,6 +60,7 @@ namespace libtorrent { namespace dht virtual void log(module_t m, char const* fmt, ...) TORRENT_FORMAT(3,4) = 0; virtual void log_packet(message_direction_t dir, char const* pkt, int len , udp::endpoint node) = 0; +#endif protected: ~dht_logger() {} diff --git a/include/libtorrent/natpmp.hpp b/include/libtorrent/natpmp.hpp index 88d5d7d9b..5a157d610 100644 --- a/include/libtorrent/natpmp.hpp +++ b/include/libtorrent/natpmp.hpp @@ -91,7 +91,10 @@ private: void mapping_expired(error_code const& e, int i); void close_impl(); - void log(char const* msg); +#ifndef TORRENT_DISABLE_LOGGING + void log(char const* fmt, ...) const TORRENT_FORMAT(2, 3); +#endif + void disable(error_code const& ec); struct mapping_t diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index e49fb9923..4a7fb1778 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -551,9 +551,7 @@ namespace libtorrent , char const* event, char const* fmt, ...) const TORRENT_FORMAT(4,5); void peer_log(peer_log_alert::direction_t direction , char const* event) const; -#endif -#ifndef TORRENT_DISABLE_LOGGING time_point m_connect_time; time_point m_bitfield_time; time_point m_unchoke_time; diff --git a/src/natpmp.cpp b/src/natpmp.cpp index 8beb6c6f0..b848f37ea 100644 --- a/src/natpmp.cpp +++ b/src/natpmp.cpp @@ -44,6 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/disable_warnings_pop.hpp" #include // for snprintf +#include #include "libtorrent/natpmp.hpp" #include "libtorrent/io.hpp" @@ -91,10 +92,10 @@ void natpmp::start() address gateway = get_default_gateway(m_socket.get_io_service(), ec); if (ec) { - char msg[200]; - std::snprintf(msg, sizeof(msg), "failed to find default route: %s" +#ifndef TORRENT_DISABLE_LOGGING + log("failed to find default route: %s" , convert_from_native(ec.message()).c_str()); - log(msg); +#endif disable(ec); return; } @@ -105,10 +106,10 @@ void natpmp::start() if (nat_endpoint == m_nat_endpoint) return; m_nat_endpoint = nat_endpoint; - char msg[200]; - std::snprintf(msg, sizeof(msg), "found router at: %s" +#ifndef TORRENT_DISABLE_LOGGING + log("found router at: %s" , print_address(m_nat_endpoint.address()).c_str()); - log(msg); +#endif m_socket.open(udp::v4(), ec); if (ec) @@ -148,7 +149,9 @@ void natpmp::send_get_ip_address_request() char* out = buf; write_uint8(0, out); // NAT-PMP version write_uint8(0, out); // public IP address request opcode +#ifndef TORRENT_DISABLE_LOGGING log("==> get public IP address"); +#endif error_code ec; m_socket.send_to(boost::asio::buffer(buf, sizeof(buf)), m_nat_endpoint, 0, ec); @@ -168,11 +171,21 @@ bool natpmp::get_mapping(int index, int& local_port, int& external_port, int& pr return true; } -void natpmp::log(char const* msg) +#ifndef TORRENT_DISABLE_LOGGING +TORRENT_FORMAT(2, 3) +void natpmp::log(char const* fmt, ...) const { TORRENT_ASSERT(is_single_thread()); + char msg[200]; + + va_list v; + va_start(v, fmt); + std::vsnprintf(msg, sizeof(msg), fmt, v); + va_end(v); + m_log_callback(msg); } +#endif void natpmp::disable(error_code const& ec) { @@ -352,13 +365,13 @@ void natpmp::send_map_request(int i) int ttl = m.action == mapping_t::action_add ? 3600 : 0; write_uint32(ttl, out); // port mapping lifetime - char msg[200]; - std::snprintf(msg, sizeof(msg), "==> port map [ mapping: %d action: %s" +#ifndef TORRENT_DISABLE_LOGGING + log("==> port map [ mapping: %d action: %s" " proto: %s local: %u external: %u ttl: %u ]" , i, m.action == mapping_t::action_add ? "add" : "delete" , m.protocol == udp ? "udp" : "tcp" , m.local_port, m.external_port, ttl); - log(msg); +#endif error_code ec; m_socket.send_to(boost::asio::buffer(buf, sizeof(buf)), m_nat_endpoint, 0, ec); @@ -414,10 +427,10 @@ void natpmp::on_reply(error_code const& e using namespace libtorrent::detail; if (e) { - char msg[200]; - std::snprintf(msg, sizeof(msg), "error on receiving reply: %s" +#ifndef TORRENT_DISABLE_LOGGING + log("error on receiving reply: %s" , convert_from_native(e.message()).c_str()); - log(msg); +#endif return; } @@ -430,20 +443,12 @@ void natpmp::on_reply(error_code const& e m_socket.async_receive_from(boost::asio::buffer(&m_response_buffer, 16) , m_remote, boost::bind(&natpmp::on_reply, self(), _1, _2)); - // simulate packet loss -/* - if ((random() % 2) == 0) - { - log(" simulating drop"); - return; - } -*/ if (m_remote != m_nat_endpoint) { - char msg[200]; - std::snprintf(msg, sizeof(msg), "received packet from wrong IP: %s" +#ifndef TORRENT_DISABLE_LOGGING + log("received packet from wrong IP: %s" , print_endpoint(m_remote).c_str()); - log(msg); +#endif return; } @@ -452,9 +457,9 @@ void natpmp::on_reply(error_code const& e if (bytes_transferred < 12) { - char msg[200]; - std::snprintf(msg, sizeof(msg), "received packet of invalid size: %d", int(bytes_transferred)); - log(msg); +#ifndef TORRENT_DISABLE_LOGGING + log("received packet of invalid size: %d", int(bytes_transferred)); +#endif return; } @@ -463,35 +468,36 @@ void natpmp::on_reply(error_code const& e int cmd = read_uint8(in); int result = read_uint16(in); int time = read_uint32(in); + TORRENT_UNUSED(version); + TORRENT_UNUSED(time); if (cmd == 128) { // public IP request response m_external_ip = read_v4_address(in); - char msg[200]; - std::snprintf(msg, sizeof(msg), "<== public IP address [ %s ]", print_address(m_external_ip).c_str()); - log(msg); +#ifndef TORRENT_DISABLE_LOGGING + log("<== public IP address [ %s ]", print_address(m_external_ip).c_str()); +#endif return; } if (bytes_transferred < 16) { - char msg[200]; - std::snprintf(msg, sizeof(msg), "received packet of invalid size: %d", int(bytes_transferred)); - log(msg); +#ifndef TORRENT_DISABLE_LOGGING + log("received packet of invalid size: %d", int(bytes_transferred)); +#endif return; } - int private_port = read_uint16(in); - int public_port = read_uint16(in); - int lifetime = read_uint32(in); + int const private_port = read_uint16(in); + int const public_port = read_uint16(in); + int const lifetime = read_uint32(in); - (void)time; // to remove warning - - int protocol = (cmd - 128 == 1)?udp:tcp; + int const protocol = (cmd - 128 == 1)?udp:tcp; +#ifndef TORRENT_DISABLE_LOGGING char msg[200]; int num_chars = std::snprintf(msg, sizeof(msg), "<== port map [" " protocol: %s local: %u external: %u ttl: %u ]" @@ -502,8 +508,9 @@ void natpmp::on_reply(error_code const& e { std::snprintf(msg + num_chars, sizeof(msg) - num_chars, "unexpected version: %u" , version); - log(msg); + log("%s", msg); } +#endif mapping_t* m = 0; int index = -1; @@ -521,13 +528,17 @@ void natpmp::on_reply(error_code const& e if (m == 0) { - std::snprintf(msg + num_chars, sizeof(msg) - num_chars, " not found in map table"); - log(msg); +#ifndef TORRENT_DISABLE_LOGGING + snprintf(msg + num_chars, sizeof(msg) - num_chars, " not found in map table"); + log("%s", msg); +#endif return; } m->outstanding_request = false; - log(msg); +#ifndef TORRENT_DISABLE_LOGGING + log("%s", msg); +#endif if (public_port == 0 || lifetime == 0) { @@ -605,9 +616,9 @@ void natpmp::update_expiration_timer() int index = i - m_mappings.begin(); if (i->expires < now) { - char msg[200]; - std::snprintf(msg, sizeof(msg), "mapping %u expired", index); - log(msg); +#ifndef TORRENT_DISABLE_LOGGING + log("mapping %u expired", index); +#endif i->action = mapping_t::action_add; if (m_next_refresh == index) m_next_refresh = -1; update_mapping(index); @@ -645,9 +656,9 @@ void natpmp::mapping_expired(error_code const& e, int i) TORRENT_ASSERT(is_single_thread()); COMPLETE_ASYNC("natpmp::mapping_expired"); if (e) return; - char msg[200]; - std::snprintf(msg, sizeof(msg), "mapping %u expired", i); - log(msg); +#ifndef TORRENT_DISABLE_LOGGING + log("mapping %u expired", i); +#endif m_mappings[i].action = mapping_t::action_add; if (m_next_refresh == i) m_next_refresh = -1; update_mapping(i); @@ -663,7 +674,9 @@ void natpmp::close_impl() { TORRENT_ASSERT(is_single_thread()); m_abort = true; +#ifndef TORRENT_DISABLE_LOGGING log("closing"); +#endif #ifdef NATPMP_LOG std::cout << time_now_string() << " close" << std::endl; time_point now = aux::time_now(); diff --git a/src/peer_list.cpp b/src/peer_list.cpp index ae13b4910..dff069d9a 100644 --- a/src/peer_list.cpp +++ b/src/peer_list.cpp @@ -738,9 +738,9 @@ namespace libtorrent } #if TORRENT_USE_IPV6 - bool is_v6 = c.remote().address().is_v6(); + bool const is_v6 = c.remote().address().is_v6(); #else - bool is_v6 = false; + bool const is_v6 = false; #endif torrent_peer* p = state->peer_allocator->allocate_peer_entry( is_v6 ? torrent_peer_allocator_interface::ipv6_peer_type @@ -808,7 +808,7 @@ namespace libtorrent TORRENT_ASSERT(pp.in_use); if (pp.connection) { - bool was_conn_cand = is_connect_candidate(pp); + bool const was_conn_cand = is_connect_candidate(pp); // if we already have an entry with this // new endpoint, disconnect this one pp.connectable = true; @@ -844,7 +844,7 @@ namespace libtorrent } #endif - bool was_conn_cand = is_connect_candidate(*p); + bool const was_conn_cand = is_connect_candidate(*p); p->port = port; p->source |= src; p->connectable = true; @@ -870,7 +870,7 @@ namespace libtorrent if (p == 0) return; TORRENT_ASSERT(p->in_use); if (p->seed == s) return; - bool was_conn_cand = is_connect_candidate(*p); + bool const was_conn_cand = is_connect_candidate(*p); p->seed = s; if (was_conn_cand && !is_connect_candidate(*p)) update_connect_candidates(-1); @@ -896,7 +896,7 @@ namespace libtorrent TORRENT_ASSERT(p); TORRENT_ASSERT(p->in_use); - int max_peerlist_size = state->max_peerlist_size; + int const max_peerlist_size = state->max_peerlist_size; if (max_peerlist_size && int(m_peers.size()) >= max_peerlist_size) @@ -950,7 +950,7 @@ namespace libtorrent , tcp::endpoint const& remote, char const* /* destination*/) { TORRENT_ASSERT(is_single_thread()); - bool was_conn_cand = is_connect_candidate(*p); + bool const was_conn_cand = is_connect_candidate(*p); TORRENT_ASSERT(p->in_use); p->connectable = true; @@ -1094,9 +1094,9 @@ namespace libtorrent // add a new entry #if TORRENT_USE_IPV6 - bool is_v6 = remote.address().is_v6(); + bool const is_v6 = remote.address().is_v6(); #else - bool is_v6 = false; + bool const is_v6 = false; #endif p = state->peer_allocator->allocate_peer_entry( is_v6 ? torrent_peer_allocator_interface::ipv6_peer_type diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 9e28f04e2..7c666a60b 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -6622,8 +6622,7 @@ namespace aux { m_alerts.emplace_alert(target, sent_target, ep); } - // TODO: 2 perhaps DHT logging should be disabled by TORRENT_DISABLE_LOGGING - // too +#ifndef TORRENT_DISABLE_LOGGING TORRENT_FORMAT(3,4) void session_impl::log(libtorrent::dht::dht_logger::module_t m, char const* fmt, ...) { @@ -6632,7 +6631,7 @@ namespace aux { va_list v; va_start(v, fmt); char buf[1024]; - vsnprintf(buf, sizeof(buf), fmt, v); + std::vsnprintf(buf, sizeof(buf), fmt, v); va_end(v); m_alerts.emplace_alert(static_cast(m), buf); } @@ -6647,6 +6646,7 @@ namespace aux { m_alerts.emplace_alert(pkt, len, d, node); } +#endif bool session_impl::on_dht_request(char const* query, int query_len , dht::msg const& request, entry& response) diff --git a/test/test_dht.cpp b/test/test_dht.cpp index f8472194b..f72218d65 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -487,6 +487,7 @@ struct obs : dht::dht_observer virtual void outgoing_get_peers(sha1_hash const& target , sha1_hash const& sent_target, udp::endpoint const& ep) override {} virtual void announce(sha1_hash const& ih, address const& addr, int port) override {} +#ifndef TORRENT_DISABLE_LOGGING virtual void log(dht_logger::module_t l, char const* fmt, ...) override { va_list v; @@ -498,10 +499,13 @@ struct obs : dht::dht_observer } virtual void log_packet(message_direction_t dir, char const* pkt, int len , udp::endpoint node) override {} +#endif virtual bool on_dht_request(char const* query, int query_len , dht::msg const& request, entry& response) override { return false; } +#ifndef TORRENT_DISABLE_LOGGING std::vector m_log; +#endif }; dht_settings test_settings() @@ -2589,6 +2593,7 @@ TORRENT_TEST(read_only_node) TEST_CHECK(!parsed[3]); } +#ifndef TORRENT_DISABLE_LOGGING TORRENT_TEST(invalid_error_msg) { dht_settings sett = test_settings(); @@ -2688,6 +2693,7 @@ TORRENT_TEST(rpc_invalid_error_msg) TEST_EQUAL(found, true); } +#endif // test bucket distribution TORRENT_TEST(node_id_bucket_distribution) diff --git a/test/test_dos_blocker.cpp b/test/test_dos_blocker.cpp index d62991bee..cf35951b2 100644 --- a/test/test_dos_blocker.cpp +++ b/test/test_dos_blocker.cpp @@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE. using namespace libtorrent; +#ifndef TORRENT_DISABLE_LOGGING struct log_t : libtorrent::dht::dht_logger { virtual void log(dht_logger::module_t m, char const* fmt, ...) @@ -69,9 +70,11 @@ struct log_t : libtorrent::dht::dht_logger , msg.c_str()); } }; +#endif TORRENT_TEST(dos_blocker) { +#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_DHT using namespace libtorrent::dht; @@ -93,5 +96,6 @@ TORRENT_TEST(dos_blocker) TEST_EQUAL(b.incoming(spammer, now, &l), false); #endif +#endif } diff --git a/test/test_peer_list.cpp b/test/test_peer_list.cpp index a940026d2..065b28ce9 100644 --- a/test/test_peer_list.cpp +++ b/test/test_peer_list.cpp @@ -44,14 +44,16 @@ POSSIBILITY OF SUCH DAMAGE. #include "test.hpp" #include "setup_transfer.hpp" #include +#include // for shared_ptr #include using namespace libtorrent; struct mock_torrent; -struct mock_peer_connection : peer_connection_interface - , boost::enable_shared_from_this +struct mock_peer_connection + : peer_connection_interface + , std::enable_shared_from_this { mock_peer_connection(mock_torrent* tor, bool out, tcp::endpoint const& remote) : m_choked(false) @@ -69,7 +71,7 @@ struct mock_peer_connection : peer_connection_interface #if !defined TORRENT_DISABLE_LOGGING virtual void peer_log(peer_log_alert::direction_t dir, char const* event - , char const* fmt, ...) const + , char const* fmt, ...) const override { va_list v; va_start(v, fmt); @@ -91,21 +93,21 @@ struct mock_peer_connection : peer_connection_interface bool m_disconnect_called; mock_torrent& m_torrent; - virtual void get_peer_info(peer_info& p) const {} - virtual tcp::endpoint const& remote() const { return m_remote; } - virtual tcp::endpoint local_endpoint() const { return m_local; } + virtual void get_peer_info(peer_info& p) const override {} + virtual tcp::endpoint const& remote() const override { return m_remote; } + virtual tcp::endpoint local_endpoint() const override { return m_local; } virtual void disconnect(error_code const& ec , operation_t op, int error = 0); - virtual peer_id const& pid() const { return m_id; } - virtual void set_holepunch_mode() {} - virtual torrent_peer* peer_info_struct() const { return m_tp; } - virtual void set_peer_info(torrent_peer* pi) { m_tp = pi; } - virtual bool is_outgoing() const { return m_outgoing; } - virtual void add_stat(boost::int64_t downloaded, boost::int64_t uploaded) + virtual peer_id const& pid() const override { return m_id; } + virtual void set_holepunch_mode() override {} + virtual torrent_peer* peer_info_struct() const override { return m_tp; } + virtual void set_peer_info(torrent_peer* pi) override { m_tp = pi; } + virtual bool is_outgoing() const override { return m_outgoing; } + virtual void add_stat(boost::int64_t downloaded, boost::int64_t uploaded) override { m_stat.add_stat(downloaded, uploaded); } - virtual bool fast_reconnect() const { return true; } - virtual bool is_choked() const { return m_choked; } - virtual bool failed() const { return false; } + virtual bool fast_reconnect() const override { return true; } + virtual bool is_choked() const override { return m_choked; } + virtual bool failed() const override { return false; } virtual libtorrent::stat const& statistics() const { return m_stat; } }; @@ -118,8 +120,7 @@ struct mock_torrent { TORRENT_ASSERT(peerinfo->connection == NULL); if (peerinfo->connection) return false; - boost::shared_ptr c - = boost::make_shared(this, true, peerinfo->ip()); + auto c = std::make_shared(this, true, peerinfo->ip()); c->set_peer_info(peerinfo); m_connections.push_back(c); @@ -139,16 +140,16 @@ struct mock_torrent peer_list* m_p; torrent_state* m_state; - std::vector > m_connections; + std::vector > m_connections; }; void mock_peer_connection::disconnect(error_code const& ec , operation_t op, int error) { m_torrent.m_p->connection_closed(*this, 0, m_torrent.m_state); - std::vector >::iterator i + std::vector >::iterator i = std::find(m_torrent.m_connections.begin(), m_torrent.m_connections.end() - , shared_from_this()); + , std::static_pointer_cast(shared_from_this())); if (i != m_torrent.m_connections.end()) m_torrent.m_connections.erase(i); m_tp = 0; @@ -329,8 +330,7 @@ TORRENT_TEST(update_peer_port) peer_list p; t.m_p = &p; TEST_EQUAL(p.num_connect_candidates(), 0); - boost::shared_ptr c - = boost::make_shared(&t, true, ep("10.0.0.1", 8080)); + auto c = std::make_shared(&t, true, ep("10.0.0.1", 8080)); p.new_connection(*c, 0, &st); TEST_EQUAL(p.num_connect_candidates(), 0); TEST_EQUAL(p.num_peers(), 1); @@ -357,8 +357,7 @@ TORRENT_TEST(update_peer_port_collide) TEST_CHECK(peer2); TEST_EQUAL(p.num_connect_candidates(), 1); - boost::shared_ptr c - = boost::make_shared(&t, true, ep("10.0.0.1", 8080)); + auto c = std::make_shared(&t, true, ep("10.0.0.1", 8080)); p.new_connection(*c, 0, &st); TEST_EQUAL(p.num_connect_candidates(), 1); // at this point we have two peers, because we think they have different @@ -375,6 +374,12 @@ TORRENT_TEST(update_peer_port_collide) st.erased.clear(); } +std::shared_ptr shared_from_this(libtorrent::peer_connection_interface* p) +{ + return std::static_pointer_cast( + static_cast(p)->shared_from_this()); +} + // test ip filter TORRENT_TEST(ip_filter) { @@ -393,11 +398,9 @@ TORRENT_TEST(ip_filter) connect_peer(p, t, st); connect_peer(p, t, st); - boost::shared_ptr con1 - = static_cast(peer1->connection)->shared_from_this(); + auto con1 = shared_from_this(peer1->connection); TEST_EQUAL(con1->was_disconnected(), false); - boost::shared_ptr con2 - = static_cast(peer2->connection)->shared_from_this(); + auto con2 = shared_from_this(peer2->connection); TEST_EQUAL(con2->was_disconnected(), false); // now, filter one of the IPs and make sure the peer is removed @@ -433,11 +436,9 @@ TORRENT_TEST(port_filter) connect_peer(p, t, st); connect_peer(p, t, st); - boost::shared_ptr con1 - = static_cast(peer1->connection)->shared_from_this(); + auto con1 = shared_from_this(peer1->connection); TEST_EQUAL(con1->was_disconnected(), false); - boost::shared_ptr con2 - = static_cast(peer2->connection)->shared_from_this(); + auto con2 = shared_from_this(peer2->connection); TEST_EQUAL(con2->was_disconnected(), false); // now, filter one of the IPs and make sure the peer is removed @@ -467,8 +468,7 @@ TORRENT_TEST(ban_peers) torrent_peer* peer1 = add_peer(p, st, ep("10.0.0.1", 4000)); TEST_EQUAL(p.num_connect_candidates(), 1); - boost::shared_ptr c - = boost::make_shared(&t, true, ep("10.0.0.1", 8080)); + auto c = std::make_shared(&t, true, ep("10.0.0.1", 8080)); p.new_connection(*c, 0, &st); TEST_EQUAL(p.num_connect_candidates(), 0); TEST_EQUAL(p.num_peers(), 1); @@ -488,7 +488,7 @@ TORRENT_TEST(ban_peers) TEST_EQUAL(p.num_connect_candidates(), 0); st.erased.clear(); - c = boost::make_shared(&t, true, ep("10.0.0.1", 8080)); + c = std::make_shared(&t, true, ep("10.0.0.1", 8080)); ok = p.new_connection(*c, 0, &st); // since it's banned, we should not allow this incoming connection TEST_EQUAL(ok, false); @@ -740,12 +740,10 @@ TORRENT_TEST(self_connection) torrent_peer* peer = add_peer(p, st, ep("10.0.0.2", 3000)); connect_peer(p, t, st); - boost::shared_ptr con_out - = static_cast(peer->connection)->shared_from_this(); + auto con_out = shared_from_this(peer->connection); con_out->set_local_ep(ep("10.0.0.2", 8080)); - boost::shared_ptr con_in - = boost::make_shared(&t, false, ep("10.0.0.2", 8080)); + auto con_in = std::make_shared(&t, false, ep("10.0.0.2", 8080)); con_in->set_local_ep(ep("10.0.0.2", 3000)); p.new_connection(*con_in, 0, &st); @@ -771,15 +769,13 @@ TORRENT_TEST(double_connection) // we are 10.0.0.1 and the other peer is 10.0.0.2 // first incoming connection - boost::shared_ptr con1 - = boost::make_shared(&t, false, ep("10.0.0.2", 7528)); + auto con1 = std::make_shared(&t, false, ep("10.0.0.2", 7528)); con1->set_local_ep(ep("10.0.0.1", 8080)); p.new_connection(*con1, 0, &st); // and the incoming connection - boost::shared_ptr con2 - = boost::make_shared(&t, false, ep("10.0.0.2", 3561)); + auto con2 = std::make_shared(&t, false, ep("10.0.0.2", 3561)); con2->set_local_ep(ep("10.0.0.1", 8080)); p.new_connection(*con2, 0, &st); @@ -804,13 +800,11 @@ TORRENT_TEST(double_connection_loose) torrent_peer* peer = add_peer(p, st, ep("10.0.0.2", 3000)); connect_peer(p, t, st); - boost::shared_ptr con_out - = static_cast(peer->connection)->shared_from_this(); + auto con_out = shared_from_this(peer->connection); con_out->set_local_ep(ep("10.0.0.1", 3163)); // and the incoming connection - boost::shared_ptr con_in - = boost::make_shared(&t, false, ep("10.0.0.2", 3561)); + auto con_in = std::make_shared(&t, false, ep("10.0.0.2", 3561)); con_in->set_local_ep(ep("10.0.0.1", 8080)); p.new_connection(*con_in, 0, &st); @@ -835,13 +829,11 @@ TORRENT_TEST(double_connection_win) torrent_peer* peer = add_peer(p, st, ep("10.0.0.2", 8080)); connect_peer(p, t, st); - boost::shared_ptr con_out - = static_cast(peer->connection)->shared_from_this(); + auto con_out = shared_from_this(peer->connection); con_out->set_local_ep(ep("10.0.0.1", 3163)); //and the incoming connection - boost::shared_ptr con_in - = boost::make_shared(&t, false, ep("10.0.0.2", 3561)); + auto con_in = std::make_shared(&t, false, ep("10.0.0.2", 3561)); con_in->set_local_ep(ep("10.0.0.1", 3000)); p.new_connection(*con_in, 0, &st); @@ -877,8 +869,7 @@ TORRENT_TEST(incoming_size_limit) TEST_CHECK(peer5); TEST_EQUAL(p.num_peers(), 5); - boost::shared_ptr con_in - = boost::make_shared(&t, false, ep("10.0.1.2", 3561)); + auto con_in = std::make_shared(&t, false, ep("10.0.1.2", 3561)); con_in->set_local_ep(ep("10.0.2.1", 3000)); // since we're already at 5 peers in the peer list, this call should