From 31ce1e5a2cc57d376128047374a804f6b68b3906 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Mon, 26 Sep 2016 18:04:42 -0400 Subject: [PATCH] dht headers and minor cleanup (#1157) --- include/libtorrent/io_service.hpp | 23 ++++----------------- include/libtorrent/kademlia/dht_tracker.hpp | 6 ++---- include/libtorrent/kademlia/node.hpp | 20 ++---------------- src/kademlia/dht_tracker.cpp | 11 +--------- src/kademlia/node.cpp | 12 +++++------ test/test_dht.cpp | 1 + 6 files changed, 16 insertions(+), 57 deletions(-) diff --git a/include/libtorrent/io_service.hpp b/include/libtorrent/io_service.hpp index f64673805..f527aeed8 100644 --- a/include/libtorrent/io_service.hpp +++ b/include/libtorrent/io_service.hpp @@ -33,28 +33,13 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef TORRENT_IO_SERVICE_HPP_INCLUDED #define TORRENT_IO_SERVICE_HPP_INCLUDED -#ifdef __OBJC__ -#define Protocol Protocol_ -#endif - -#include "libtorrent/aux_/disable_warnings_push.hpp" - -#if defined TORRENT_WINDOWS || defined TORRENT_CYGWIN -// asio assumes that the windows error codes are defined already -#include -#endif - -#include - #if defined TORRENT_BUILD_SIMULATOR #include "simulator/simulator.hpp" -#endif - +#else +#include "libtorrent/aux_/disable_warnings_push.hpp" +#include #include "libtorrent/aux_/disable_warnings_pop.hpp" - -#ifdef __OBJC__ -#undef Protocol -#endif +#endif // SIMULATOR namespace libtorrent { diff --git a/include/libtorrent/kademlia/dht_tracker.hpp b/include/libtorrent/kademlia/dht_tracker.hpp index 7448c83e3..414534a52 100644 --- a/include/libtorrent/kademlia/dht_tracker.hpp +++ b/include/libtorrent/kademlia/dht_tracker.hpp @@ -36,20 +36,18 @@ POSSIBILITY OF SUCH DAMAGE. #include #include -#include -#include #include #include -#include -#include #include #include #include +#include namespace libtorrent { struct counters; + struct dht_settings; #ifndef TORRENT_NO_DEPRECATE struct session_status; #endif diff --git a/include/libtorrent/kademlia/node.hpp b/include/libtorrent/kademlia/node.hpp index 88fb08811..4fa3fdf54 100644 --- a/include/libtorrent/kademlia/node.hpp +++ b/include/libtorrent/kademlia/node.hpp @@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE. #ifndef NODE_HPP #define NODE_HPP -#include #include #include #include @@ -45,21 +44,15 @@ POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include -#include #include // for udp::endpoint -#include -#include -#include #include -#include "libtorrent/socket.hpp" - namespace libtorrent { struct counters; struct dht_routing_bucket; + struct dht_settings; } namespace libtorrent { namespace dht @@ -237,13 +230,7 @@ public: rpc_manager m_rpc; private: -#ifdef _MSC_VER -#pragma warning(push) -// warning: default constructor could not be generated -#pragma warning(disable: 4510) -// warning: struct can never be instantiated -#pragma warning(disable: 4610) -#endif + struct protocol_descriptor { udp protocol; @@ -251,9 +238,6 @@ private: char const* nodes_key; }; -#ifdef _MSC_VER -#pragma warning(pop) -#endif static protocol_descriptor const& map_protocol_to_descriptor(udp protocol); std::map const& m_nodes; diff --git a/src/kademlia/dht_tracker.cpp b/src/kademlia/dht_tracker.cpp index 7a0f85bf4..07b32e259 100644 --- a/src/kademlia/dht_tracker.cpp +++ b/src/kademlia/dht_tracker.cpp @@ -32,32 +32,23 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/dht_tracker.hpp" -#include -#include - #include -#include -#include -#include #include #include -#include -#include #include -#include #include #include #include // for counters #include #include +#include #ifndef TORRENT_DISABLE_LOGGING #include // to_hex #endif -using libtorrent::detail::write_endpoint; using namespace std::placeholders; namespace libtorrent { namespace dht diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index a8ed262bf..b3d484745 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -41,18 +41,16 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/hex.hpp" // to_hex #endif -#include "libtorrent/io.hpp" +#include +#include #include "libtorrent/bencode.hpp" #include "libtorrent/hasher.hpp" -#include "libtorrent/socket.hpp" #include "libtorrent/random.hpp" -#include "libtorrent/aux_/session_impl.hpp" +#include +#include #include "libtorrent/alert_types.hpp" // for dht_lookup #include "libtorrent/performance_counters.hpp" // for counters -#include "libtorrent/kademlia/node_id.hpp" -#include "libtorrent/kademlia/rpc_manager.hpp" -#include "libtorrent/kademlia/routing_table.hpp" #include "libtorrent/kademlia/node.hpp" #include "libtorrent/kademlia/dht_observer.hpp" #include "libtorrent/kademlia/direct_request.hpp" @@ -61,6 +59,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/kademlia/get_peers.hpp" #include "libtorrent/kademlia/get_item.hpp" #include "libtorrent/kademlia/msg.hpp" +#include using namespace std::placeholders; @@ -1164,6 +1163,7 @@ void node::incoming_request(msg const& m, entry& e) } } +// TODO: limit number of entries in the result void node::write_nodes_entries(sha1_hash const& info_hash , bdecode_node const& want, entry& r) { diff --git a/test/test_dht.cpp b/test/test_dht.cpp index d676ba246..1e5363434 100644 --- a/test/test_dht.cpp +++ b/test/test_dht.cpp @@ -46,6 +46,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/random.hpp" #include "libtorrent/kademlia/ed25519.hpp" #include "libtorrent/hex.hpp" // to_hex, from_hex +#include "libtorrent/bloom_filter.hpp" #include "libtorrent/kademlia/node_id.hpp" #include "libtorrent/kademlia/routing_table.hpp"