|
|
@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE. |
|
|
|
#include <utility> |
|
|
|
#include <utility> |
|
|
|
#include <boost/bind.hpp> |
|
|
|
#include <boost/bind.hpp> |
|
|
|
#include <boost/function/function1.hpp> |
|
|
|
#include <boost/function/function1.hpp> |
|
|
|
|
|
|
|
//#include <boost/date_time/posix_time/time_formatters_limited.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
#include "libtorrent/io.hpp" |
|
|
|
#include "libtorrent/io.hpp" |
|
|
|
#include "libtorrent/bencode.hpp" |
|
|
|
#include "libtorrent/bencode.hpp" |
|
|
@ -400,7 +401,7 @@ void node_impl::add_node(udp::endpoint node) |
|
|
|
m_rpc.invoke(e, node, o); |
|
|
|
m_rpc.invoke(e, node, o); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void node_impl::announce(std::string const& trackerName, sha1_hash const& info_hash, address addr, int listen_port, bool seed, bool myself |
|
|
|
void node_impl::announce(std::string const& trackerName, sha1_hash const& info_hash, address addr, int listen_port, bool seed, bool myself, int list_peers |
|
|
|
, boost::function<void(std::vector<tcp::endpoint> const&)> f) |
|
|
|
, boost::function<void(std::vector<tcp::endpoint> const&)> f) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING |
|
|
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING |
|
|
@ -410,7 +411,7 @@ void node_impl::announce(std::string const& trackerName, sha1_hash const& info_h |
|
|
|
|
|
|
|
|
|
|
|
// [MF] is_unspecified() is not always available. never mind.
|
|
|
|
// [MF] is_unspecified() is not always available. never mind.
|
|
|
|
//if( !addr.is_unspecified() ) {
|
|
|
|
//if( !addr.is_unspecified() ) {
|
|
|
|
add_peer( trackerName, info_hash, addr, listen_port, seed ); |
|
|
|
add_peer( trackerName, info_hash, addr, listen_port, seed, list_peers ); |
|
|
|
//}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
@ -556,13 +557,18 @@ bool node_impl::refresh_storage() { |
|
|
|
m_last_refreshed_item = m_storage_table.begin()->first; |
|
|
|
m_last_refreshed_item = m_storage_table.begin()->first; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
time_duration sleepToRefresh; |
|
|
|
if( num_refreshable ) { |
|
|
|
if( num_refreshable ) { |
|
|
|
m_next_storage_refresh = minutes(60) / num_refreshable + time_now(); |
|
|
|
sleepToRefresh = minutes(60) / num_refreshable; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
m_next_storage_refresh = minutes(10) + time_now(); |
|
|
|
sleepToRefresh = minutes(10); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
m_next_storage_refresh = time_now() + sleepToRefresh; |
|
|
|
|
|
|
|
|
|
|
|
printf("node dht: next storage refresh in %d seconds\n", (m_next_storage_refresh - time_now())/1000000 ); |
|
|
|
/*
|
|
|
|
|
|
|
|
printf("node dht: next storage refresh in %s\n", |
|
|
|
|
|
|
|
boost::posix_time::to_simple_string(sleepToRefresh).c_str() ); |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
return did_something; |
|
|
|
return did_something; |
|
|
|
} |
|
|
|
} |
|
|
@ -762,6 +768,7 @@ void node_impl::lookup_peers(sha1_hash const& info_hash, int prefix, entry& repl |
|
|
|
torrent_entry const& v = i->second; |
|
|
|
torrent_entry const& v = i->second; |
|
|
|
|
|
|
|
|
|
|
|
if (!v.name.empty()) reply["n"] = v.name; |
|
|
|
if (!v.name.empty()) reply["n"] = v.name; |
|
|
|
|
|
|
|
reply["followers"] = v.list_peers; |
|
|
|
|
|
|
|
|
|
|
|
if (scrape) |
|
|
|
if (scrape) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -803,7 +810,7 @@ void node_impl::lookup_peers(sha1_hash const& info_hash, int prefix, entry& repl |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void node_impl::add_peer(std::string const &name, sha1_hash const& info_hash, address addr, int port, bool seed) |
|
|
|
void node_impl::add_peer(std::string const &name, sha1_hash const& info_hash, address addr, int port, bool seed, int list_peers) |
|
|
|
{ |
|
|
|
{ |
|
|
|
torrent_entry& v = m_map[info_hash]; |
|
|
|
torrent_entry& v = m_map[info_hash]; |
|
|
|
|
|
|
|
|
|
|
@ -814,6 +821,7 @@ void node_impl::add_peer(std::string const &name, sha1_hash const& info_hash, ad |
|
|
|
v.name = name; |
|
|
|
v.name = name; |
|
|
|
if (v.name.size() > 50) v.name.resize(50); |
|
|
|
if (v.name.size() > 50) v.name.resize(50); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (list_peers) v.list_peers = list_peers; |
|
|
|
|
|
|
|
|
|
|
|
peer_entry peer; |
|
|
|
peer_entry peer; |
|
|
|
peer.addr = tcp::endpoint(addr, port); |
|
|
|
peer.addr = tcp::endpoint(addr, port); |
|
|
@ -1144,7 +1152,7 @@ void node_impl::incoming_request(msg const& m, entry& e) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
add_peer( msg_keys[3] ? msg_keys[3]->string_value() : std::string(), info_hash, |
|
|
|
add_peer( msg_keys[3] ? msg_keys[3]->string_value() : std::string(), info_hash, |
|
|
|
m.addr.address(), port, msg_keys[4] && msg_keys[4]->int_value()); |
|
|
|
m.addr.address(), port, msg_keys[4] && msg_keys[4]->int_value(), 0); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING |
|
|
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING |
|
|
|
++g_announces; |
|
|
|
++g_announces; |
|
|
|