2012-05-01 07:45:05 +02:00
|
|
|
/*
|
|
|
|
|
2018-04-09 09:04:33 +02:00
|
|
|
Copyright (c) 2012-2018, Arvid Norberg
|
2012-05-01 07:45:05 +02:00
|
|
|
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 DHT_OBSERVER_HPP
|
|
|
|
#define DHT_OBSERVER_HPP
|
|
|
|
|
2015-05-10 07:11:51 +02:00
|
|
|
#include "libtorrent/config.hpp"
|
2012-05-01 07:45:05 +02:00
|
|
|
#include "libtorrent/address.hpp"
|
2017-09-02 23:58:10 +02:00
|
|
|
#include "libtorrent/string_view.hpp"
|
2014-11-23 07:14:47 +01:00
|
|
|
#include "libtorrent/kademlia/msg.hpp"
|
2012-05-01 07:45:05 +02:00
|
|
|
|
2017-04-21 06:45:43 +02:00
|
|
|
namespace libtorrent {
|
|
|
|
|
2017-09-02 23:58:10 +02:00
|
|
|
class entry;
|
|
|
|
|
2017-07-21 05:19:28 +02:00
|
|
|
namespace aux { struct listen_socket_handle; }
|
2017-04-21 06:45:43 +02:00
|
|
|
|
|
|
|
namespace dht {
|
2017-04-12 19:00:57 +02:00
|
|
|
|
2015-11-19 01:51:17 +01:00
|
|
|
struct TORRENT_EXTRA_EXPORT dht_logger
|
2015-05-10 06:54:02 +02:00
|
|
|
{
|
2016-05-18 07:54:37 +02:00
|
|
|
#ifndef TORRENT_DISABLE_LOGGING
|
2015-05-16 21:29:49 +02:00
|
|
|
enum module_t
|
2015-05-10 06:54:02 +02:00
|
|
|
{
|
|
|
|
tracker,
|
|
|
|
node,
|
|
|
|
routing_table,
|
|
|
|
rpc_manager,
|
|
|
|
traversal
|
|
|
|
};
|
|
|
|
|
2015-05-16 21:29:49 +02:00
|
|
|
enum message_direction_t
|
|
|
|
{
|
|
|
|
incoming_message,
|
2015-05-28 22:36:22 +02:00
|
|
|
outgoing_message
|
2015-05-16 21:29:49 +02:00
|
|
|
};
|
|
|
|
|
2016-09-09 01:13:47 +02:00
|
|
|
virtual bool should_log(module_t m) const = 0;
|
2015-05-16 21:29:49 +02:00
|
|
|
virtual void log(module_t m, char const* fmt, ...) TORRENT_FORMAT(3,4) = 0;
|
2016-09-28 05:21:18 +02:00
|
|
|
virtual void log_packet(message_direction_t dir, span<char const> pkt
|
2016-09-16 03:13:43 +02:00
|
|
|
, udp::endpoint const& node) = 0;
|
2016-05-18 07:54:37 +02:00
|
|
|
#endif
|
2015-05-10 06:54:02 +02:00
|
|
|
|
|
|
|
protected:
|
2017-04-21 06:45:43 +02:00
|
|
|
~dht_logger() = default;
|
2015-05-10 06:54:02 +02:00
|
|
|
};
|
|
|
|
|
2015-11-19 01:51:17 +01:00
|
|
|
struct TORRENT_EXTRA_EXPORT dht_observer : dht_logger
|
2012-05-01 07:45:05 +02:00
|
|
|
{
|
2017-07-21 05:19:28 +02:00
|
|
|
virtual void set_external_address(aux::listen_socket_handle const& iface
|
2017-04-21 06:45:43 +02:00
|
|
|
, address const& addr, address const& source) = 0;
|
2015-04-03 22:15:48 +02:00
|
|
|
virtual void get_peers(sha1_hash const& ih) = 0;
|
|
|
|
virtual void outgoing_get_peers(sha1_hash const& target
|
|
|
|
, sha1_hash const& sent_target, udp::endpoint const& ep) = 0;
|
|
|
|
virtual void announce(sha1_hash const& ih, address const& addr, int port) = 0;
|
2016-08-15 22:17:13 +02:00
|
|
|
virtual bool on_dht_request(string_view query
|
2014-02-17 06:56:49 +01:00
|
|
|
, dht::msg const& request, entry& response) = 0;
|
2015-05-10 06:54:02 +02:00
|
|
|
|
2015-04-19 08:28:21 +02:00
|
|
|
protected:
|
2017-04-21 06:45:43 +02:00
|
|
|
~dht_observer() = default;
|
2012-05-01 07:45:05 +02:00
|
|
|
};
|
|
|
|
}}
|
|
|
|
|
|
|
|
#endif
|