From 2dbfa156d36f3a988ab4e36209575ead56907996 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 8 Mar 2007 21:42:37 +0000 Subject: [PATCH] client test now always uses dht. fixed problem with the dht logging and updated dht extension docs. --- docs/dht_extensions.html | 26 ++++++++++++++----------- docs/dht_extensions.rst | 15 +++++++++----- examples/client_test.cpp | 2 ++ include/libtorrent/kademlia/logging.hpp | 2 +- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/docs/dht_extensions.html b/docs/dht_extensions.html index faa1fb3a8..96c6b39ed 100644 --- a/docs/dht_extensions.html +++ b/docs/dht_extensions.html @@ -19,11 +19,11 @@ Arvid Norberg, arvid@rasterbar.com -
-

Mainline DHT extensions

+
+

Mainline DHT extensions

libtorrent implements a few extensions to the Mainline DHT protocol.

-
-

client identification

+
+

client identification

In each DHT packet, an extra key is inserted named "v". This is a string describing the client and version used. This can help alot when debugging and finding errors in client implementations. The string is encoded as four @@ -51,15 +51,19 @@ as a binary number describing the client version.

-
-

IPv6 support

-

The only DHT messages that don't support IPv6 is the nodes reply. It -encodes all the contacts as 6 bytes sequences packed together in sequence in +

+

IPv6 support

+

The DHT messages that don't support IPv6 are the nodes replies. +They encode all the contacts as 6 bytes packed together in sequence in a string. The problem is that IPv6 endpoints cannot be encoded as 6 bytes, but needs 18 bytes. The extension libtorrent applies is to add another key, called -nodes2 which is encoded as a list of strings. Each string represents one -contact and is encoded as 20 bytes node-id and then a variable length encoded -IP address (6 bytes in IPv4 case and 18 bytes in IPv6 case).

+nodes2.

+

nodes2 may be present in replies that contains a nodes key. It is encoded +as a list of strings. Each string represents one contact and is encoded as 20 +bytes node-id and then a variable length encoded IP address (6 bytes in IPv4 case +and 18 bytes in IPv6 case).

+

As an optimization, libtorrent does not include the extra key in case there are +only IPv4 nodes present.

diff --git a/docs/dht_extensions.rst b/docs/dht_extensions.rst index 424f90978..6d64a8c18 100644 --- a/docs/dht_extensions.rst +++ b/docs/dht_extensions.rst @@ -29,12 +29,17 @@ Currently known clients: IPv6 support ------------ -The only DHT messages that don't support IPv6 is the ``nodes`` reply. It -encodes all the contacts as 6 bytes sequences packed together in sequence in +The DHT messages that don't support IPv6 are the ``nodes`` replies. +They encode all the contacts as 6 bytes packed together in sequence in a string. The problem is that IPv6 endpoints cannot be encoded as 6 bytes, but needs 18 bytes. The extension libtorrent applies is to add another key, called -``nodes2`` which is encoded as a list of strings. Each string represents one -contact and is encoded as 20 bytes node-id and then a variable length encoded -IP address (6 bytes in IPv4 case and 18 bytes in IPv6 case). +``nodes2``. +``nodes2`` may be present in replies that contains a ``nodes`` key. It is encoded +as a list of strings. Each string represents one contact and is encoded as 20 +bytes node-id and then a variable length encoded IP address (6 bytes in IPv4 case +and 18 bytes in IPv6 case). + +As an optimization, libtorrent does not include the extra key in case there are +only IPv4 nodes present. diff --git a/examples/client_test.cpp b/examples/client_test.cpp index f46ed1062..7070ec513 100755 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -588,6 +588,8 @@ int main(int ac, char* av[]) ses.add_extension(&create_ut_pex_plugin); #ifndef TORRENT_DISABLE_DHT + settings.use_dht_as_fallback = false; + dht_settings s; s.service_port = listen_port; ses.set_dht_settings(s); diff --git a/include/libtorrent/kademlia/logging.hpp b/include/libtorrent/kademlia/logging.hpp index 8bd488f1a..c0cbb31a4 100644 --- a/include/libtorrent/kademlia/logging.hpp +++ b/include/libtorrent/kademlia/logging.hpp @@ -133,7 +133,7 @@ public: #define TORRENT_DEFINE_LOG(name) \ libtorrent::dht::log& name ## _log() \ { \ - static std::ofstream log_file("libtorrent_logs/dht.log", std::ios::app); \ + static std::ofstream log_file("dht.log", std::ios::app); \ static libtorrent::dht::log instance(#name, log_file); \ return instance; \ }