diff --git a/include/libtorrent/Makefile.am b/include/libtorrent/Makefile.am index 465ba1d0e..b8c3ee994 100644 --- a/include/libtorrent/Makefile.am +++ b/include/libtorrent/Makefile.am @@ -127,8 +127,6 @@ nobase_include_HEADERS = \ sliding_average.hpp \ socket.hpp \ socket_io.hpp \ - socket_type.hpp \ - socket_type_fwd.hpp \ socks5_stream.hpp \ ssl_stream.hpp \ stack_allocator.hpp \ @@ -191,6 +189,7 @@ nobase_include_HEADERS = \ aux_/proxy_settings.hpp \ aux_/session_interface.hpp \ aux_/suggest_piece.hpp \ + aux_/socket_type.hpp \ aux_/storage_piece_set.hpp \ aux_/string_ptr.hpp \ aux_/time.hpp \ diff --git a/include/libtorrent/aux_/session_impl.hpp b/include/libtorrent/aux_/session_impl.hpp index f8080309a..5f69df41c 100644 --- a/include/libtorrent/aux_/session_impl.hpp +++ b/include/libtorrent/aux_/session_impl.hpp @@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/aux_/session_settings.hpp" #include "libtorrent/aux_/session_interface.hpp" #include "libtorrent/aux_/session_udp_sockets.hpp" -#include "libtorrent/linked_list.hpp" +#include "libtorrent/aux_/socket_type.hpp" #include "libtorrent/torrent_peer.hpp" #include "libtorrent/torrent_peer_allocator.hpp" #include "libtorrent/performance_counters.hpp" // for counters @@ -62,7 +62,6 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/stat.hpp" #include "libtorrent/file_pool.hpp" #include "libtorrent/bandwidth_manager.hpp" -#include "libtorrent/socket_type.hpp" #include "libtorrent/disk_io_thread.hpp" #include "libtorrent/udp_socket.hpp" #include "libtorrent/assert.hpp" diff --git a/include/libtorrent/aux_/session_interface.hpp b/include/libtorrent/aux_/session_interface.hpp index d78e4dc45..7ea4a7903 100644 --- a/include/libtorrent/aux_/session_interface.hpp +++ b/include/libtorrent/aux_/session_interface.hpp @@ -78,7 +78,6 @@ namespace libtorrent { struct tracker_request; struct request_callback; struct utp_socket_manager; - struct socket_type; struct block_info; struct external_ip; struct torrent_handle; @@ -104,10 +103,12 @@ namespace dht { #endif } -namespace libtorrent { namespace aux { +namespace libtorrent { +namespace aux { struct proxy_settings; struct session_settings; + struct socket_type; struct ip_source_tag; using ip_source_t = flags::bitfield_flag; diff --git a/include/libtorrent/socket_type.hpp b/include/libtorrent/aux_/socket_type.hpp similarity index 99% rename from include/libtorrent/socket_type.hpp rename to include/libtorrent/aux_/socket_type.hpp index de88979ac..0432fc268 100644 --- a/include/libtorrent/socket_type.hpp +++ b/include/libtorrent/aux_/socket_type.hpp @@ -130,6 +130,7 @@ POSSIBILITY OF SUCH DAMAGE. } namespace libtorrent { +namespace aux { template struct socket_type_int_impl @@ -341,5 +342,6 @@ namespace libtorrent { // properly shuts down SSL sockets. holder keeps s alive void async_shutdown(socket_type& s, std::shared_ptr holder); } +} #endif diff --git a/include/libtorrent/enum_net.hpp b/include/libtorrent/enum_net.hpp index 4b827df44..a50e02c19 100644 --- a/include/libtorrent/enum_net.hpp +++ b/include/libtorrent/enum_net.hpp @@ -53,8 +53,6 @@ POSSIBILITY OF SUCH DAMAGE. namespace libtorrent { - struct socket_type; - // the interface should not have a netmask struct ip_interface { diff --git a/include/libtorrent/http_connection.hpp b/include/libtorrent/http_connection.hpp index f3b7dda4a..a733b6001 100644 --- a/include/libtorrent/http_connection.hpp +++ b/include/libtorrent/http_connection.hpp @@ -53,8 +53,8 @@ namespace ssl { #include "libtorrent/http_parser.hpp" #include "libtorrent/deadline_timer.hpp" #include "libtorrent/assert.hpp" -#include "libtorrent/socket_type.hpp" #include "libtorrent/i2p_stream.hpp" +#include "libtorrent/aux_/socket_type.hpp" #include "libtorrent/aux_/vector.hpp" #include "libtorrent/resolver_interface.hpp" #include "libtorrent/optional.hpp" @@ -125,7 +125,7 @@ struct TORRENT_EXTRA_EXPORT http_connection void close(bool force = false); - socket_type const& socket() const { return m_sock; } + aux::socket_type const& socket() const { return m_sock; } std::vector const& endpoints() const { return m_endpoints; } @@ -160,7 +160,7 @@ private: // endpoint with this index (in m_endpoints) next int m_next_ep; - socket_type m_sock; + aux::socket_type m_sock; #ifdef TORRENT_USE_OPENSSL ssl::context* m_ssl_ctx; diff --git a/include/libtorrent/instantiate_connection.hpp b/include/libtorrent/instantiate_connection.hpp index 8ba4d7a15..0ea23b575 100644 --- a/include/libtorrent/instantiate_connection.hpp +++ b/include/libtorrent/instantiate_connection.hpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_INSTANTIATE_CONNECTION #define TORRENT_INSTANTIATE_CONNECTION -#include "libtorrent/socket_type.hpp" +#include "libtorrent/aux_/socket_type.hpp" namespace libtorrent { @@ -43,11 +43,10 @@ namespace libtorrent { } struct utp_socket_manager; - struct socket_type; // instantiate a socket_type (s) according to the specified criteria TORRENT_EXTRA_EXPORT bool instantiate_connection(io_service& ios - , aux::proxy_settings const& ps, socket_type& s + , aux::proxy_settings const& ps, aux::socket_type& s , void* ssl_context , utp_socket_manager* sm , bool peer_connection diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index dbbe4ac30..dbe93340a 100644 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -41,13 +41,11 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_request.hpp" #include "libtorrent/piece_block_progress.hpp" #include "libtorrent/bandwidth_limit.hpp" -#include "libtorrent/socket_type_fwd.hpp" #include "libtorrent/assert.hpp" #include "libtorrent/chained_buffer.hpp" #include "libtorrent/disk_buffer_holder.hpp" #include "libtorrent/bitfield.hpp" #include "libtorrent/bandwidth_socket.hpp" -#include "libtorrent/socket_type_fwd.hpp" #include "libtorrent/error_code.hpp" #include "libtorrent/sliding_average.hpp" #include "libtorrent/peer_class.hpp" @@ -89,7 +87,9 @@ namespace libtorrent { namespace aux { + struct socket_type; struct session_interface; + } struct pending_block @@ -143,7 +143,7 @@ namespace aux { disk_interface* disk_thread; io_service* ios; std::weak_ptr tor; - std::shared_ptr s; + std::shared_ptr s; tcp::endpoint endp; torrent_peer* peerinfo; }; @@ -444,7 +444,7 @@ namespace aux { void timeout_requests(); - std::shared_ptr get_socket() const { return m_socket; } + std::shared_ptr get_socket() const { return m_socket; } tcp::endpoint const& remote() const override { return m_remote; } tcp::endpoint local_endpoint() const override { return m_local; } @@ -775,7 +775,7 @@ namespace aux { int wanted_transfer(int channel); int request_bandwidth(int channel, int bytes = 0); - std::shared_ptr m_socket; + std::shared_ptr m_socket; // the queue of blocks we have requested // from this peer diff --git a/include/libtorrent/socket_type_fwd.hpp b/include/libtorrent/socket_type_fwd.hpp deleted file mode 100644 index cf6098b67..000000000 --- a/include/libtorrent/socket_type_fwd.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - -Copyright (c) 2009-2016, Arvid Norberg -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - * Neither the name of the author nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -*/ - -#ifndef TORRENT_SOCKET_TYPE_FWD_HPP -#define TORRENT_SOCKET_TYPE_FWD_HPP - -namespace libtorrent { - - struct socket_type; -} - -#endif - diff --git a/include/libtorrent/utp_socket_manager.hpp b/include/libtorrent/utp_socket_manager.hpp index 30ea98d48..54e0415e8 100644 --- a/include/libtorrent/utp_socket_manager.hpp +++ b/include/libtorrent/utp_socket_manager.hpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include "libtorrent/socket_type.hpp" +#include "libtorrent/aux_/socket_type.hpp" #include "libtorrent/session_status.hpp" #include "libtorrent/enum_net.hpp" #include "libtorrent/aux_/session_settings.hpp" @@ -64,7 +64,7 @@ namespace libtorrent { , span , error_code&, udp_send_flags_t)>; - using incoming_utp_callback_t = std::function const&)>; + using incoming_utp_callback_t = std::function const&)>; utp_socket_manager(send_fun_t const& send_fun , incoming_utp_callback_t const& cb diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index a8533cc0e..10372872b 100644 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -58,7 +58,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/peer_info.hpp" #include "libtorrent/random.hpp" #include "libtorrent/aux_/alloca.hpp" -#include "libtorrent/socket_type.hpp" +#include "libtorrent/aux_/socket_type.hpp" #include "libtorrent/performance_counters.hpp" // for counters #include "libtorrent/alert_manager.hpp" // for alert_manager #include "libtorrent/string_util.hpp" // for search diff --git a/src/enum_net.cpp b/src/enum_net.cpp index 942b02495..02d877a6c 100644 --- a/src/enum_net.cpp +++ b/src/enum_net.cpp @@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/enum_net.hpp" #include "libtorrent/broadcast_socket.hpp" #include "libtorrent/assert.hpp" -#include "libtorrent/socket_type.hpp" +#include "libtorrent/aux_/socket_type.hpp" #ifdef TORRENT_WINDOWS #include "libtorrent/aux_/win_util.hpp" #endif diff --git a/src/http_connection.cpp b/src/http_connection.cpp index c39d1fffa..be607f9a5 100644 --- a/src/http_connection.cpp +++ b/src/http_connection.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/gzip.hpp" #include "libtorrent/parse_url.hpp" #include "libtorrent/socket.hpp" -#include "libtorrent/socket_type.hpp" // for async_shutdown +#include "libtorrent/aux_/socket_type.hpp" // for async_shutdown #include "libtorrent/resolver_interface.hpp" #include "libtorrent/settings_pack.hpp" #include "libtorrent/aux_/time.hpp" diff --git a/src/instantiate_connection.cpp b/src/instantiate_connection.cpp index dc4ee69bd..6a9110680 100644 --- a/src/instantiate_connection.cpp +++ b/src/instantiate_connection.cpp @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/socket.hpp" -#include "libtorrent/socket_type.hpp" +#include "libtorrent/aux_/socket_type.hpp" #include "libtorrent/utp_socket_manager.hpp" #include "libtorrent/instantiate_connection.hpp" @@ -40,7 +40,7 @@ namespace libtorrent { // TODO: 2 peer_connection and tracker_connection should probably be flags // TODO: 2 move this function into libtorrent::aux namespace bool instantiate_connection(io_service& ios - , aux::proxy_settings const& ps, socket_type& s + , aux::proxy_settings const& ps, aux::socket_type& s , void* ssl_context , utp_socket_manager* sm , bool peer_connection diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index b473cf741..2413ff535 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -44,7 +44,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/extensions.hpp" #include "libtorrent/aux_/session_interface.hpp" #include "libtorrent/peer_list.hpp" -#include "libtorrent/socket_type.hpp" +#include "libtorrent/aux_/socket_type.hpp" #include "libtorrent/assert.hpp" #include "libtorrent/broadcast_socket.hpp" #include "libtorrent/torrent.hpp" diff --git a/src/peer_list.cpp b/src/peer_list.cpp index 4666f829f..8e11aaef5 100644 --- a/src/peer_list.cpp +++ b/src/peer_list.cpp @@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/web_peer_connection.hpp" #include "libtorrent/peer_list.hpp" #include "libtorrent/socket.hpp" -#include "libtorrent/socket_type.hpp" +#include "libtorrent/aux_/socket_type.hpp" #include "libtorrent/invariant_check.hpp" #include "libtorrent/time.hpp" #include "libtorrent/aux_/session_interface.hpp" diff --git a/src/request_blocks.cpp b/src/request_blocks.cpp index 868f63b31..d48f0930f 100644 --- a/src/request_blocks.cpp +++ b/src/request_blocks.cpp @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/bitfield.hpp" #include "libtorrent/peer_connection.hpp" #include "libtorrent/torrent.hpp" -#include "libtorrent/socket_type.hpp" +#include "libtorrent/aux_/socket_type.hpp" #include "libtorrent/peer_info.hpp" // for peer_info flags #include "libtorrent/performance_counters.hpp" // for counters #include "libtorrent/request_blocks.hpp" diff --git a/src/socket_type.cpp b/src/socket_type.cpp index c1b18c1bb..008befd7b 100644 --- a/src/socket_type.cpp +++ b/src/socket_type.cpp @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "libtorrent/config.hpp" -#include "libtorrent/socket_type.hpp" +#include "libtorrent/aux_/socket_type.hpp" #include "libtorrent/aux_/openssl.hpp" #ifdef TORRENT_USE_OPENSSL @@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/debug.hpp" namespace libtorrent { +namespace aux { bool is_ssl(socket_type const& s) { @@ -396,3 +397,5 @@ namespace libtorrent { #endif } +} + diff --git a/src/torrent.cpp b/src/torrent.cpp index 0c089d389..05b51865d 100644 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -5910,8 +5910,8 @@ namespace libtorrent { if (!web->have_files.empty() && web->have_files.none_set()) return; - std::shared_ptr s - = std::make_shared(m_ses.get_io_service()); + std::shared_ptr s + = std::make_shared(m_ses.get_io_service()); if (!s) return; void* userdata = nullptr; @@ -6488,7 +6488,7 @@ namespace libtorrent { || !m_ip_filter || (m_ip_filter->access(peerinfo->address()) & ip_filter::blocked) == 0); - std::shared_ptr s = std::make_shared(m_ses.get_io_service()); + std::shared_ptr s = std::make_shared(m_ses.get_io_service()); #if TORRENT_USE_I2P bool const i2p = peerinfo->is_i2p_addr; @@ -6562,7 +6562,7 @@ namespace libtorrent { // for ssl sockets, set the hostname std::string host_name = aux::to_hex(m_torrent_file->info_hash()); -#define CASE(t) case socket_type_int_impl>::value: \ +#define CASE(t) case aux::socket_type_int_impl>::value: \ s->get>()->set_host_name(host_name); break; switch (s->type()) @@ -6750,10 +6750,10 @@ namespace libtorrent { if (is_ssl_torrent()) { // if this is an SSL torrent, don't allow non SSL peers on it - std::shared_ptr s = p->get_socket(); + std::shared_ptr s = p->get_socket(); // -#define SSL(t) socket_type_int_impl>::value: \ +#define SSL(t) aux::socket_type_int_impl>::value: \ ssl_conn = s->get>()->native_handle(); \ break; diff --git a/src/ut_pex.cpp b/src/ut_pex.cpp index 7dedd7f8d..2d3dba9c0 100644 --- a/src/ut_pex.cpp +++ b/src/ut_pex.cpp @@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/broadcast_socket.hpp" #include "libtorrent/socket_io.hpp" #include "libtorrent/peer_info.hpp" -#include "libtorrent/socket_type.hpp" // for is_utp +#include "libtorrent/aux_/socket_type.hpp" // for is_utp #include "libtorrent/performance_counters.hpp" // for counters #include "libtorrent/extensions/ut_pex.hpp" #include "libtorrent/aux_/time.hpp" diff --git a/src/utp_socket_manager.cpp b/src/utp_socket_manager.cpp index 5d537b29b..e46ee84fe 100644 --- a/src/utp_socket_manager.cpp +++ b/src/utp_socket_manager.cpp @@ -209,7 +209,7 @@ namespace libtorrent { // UTP_LOGV("not found, new connection id:%d\n", m_new_connection); - std::shared_ptr c(new (std::nothrow) socket_type(m_ios)); + std::shared_ptr c(new (std::nothrow) aux::socket_type(m_ios)); if (!c) return false; TORRENT_ASSERT(m_new_connection == -1);