diff --git a/ChangeLog b/ChangeLog index e4c6f2fca..da4c2fa53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,5 @@ + * hint DHT bootstrap nodes of actual bootstrap request + 1.1.1 release * update puff.c for gzip inflation diff --git a/simulation/fake_peer.hpp b/simulation/fake_peer.hpp index 1ed6925d0..c113680b0 100644 --- a/simulation/fake_peer.hpp +++ b/simulation/fake_peer.hpp @@ -208,10 +208,12 @@ struct fake_node lt::bdecode_node n; boost::system::error_code err; - int const ret = bdecode(m_in_buffer, m_in_buffer + bytes_transferred + int const ret = bdecode(m_in_buffer.data(), m_in_buffer.data() + bytes_transferred , n, err, nullptr, 10, 200); TEST_EQUAL(ret, 0); + m_incoming_packets.emplace_back(m_in_buffer.data(), m_in_buffer.data() + bytes_transferred); + // TODO: ideally we would validate the DHT message m_tripped = true; }); @@ -224,9 +226,14 @@ struct fake_node bool tripped() const { return m_tripped; } + std::vector> const& incoming_packets() const + { return m_incoming_packets; } + private: - char m_in_buffer[300]; + std::array m_in_buffer; + + std::vector> m_incoming_packets; asio::io_service m_ios; asio::ip::udp::socket m_socket; diff --git a/simulation/test_dht_bootstrap.cpp b/simulation/test_dht_bootstrap.cpp index fe3af95cf..d01703f8b 100644 --- a/simulation/test_dht_bootstrap.cpp +++ b/simulation/test_dht_bootstrap.cpp @@ -92,5 +92,15 @@ TORRENT_TEST(dht_bootstrap) sim.run(); TEST_EQUAL(node.tripped(), true); + + std::vector const& p = node.incoming_packets().front(); + lt::bdecode_node n; + boost::system::error_code err; + int const ret = bdecode(p.data(), p.data() + p.size() + , n, err, nullptr, 10, 200); + TEST_EQUAL(ret, 0); + + lt::bdecode_node a = n.dict_find_dict("a"); + TEST_CHECK(a.dict_find_int_value("bs", -1) == 1); } diff --git a/src/kademlia/refresh.cpp b/src/kademlia/refresh.cpp index 998e6efd1..e6aa5c70f 100644 --- a/src/kademlia/refresh.cpp +++ b/src/kademlia/refresh.cpp @@ -65,6 +65,14 @@ bool bootstrap::invoke(observer_ptr o) make_id_secret(target); a["info_hash"] = target.to_string(); + if (o->flags & observer::flag_initial) + { + // if this packet is being sent to a bootstrap/router node, let it know + // that we're actualy bootstrapping (as opposed to being collateral + // traffic). + a["bs"] = 1; + } + // e["q"] = "find_node"; // a["target"] = target.to_string(); m_node.stats_counters().inc_stats_counter(counters::dht_get_peers_out);