Browse Source

some more debuging to make sure new dht announce x torrent peers is working

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
7af7927f5d
  1. 2
      libtorrent/src/kademlia/node.cpp
  2. 26
      libtorrent/src/torrent.cpp
  3. 2
      src/twister.cpp

2
libtorrent/src/kademlia/node.cpp

@ -423,6 +423,8 @@ void node_impl::announce(std::string const& trackerName, sha1_hash const& info_h
#ifdef TORRENT_DHT_VERBOSE_LOGGING #ifdef TORRENT_DHT_VERBOSE_LOGGING
TORRENT_LOG(node) << "announcing [ ih: " << info_hash << " p: " << listen_port << " ]" ; TORRENT_LOG(node) << "announcing [ ih: " << info_hash << " p: " << listen_port << " ]" ;
#endif #endif
printf("node_impl::announce '%s' host: %s:%d myself=%d\n", trackerName.c_str(), addr.to_string().c_str(), listen_port, myself);
add_peer( trackerName, info_hash, addr, listen_port, seed ); add_peer( trackerName, info_hash, addr, listen_port, seed );
// do not announce other peers, just add them to our local m_map. // do not announce other peers, just add them to our local m_map.

26
libtorrent/src/torrent.cpp

@ -88,6 +88,7 @@ POSSIBILITY OF SUCH DAMAGE.
#endif // BOOST_VERSION #endif // BOOST_VERSION
#endif // TORRENT_USE_OPENSSL #endif // TORRENT_USE_OPENSSL
#include "../../src/util.h"
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING #if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
#include "libtorrent/struct_debug.hpp" #include "libtorrent/struct_debug.hpp"
#endif #endif
@ -201,6 +202,8 @@ namespace
peer_id const& pid; peer_id const& pid;
}; };
void nop() {}
} }
namespace libtorrent namespace libtorrent
@ -2239,6 +2242,22 @@ namespace libtorrent
TORRENT_ASSERT(m_allow_peers); TORRENT_ASSERT(m_allow_peers);
// [MF] use m_dht->announce with myself=false to update dht tracker with other peers
{
policy::const_iterator i = get_policy().begin_peer();
policy::const_iterator end = get_policy().end_peer();
for (; i != end; ++i)
{
policy::peer const* p = *i;
if( p->connectable && !p->banned ) {
m_ses.m_dht->announce(*m_name, m_torrent_file->info_hash()
, p->address(), p->port, p->seed, false
, boost::bind(&nop));
}
}
}
#ifdef TORRENT_USE_OPENSSL #ifdef TORRENT_USE_OPENSSL
int port = is_ssl_torrent() ? m_ses.ssl_listen_port() : m_ses.listen_port(); int port = is_ssl_torrent() ? m_ses.ssl_listen_port() : m_ses.listen_port();
#else #else
@ -2284,6 +2303,9 @@ namespace libtorrent
localpeer.port(port); localpeer.port(port);
BOOST_FOREACH(tcp::endpoint const& p, peers) { BOOST_FOREACH(tcp::endpoint const& p, peers) {
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
debug_log("on_dht_announce_response %s:%d (local=%d)", p.address().to_string().c_str(), p.port(), p==localpeer);
#endif
if( p != localpeer ) { if( p != localpeer ) {
m_policy.add_peer(p, peer_id(0), peer_info::dht, 0); m_policy.add_peer(p, peer_id(0), peer_info::dht, 0);
} }
@ -8982,7 +9004,9 @@ namespace libtorrent
char buf[1280]; char buf[1280];
snprintf(buf, sizeof(buf), "%s: %s: %s\n", time_now_string() snprintf(buf, sizeof(buf), "%s: %s: %s\n", time_now_string()
, to_hex(info_hash().to_string()).substr(0, 6).c_str(), usr); , to_hex(info_hash().to_string()).substr(0, 6).c_str(), usr);
(*m_ses.m_logger) << buf; //(*m_ses.m_logger) << buf;
// [MF]
printf(buf);
} }
#endif #endif

2
src/twister.cpp

@ -184,6 +184,8 @@ void ThreadWaitExtIP()
// settings to test local connections // settings to test local connections
settings.allow_multiple_connections_per_ip = true; settings.allow_multiple_connections_per_ip = true;
settings.enable_outgoing_utp = false; // test (netstat display) settings.enable_outgoing_utp = false; // test (netstat display)
//settings.dht_announce_interval = 60; // test
//settings.min_announce_interval = 60; // test
ses->set_settings(settings); ses->set_settings(settings);
printf("libtorrent + dht started\n"); printf("libtorrent + dht started\n");

Loading…
Cancel
Save