forked from premiere/premiere-libtorrent
Merge pull request #1044 from arvidn/bootstrap-hint-1.1
hint DHT bootstrap nodes of actual bootstrap request
This commit is contained in:
commit
35846d0c7c
|
@ -1,3 +1,5 @@
|
||||||
|
* hint DHT bootstrap nodes of actual bootstrap request
|
||||||
|
|
||||||
1.1.1 release
|
1.1.1 release
|
||||||
|
|
||||||
* update puff.c for gzip inflation
|
* update puff.c for gzip inflation
|
||||||
|
|
|
@ -208,10 +208,12 @@ struct fake_node
|
||||||
|
|
||||||
lt::bdecode_node n;
|
lt::bdecode_node n;
|
||||||
boost::system::error_code err;
|
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);
|
, n, err, nullptr, 10, 200);
|
||||||
TEST_EQUAL(ret, 0);
|
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
|
// TODO: ideally we would validate the DHT message
|
||||||
m_tripped = true;
|
m_tripped = true;
|
||||||
});
|
});
|
||||||
|
@ -224,9 +226,14 @@ struct fake_node
|
||||||
|
|
||||||
bool tripped() const { return m_tripped; }
|
bool tripped() const { return m_tripped; }
|
||||||
|
|
||||||
|
std::vector<std::vector<char>> const& incoming_packets() const
|
||||||
|
{ return m_incoming_packets; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
char m_in_buffer[300];
|
std::array<char, 300> m_in_buffer;
|
||||||
|
|
||||||
|
std::vector<std::vector<char>> m_incoming_packets;
|
||||||
|
|
||||||
asio::io_service m_ios;
|
asio::io_service m_ios;
|
||||||
asio::ip::udp::socket m_socket;
|
asio::ip::udp::socket m_socket;
|
||||||
|
|
|
@ -92,5 +92,15 @@ TORRENT_TEST(dht_bootstrap)
|
||||||
sim.run();
|
sim.run();
|
||||||
|
|
||||||
TEST_EQUAL(node.tripped(), true);
|
TEST_EQUAL(node.tripped(), true);
|
||||||
|
|
||||||
|
std::vector<char> 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,14 @@ bool bootstrap::invoke(observer_ptr o)
|
||||||
make_id_secret(target);
|
make_id_secret(target);
|
||||||
a["info_hash"] = target.to_string();
|
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";
|
// e["q"] = "find_node";
|
||||||
// a["target"] = target.to_string();
|
// a["target"] = target.to_string();
|
||||||
m_node.stats_counters().inc_stats_counter(counters::dht_get_peers_out);
|
m_node.stats_counters().inc_stats_counter(counters::dht_get_peers_out);
|
||||||
|
|
Loading…
Reference in New Issue