dht headers and minor cleanup (#1157)

This commit is contained in:
Alden Torres 2016-09-26 18:04:42 -04:00 committed by Arvid Norberg
parent 9cebd4569f
commit 31ce1e5a2c
6 changed files with 16 additions and 57 deletions

View File

@ -33,28 +33,13 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef TORRENT_IO_SERVICE_HPP_INCLUDED #ifndef TORRENT_IO_SERVICE_HPP_INCLUDED
#define 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 <winsock2.h>
#endif
#include <boost/asio/io_service.hpp>
#if defined TORRENT_BUILD_SIMULATOR #if defined TORRENT_BUILD_SIMULATOR
#include "simulator/simulator.hpp" #include "simulator/simulator.hpp"
#endif #else
#include "libtorrent/aux_/disable_warnings_push.hpp"
#include <boost/asio/io_service.hpp>
#include "libtorrent/aux_/disable_warnings_pop.hpp" #include "libtorrent/aux_/disable_warnings_pop.hpp"
#endif // SIMULATOR
#ifdef __OBJC__
#undef Protocol
#endif
namespace libtorrent namespace libtorrent
{ {

View File

@ -36,20 +36,18 @@ POSSIBILITY OF SUCH DAMAGE.
#include <functional> #include <functional>
#include <libtorrent/kademlia/node.hpp> #include <libtorrent/kademlia/node.hpp>
#include <libtorrent/kademlia/node_id.hpp>
#include <libtorrent/kademlia/traversal_algorithm.hpp>
#include <libtorrent/kademlia/dos_blocker.hpp> #include <libtorrent/kademlia/dos_blocker.hpp>
#include <libtorrent/kademlia/dht_state.hpp> #include <libtorrent/kademlia/dht_state.hpp>
#include <libtorrent/session_settings.hpp>
#include <libtorrent/udp_socket.hpp>
#include <libtorrent/socket.hpp> #include <libtorrent/socket.hpp>
#include <libtorrent/deadline_timer.hpp> #include <libtorrent/deadline_timer.hpp>
#include <libtorrent/span.hpp> #include <libtorrent/span.hpp>
#include <libtorrent/io_service.hpp>
namespace libtorrent namespace libtorrent
{ {
struct counters; struct counters;
struct dht_settings;
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
struct session_status; struct session_status;
#endif #endif

View File

@ -33,7 +33,6 @@ POSSIBILITY OF SUCH DAMAGE.
#ifndef NODE_HPP #ifndef NODE_HPP
#define NODE_HPP #define NODE_HPP
#include <algorithm>
#include <map> #include <map>
#include <set> #include <set>
#include <mutex> #include <mutex>
@ -45,21 +44,15 @@ POSSIBILITY OF SUCH DAMAGE.
#include <libtorrent/kademlia/rpc_manager.hpp> #include <libtorrent/kademlia/rpc_manager.hpp>
#include <libtorrent/kademlia/node_id.hpp> #include <libtorrent/kademlia/node_id.hpp>
#include <libtorrent/kademlia/find_data.hpp> #include <libtorrent/kademlia/find_data.hpp>
#include <libtorrent/kademlia/put_data.hpp>
#include <libtorrent/kademlia/item.hpp> #include <libtorrent/kademlia/item.hpp>
#include <libtorrent/io.hpp>
#include <libtorrent/socket.hpp> // for udp::endpoint #include <libtorrent/socket.hpp> // for udp::endpoint
#include <libtorrent/session_settings.hpp>
#include <libtorrent/assert.hpp>
#include <libtorrent/bloom_filter.hpp>
#include <libtorrent/string_view.hpp> #include <libtorrent/string_view.hpp>
#include "libtorrent/socket.hpp"
namespace libtorrent { namespace libtorrent {
struct counters; struct counters;
struct dht_routing_bucket; struct dht_routing_bucket;
struct dht_settings;
} }
namespace libtorrent { namespace dht namespace libtorrent { namespace dht
@ -237,13 +230,7 @@ public:
rpc_manager m_rpc; rpc_manager m_rpc;
private: 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 struct protocol_descriptor
{ {
udp protocol; udp protocol;
@ -251,9 +238,6 @@ private:
char const* nodes_key; char const* nodes_key;
}; };
#ifdef _MSC_VER
#pragma warning(pop)
#endif
static protocol_descriptor const& map_protocol_to_descriptor(udp protocol); static protocol_descriptor const& map_protocol_to_descriptor(udp protocol);
std::map<std::string, node*> const& m_nodes; std::map<std::string, node*> const& m_nodes;

View File

@ -32,32 +32,23 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/kademlia/dht_tracker.hpp" #include "libtorrent/kademlia/dht_tracker.hpp"
#include <set>
#include <numeric>
#include <libtorrent/config.hpp> #include <libtorrent/config.hpp>
#include <libtorrent/kademlia/node.hpp>
#include <libtorrent/kademlia/node_id.hpp>
#include <libtorrent/kademlia/traversal_algorithm.hpp>
#include <libtorrent/kademlia/msg.hpp> #include <libtorrent/kademlia/msg.hpp>
#include <libtorrent/kademlia/dht_observer.hpp> #include <libtorrent/kademlia/dht_observer.hpp>
#include <libtorrent/socket.hpp>
#include <libtorrent/socket_io.hpp>
#include <libtorrent/bencode.hpp> #include <libtorrent/bencode.hpp>
#include <libtorrent/io.hpp>
#include <libtorrent/version.hpp> #include <libtorrent/version.hpp>
#include <libtorrent/time.hpp> #include <libtorrent/time.hpp>
#include <libtorrent/performance_counters.hpp> // for counters #include <libtorrent/performance_counters.hpp> // for counters
#include <libtorrent/aux_/time.hpp> #include <libtorrent/aux_/time.hpp>
#include <libtorrent/session_status.hpp> #include <libtorrent/session_status.hpp>
#include <libtorrent/session_settings.hpp>
#ifndef TORRENT_DISABLE_LOGGING #ifndef TORRENT_DISABLE_LOGGING
#include <libtorrent/hex.hpp> // to_hex #include <libtorrent/hex.hpp> // to_hex
#endif #endif
using libtorrent::detail::write_endpoint;
using namespace std::placeholders; using namespace std::placeholders;
namespace libtorrent { namespace dht namespace libtorrent { namespace dht

View File

@ -41,18 +41,16 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/hex.hpp" // to_hex #include "libtorrent/hex.hpp" // to_hex
#endif #endif
#include "libtorrent/io.hpp" #include <libtorrent/socket_io.hpp>
#include <libtorrent/session_status.hpp>
#include "libtorrent/bencode.hpp" #include "libtorrent/bencode.hpp"
#include "libtorrent/hasher.hpp" #include "libtorrent/hasher.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/random.hpp" #include "libtorrent/random.hpp"
#include "libtorrent/aux_/session_impl.hpp" #include <libtorrent/assert.hpp>
#include <libtorrent/aux_/time.hpp>
#include "libtorrent/alert_types.hpp" // for dht_lookup #include "libtorrent/alert_types.hpp" // for dht_lookup
#include "libtorrent/performance_counters.hpp" // for counters #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/node.hpp"
#include "libtorrent/kademlia/dht_observer.hpp" #include "libtorrent/kademlia/dht_observer.hpp"
#include "libtorrent/kademlia/direct_request.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_peers.hpp"
#include "libtorrent/kademlia/get_item.hpp" #include "libtorrent/kademlia/get_item.hpp"
#include "libtorrent/kademlia/msg.hpp" #include "libtorrent/kademlia/msg.hpp"
#include <libtorrent/kademlia/put_data.hpp>
using namespace std::placeholders; 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 void node::write_nodes_entries(sha1_hash const& info_hash
, bdecode_node const& want, entry& r) , bdecode_node const& want, entry& r)
{ {

View File

@ -46,6 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/random.hpp" #include "libtorrent/random.hpp"
#include "libtorrent/kademlia/ed25519.hpp" #include "libtorrent/kademlia/ed25519.hpp"
#include "libtorrent/hex.hpp" // to_hex, from_hex #include "libtorrent/hex.hpp" // to_hex, from_hex
#include "libtorrent/bloom_filter.hpp"
#include "libtorrent/kademlia/node_id.hpp" #include "libtorrent/kademlia/node_id.hpp"
#include "libtorrent/kademlia/routing_table.hpp" #include "libtorrent/kademlia/routing_table.hpp"