mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-03-10 12:31:27 +00:00
incompatible dht change: "y" => "z"
This commit is contained in:
parent
b8b2302d59
commit
5b98b52901
libtorrent
@ -60,9 +60,9 @@ query = 'get_peers'
|
|||||||
|
|
||||||
print 'test random info-hashes'
|
print 'test random info-hashes'
|
||||||
for i in xrange(1, 30000):
|
for i in xrange(1, 30000):
|
||||||
send_dht_message({'a': {'id': node_id, 'info_hash': random_key()}, 'q': query, 'y': 'q', 't': '%d' % i})
|
send_dht_message({'a': {'id': node_id, 'info_hash': random_key()}, 'q': query, 'z': 'q', 't': '%d' % i})
|
||||||
|
|
||||||
print 'test random peer-ids'
|
print 'test random peer-ids'
|
||||||
for i in xrange(1, 30000):
|
for i in xrange(1, 30000):
|
||||||
send_dht_message({'a': {'id': random_key(), 'info_hash': random_key()}, 'q': query, 'y': 'q', 't': '%d' % i})
|
send_dht_message({'a': {'id': random_key(), 'info_hash': random_key()}, 'q': query, 'z': 'q', 't': '%d' % i})
|
||||||
|
|
||||||
|
@ -636,7 +636,7 @@ namespace libtorrent { namespace dht
|
|||||||
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
#ifdef TORRENT_DHT_VERBOSE_LOGGING
|
||||||
m_total_out_bytes += m_send_buf.size();
|
m_total_out_bytes += m_send_buf.size();
|
||||||
|
|
||||||
if (e["y"].string() == "r")
|
if (e["z"].string() == "r")
|
||||||
{
|
{
|
||||||
// TODO: 2 fix this stats logging. For instance,
|
// TODO: 2 fix this stats logging. For instance,
|
||||||
// the stats counters could be factored out into its own
|
// the stats counters could be factored out into its own
|
||||||
@ -644,7 +644,7 @@ namespace libtorrent { namespace dht
|
|||||||
// ++m_replies_sent[e["r"]];
|
// ++m_replies_sent[e["r"]];
|
||||||
// m_replies_bytes_sent[e["r"]] += int(m_send_buf.size());
|
// m_replies_bytes_sent[e["r"]] += int(m_send_buf.size());
|
||||||
}
|
}
|
||||||
else if (e["y"].string() == "q")
|
else if (e["z"].string() == "q")
|
||||||
{
|
{
|
||||||
m_queries_out_bytes += m_send_buf.size();
|
m_queries_out_bytes += m_send_buf.size();
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ bool find_data::invoke(observer_ptr o)
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry e;
|
entry e;
|
||||||
e["y"] = "q";
|
e["z"] = "q";
|
||||||
e["q"] = "get_peers";
|
e["q"] = "get_peers";
|
||||||
entry& a = e["a"];
|
entry& a = e["a"];
|
||||||
a["info_hash"] = m_target.to_string();
|
a["info_hash"] = m_target.to_string();
|
||||||
|
@ -209,7 +209,7 @@ void node_impl::unreachable(udp::endpoint const& ep)
|
|||||||
void node_impl::incoming(msg const& m)
|
void node_impl::incoming(msg const& m)
|
||||||
{
|
{
|
||||||
// is this a reply?
|
// is this a reply?
|
||||||
lazy_entry const* y_ent = m.message.dict_find_string("y");
|
lazy_entry const* y_ent = m.message.dict_find_string("z");
|
||||||
if (!y_ent || y_ent->string_length() == 0)
|
if (!y_ent || y_ent->string_length() == 0)
|
||||||
{
|
{
|
||||||
entry e;
|
entry e;
|
||||||
@ -231,7 +231,7 @@ void node_impl::incoming(msg const& m)
|
|||||||
}
|
}
|
||||||
case 'q':
|
case 'q':
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(m.message.dict_find_string_value("y") == "q");
|
TORRENT_ASSERT(m.message.dict_find_string_value("z") == "q");
|
||||||
entry e;
|
entry e;
|
||||||
incoming_request(m, e);
|
incoming_request(m, e);
|
||||||
m_sock->send_packet(e, m.addr, 0);
|
m_sock->send_packet(e, m.addr, 0);
|
||||||
@ -281,7 +281,7 @@ namespace
|
|||||||
o->m_in_constructor = false;
|
o->m_in_constructor = false;
|
||||||
#endif
|
#endif
|
||||||
entry e;
|
entry e;
|
||||||
e["y"] = "q";
|
e["z"] = "q";
|
||||||
e["q"] = "announce_peer";
|
e["q"] = "announce_peer";
|
||||||
entry& a = e["a"];
|
entry& a = e["a"];
|
||||||
a["info_hash"] = ih.to_string();
|
a["info_hash"] = ih.to_string();
|
||||||
@ -318,7 +318,7 @@ void node_impl::add_node(udp::endpoint node)
|
|||||||
o->m_in_constructor = false;
|
o->m_in_constructor = false;
|
||||||
#endif
|
#endif
|
||||||
entry e;
|
entry e;
|
||||||
e["y"] = "q";
|
e["z"] = "q";
|
||||||
e["q"] = "ping";
|
e["q"] = "ping";
|
||||||
m_rpc.invoke(e, node, o);
|
m_rpc.invoke(e, node, o);
|
||||||
}
|
}
|
||||||
@ -593,7 +593,7 @@ bool verify_message(lazy_entry const* msg, key_desc_t const desc[], lazy_entry c
|
|||||||
|
|
||||||
void incoming_error(entry& e, char const* msg)
|
void incoming_error(entry& e, char const* msg)
|
||||||
{
|
{
|
||||||
e["y"] = "e";
|
e["z"] = "e";
|
||||||
entry::list_type& l = e["e"].list();
|
entry::list_type& l = e["e"].list();
|
||||||
l.push_back(entry(203));
|
l.push_back(entry(203));
|
||||||
l.push_back(entry(msg));
|
l.push_back(entry(msg));
|
||||||
@ -603,7 +603,7 @@ void incoming_error(entry& e, char const* msg)
|
|||||||
void node_impl::incoming_request(msg const& m, entry& e)
|
void node_impl::incoming_request(msg const& m, entry& e)
|
||||||
{
|
{
|
||||||
e = entry(entry::dictionary_t);
|
e = entry(entry::dictionary_t);
|
||||||
e["y"] = "r";
|
e["z"] = "r";
|
||||||
e["t"] = m.message.dict_find_string_value("t");
|
e["t"] = m.message.dict_find_string_value("t");
|
||||||
|
|
||||||
key_desc_t top_desc[] = {
|
key_desc_t top_desc[] = {
|
||||||
|
@ -71,7 +71,7 @@ observer_ptr refresh::new_observer(void* ptr
|
|||||||
bool refresh::invoke(observer_ptr o)
|
bool refresh::invoke(observer_ptr o)
|
||||||
{
|
{
|
||||||
entry e;
|
entry e;
|
||||||
e["y"] = "q";
|
e["z"] = "q";
|
||||||
e["q"] = "find_node";
|
e["q"] = "find_node";
|
||||||
entry& a = e["a"];
|
entry& a = e["a"];
|
||||||
a["target"] = target().to_string();
|
a["target"] = target().to_string();
|
||||||
|
@ -277,7 +277,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id)
|
|||||||
if (m_destructing) return false;
|
if (m_destructing) return false;
|
||||||
|
|
||||||
// we only deal with replies, not queries
|
// we only deal with replies, not queries
|
||||||
TORRENT_ASSERT(m.message.dict_find_string_value("y") == "r");
|
TORRENT_ASSERT(m.message.dict_find_string_value("z") == "r");
|
||||||
|
|
||||||
// if we don't have the transaction id in our
|
// if we don't have the transaction id in our
|
||||||
// request list, ignore the packet
|
// request list, ignore the packet
|
||||||
@ -465,7 +465,7 @@ bool rpc_manager::invoke(entry& e, udp::endpoint target_addr
|
|||||||
|
|
||||||
if (m_destructing) return false;
|
if (m_destructing) return false;
|
||||||
|
|
||||||
e["y"] = "q";
|
e["z"] = "q";
|
||||||
entry& a = e["a"];
|
entry& a = e["a"];
|
||||||
add_our_id(a);
|
add_our_id(a);
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ void send_dht_msg(node_impl& node, char const* msg, udp::endpoint const& ep
|
|||||||
entry e;
|
entry e;
|
||||||
e["q"] = msg;
|
e["q"] = msg;
|
||||||
e["t"] = t;
|
e["t"] = t;
|
||||||
e["y"] = "q";
|
e["z"] = "q";
|
||||||
entry::dictionary_type& a = e["a"].dict();
|
entry::dictionary_type& a = e["a"].dict();
|
||||||
a["id"] = generate_next().to_string();
|
a["id"] = generate_next().to_string();
|
||||||
if (info_hash) a["info_hash"] = std::string(info_hash, 20);
|
if (info_hash) a["info_hash"] = std::string(info_hash, 20);
|
||||||
@ -194,7 +194,7 @@ void announce_immutable_items(node_impl& node, udp::endpoint const* eps
|
|||||||
{ "id", lazy_entry::string_t, 20, 0},
|
{ "id", lazy_entry::string_t, 20, 0},
|
||||||
{ "token", lazy_entry::string_t, 0, 0},
|
{ "token", lazy_entry::string_t, 0, 0},
|
||||||
{ "ip", lazy_entry::string_t, 0, key_desc_t::optional | key_desc_t::last_child},
|
{ "ip", lazy_entry::string_t, 0, key_desc_t::optional | key_desc_t::last_child},
|
||||||
{ "y", lazy_entry::string_t, 1, 0},
|
{ "z", lazy_entry::string_t, 1, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
lazy_entry const* parsed[5];
|
lazy_entry const* parsed[5];
|
||||||
@ -228,7 +228,7 @@ void announce_immutable_items(node_impl& node, udp::endpoint const* eps
|
|||||||
|
|
||||||
key_desc_t desc2[] =
|
key_desc_t desc2[] =
|
||||||
{
|
{
|
||||||
{ "y", lazy_entry::string_t, 1, 0 }
|
{ "z", lazy_entry::string_t, 1, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = verify_message(&response, desc2, parsed, 1, error_string, sizeof(error_string));
|
ret = verify_message(&response, desc2, parsed, 1, error_string, sizeof(error_string));
|
||||||
@ -260,7 +260,7 @@ void announce_immutable_items(node_impl& node, udp::endpoint const* eps
|
|||||||
{ "r", lazy_entry::dict_t, 0, key_desc_t::parse_children },
|
{ "r", lazy_entry::dict_t, 0, key_desc_t::parse_children },
|
||||||
{ "v", lazy_entry::dict_t, 0, 0},
|
{ "v", lazy_entry::dict_t, 0, 0},
|
||||||
{ "id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
{ "id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
||||||
{ "y", lazy_entry::string_t, 1, 0},
|
{ "z", lazy_entry::string_t, 1, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
lazy_entry const* parsed[4];
|
lazy_entry const* parsed[4];
|
||||||
@ -313,7 +313,7 @@ int test_main()
|
|||||||
send_dht_msg(node, "ping", source, &response, "10");
|
send_dht_msg(node, "ping", source, &response, "10");
|
||||||
|
|
||||||
dht::key_desc_t pong_desc[] = {
|
dht::key_desc_t pong_desc[] = {
|
||||||
{"y", lazy_entry::string_t, 1, 0},
|
{"z", lazy_entry::string_t, 1, 0},
|
||||||
{"t", lazy_entry::string_t, 2, 0},
|
{"t", lazy_entry::string_t, 2, 0},
|
||||||
{"r", lazy_entry::dict_t, 0, key_desc_t::parse_children},
|
{"r", lazy_entry::dict_t, 0, key_desc_t::parse_children},
|
||||||
{"id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
{"id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
||||||
@ -337,7 +337,7 @@ int test_main()
|
|||||||
send_dht_msg(node, "find_node", source, &response, "10");
|
send_dht_msg(node, "find_node", source, &response, "10");
|
||||||
|
|
||||||
dht::key_desc_t err_desc[] = {
|
dht::key_desc_t err_desc[] = {
|
||||||
{"y", lazy_entry::string_t, 1, 0},
|
{"z", lazy_entry::string_t, 1, 0},
|
||||||
{"e", lazy_entry::list_t, 2, 0},
|
{"e", lazy_entry::list_t, 2, 0},
|
||||||
{"r", lazy_entry::dict_t, 0, key_desc_t::parse_children},
|
{"r", lazy_entry::dict_t, 0, key_desc_t::parse_children},
|
||||||
{"id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
{"id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
||||||
@ -369,7 +369,7 @@ int test_main()
|
|||||||
send_dht_msg(node, "get_peers", source, &response, "10", "01010101010101010101");
|
send_dht_msg(node, "get_peers", source, &response, "10", "01010101010101010101");
|
||||||
|
|
||||||
dht::key_desc_t peer1_desc[] = {
|
dht::key_desc_t peer1_desc[] = {
|
||||||
{"y", lazy_entry::string_t, 1, 0},
|
{"z", lazy_entry::string_t, 1, 0},
|
||||||
{"r", lazy_entry::dict_t, 0, key_desc_t::parse_children},
|
{"r", lazy_entry::dict_t, 0, key_desc_t::parse_children},
|
||||||
{"token", lazy_entry::string_t, 0, 0},
|
{"token", lazy_entry::string_t, 0, 0},
|
||||||
{"id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
{"id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
||||||
@ -396,7 +396,7 @@ int test_main()
|
|||||||
send_dht_msg(node, "announce_peer", source, &response, "10", "01010101010101010101", "test", token, 8080);
|
send_dht_msg(node, "announce_peer", source, &response, "10", "01010101010101010101", "test", token, 8080);
|
||||||
|
|
||||||
dht::key_desc_t ann_desc[] = {
|
dht::key_desc_t ann_desc[] = {
|
||||||
{"y", lazy_entry::string_t, 1, 0},
|
{"z", lazy_entry::string_t, 1, 0},
|
||||||
{"r", lazy_entry::dict_t, 0, key_desc_t::parse_children},
|
{"r", lazy_entry::dict_t, 0, key_desc_t::parse_children},
|
||||||
{"id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
{"id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
||||||
};
|
};
|
||||||
@ -444,7 +444,7 @@ int test_main()
|
|||||||
, 0, no, 0, 0, 0, true);
|
, 0, no, 0, 0, 0, true);
|
||||||
|
|
||||||
dht::key_desc_t peer2_desc[] = {
|
dht::key_desc_t peer2_desc[] = {
|
||||||
{"y", lazy_entry::string_t, 1, 0},
|
{"z", lazy_entry::string_t, 1, 0},
|
||||||
{"r", lazy_entry::dict_t, 0, key_desc_t::parse_children},
|
{"r", lazy_entry::dict_t, 0, key_desc_t::parse_children},
|
||||||
{"BFpe", lazy_entry::string_t, 256, 0},
|
{"BFpe", lazy_entry::string_t, 256, 0},
|
||||||
{"BFse", lazy_entry::string_t, 256, 0},
|
{"BFse", lazy_entry::string_t, 256, 0},
|
||||||
@ -565,7 +565,7 @@ int test_main()
|
|||||||
{ "id", lazy_entry::string_t, 20, 0},
|
{ "id", lazy_entry::string_t, 20, 0},
|
||||||
{ "token", lazy_entry::string_t, 0, 0},
|
{ "token", lazy_entry::string_t, 0, 0},
|
||||||
{ "ip", lazy_entry::string_t, 0, key_desc_t::optional | key_desc_t::last_child},
|
{ "ip", lazy_entry::string_t, 0, key_desc_t::optional | key_desc_t::last_child},
|
||||||
{ "y", lazy_entry::string_t, 1, 0},
|
{ "z", lazy_entry::string_t, 1, 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = verify_message(&response, desc, parsed, 5, error_string, sizeof(error_string));
|
ret = verify_message(&response, desc, parsed, 5, error_string, sizeof(error_string));
|
||||||
@ -601,7 +601,7 @@ int test_main()
|
|||||||
|
|
||||||
key_desc_t desc2[] =
|
key_desc_t desc2[] =
|
||||||
{
|
{
|
||||||
{ "y", lazy_entry::string_t, 1, 0 }
|
{ "z", lazy_entry::string_t, 1, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = verify_message(&response, desc2, parsed, 1, error_string, sizeof(error_string));
|
ret = verify_message(&response, desc2, parsed, 1, error_string, sizeof(error_string));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user