From 5b98b52901ea438058eef3a08f8303eb7363374b Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Mon, 29 Jul 2013 15:13:50 -0300 Subject: [PATCH] incompatible dht change: "y" => "z" --- libtorrent/dht_flood.py | 4 ++-- libtorrent/src/kademlia/dht_tracker.cpp | 4 ++-- libtorrent/src/kademlia/find_data.cpp | 2 +- libtorrent/src/kademlia/node.cpp | 12 ++++++------ libtorrent/src/kademlia/refresh.cpp | 2 +- libtorrent/src/kademlia/rpc_manager.cpp | 4 ++-- libtorrent/test/test_dht.cpp | 22 +++++++++++----------- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libtorrent/dht_flood.py b/libtorrent/dht_flood.py index b9f6b98d..84169a59 100755 --- a/libtorrent/dht_flood.py +++ b/libtorrent/dht_flood.py @@ -60,9 +60,9 @@ query = 'get_peers' print 'test random info-hashes' 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' 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}) diff --git a/libtorrent/src/kademlia/dht_tracker.cpp b/libtorrent/src/kademlia/dht_tracker.cpp index d43cd82a..5752ba2f 100644 --- a/libtorrent/src/kademlia/dht_tracker.cpp +++ b/libtorrent/src/kademlia/dht_tracker.cpp @@ -636,7 +636,7 @@ namespace libtorrent { namespace dht #ifdef TORRENT_DHT_VERBOSE_LOGGING 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, // 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_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(); } diff --git a/libtorrent/src/kademlia/find_data.cpp b/libtorrent/src/kademlia/find_data.cpp index 482b353b..024cb5e6 100644 --- a/libtorrent/src/kademlia/find_data.cpp +++ b/libtorrent/src/kademlia/find_data.cpp @@ -205,7 +205,7 @@ bool find_data::invoke(observer_ptr o) } entry e; - e["y"] = "q"; + e["z"] = "q"; e["q"] = "get_peers"; entry& a = e["a"]; a["info_hash"] = m_target.to_string(); diff --git a/libtorrent/src/kademlia/node.cpp b/libtorrent/src/kademlia/node.cpp index 27d361d5..f66901d9 100644 --- a/libtorrent/src/kademlia/node.cpp +++ b/libtorrent/src/kademlia/node.cpp @@ -209,7 +209,7 @@ void node_impl::unreachable(udp::endpoint const& ep) void node_impl::incoming(msg const& m) { // 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) { entry e; @@ -231,7 +231,7 @@ void node_impl::incoming(msg const& m) } case 'q': { - TORRENT_ASSERT(m.message.dict_find_string_value("y") == "q"); + TORRENT_ASSERT(m.message.dict_find_string_value("z") == "q"); entry e; incoming_request(m, e); m_sock->send_packet(e, m.addr, 0); @@ -281,7 +281,7 @@ namespace o->m_in_constructor = false; #endif entry e; - e["y"] = "q"; + e["z"] = "q"; e["q"] = "announce_peer"; entry& a = e["a"]; a["info_hash"] = ih.to_string(); @@ -318,7 +318,7 @@ void node_impl::add_node(udp::endpoint node) o->m_in_constructor = false; #endif entry e; - e["y"] = "q"; + e["z"] = "q"; e["q"] = "ping"; 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) { - e["y"] = "e"; + e["z"] = "e"; entry::list_type& l = e["e"].list(); l.push_back(entry(203)); 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) { e = entry(entry::dictionary_t); - e["y"] = "r"; + e["z"] = "r"; e["t"] = m.message.dict_find_string_value("t"); key_desc_t top_desc[] = { diff --git a/libtorrent/src/kademlia/refresh.cpp b/libtorrent/src/kademlia/refresh.cpp index 294c6b6f..4b9b05e8 100644 --- a/libtorrent/src/kademlia/refresh.cpp +++ b/libtorrent/src/kademlia/refresh.cpp @@ -71,7 +71,7 @@ observer_ptr refresh::new_observer(void* ptr bool refresh::invoke(observer_ptr o) { entry e; - e["y"] = "q"; + e["z"] = "q"; e["q"] = "find_node"; entry& a = e["a"]; a["target"] = target().to_string(); diff --git a/libtorrent/src/kademlia/rpc_manager.cpp b/libtorrent/src/kademlia/rpc_manager.cpp index ed6a2fad..491870d8 100644 --- a/libtorrent/src/kademlia/rpc_manager.cpp +++ b/libtorrent/src/kademlia/rpc_manager.cpp @@ -277,7 +277,7 @@ bool rpc_manager::incoming(msg const& m, node_id* id) if (m_destructing) return false; // 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 // request list, ignore the packet @@ -465,7 +465,7 @@ bool rpc_manager::invoke(entry& e, udp::endpoint target_addr if (m_destructing) return false; - e["y"] = "q"; + e["z"] = "q"; entry& a = e["a"]; add_our_id(a); diff --git a/libtorrent/test/test_dht.cpp b/libtorrent/test/test_dht.cpp index 72b80dba..43100f37 100644 --- a/libtorrent/test/test_dht.cpp +++ b/libtorrent/test/test_dht.cpp @@ -106,7 +106,7 @@ void send_dht_msg(node_impl& node, char const* msg, udp::endpoint const& ep entry e; e["q"] = msg; e["t"] = t; - e["y"] = "q"; + e["z"] = "q"; entry::dictionary_type& a = e["a"].dict(); a["id"] = generate_next().to_string(); 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}, { "token", lazy_entry::string_t, 0, 0}, { "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]; @@ -228,7 +228,7 @@ void announce_immutable_items(node_impl& node, udp::endpoint const* eps 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)); @@ -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 }, { "v", lazy_entry::dict_t, 0, 0}, { "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]; @@ -313,7 +313,7 @@ int test_main() send_dht_msg(node, "ping", source, &response, "10"); 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}, {"r", lazy_entry::dict_t, 0, key_desc_t::parse_children}, {"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"); 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}, {"r", lazy_entry::dict_t, 0, key_desc_t::parse_children}, {"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"); 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}, {"token", lazy_entry::string_t, 0, 0}, {"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); 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}, {"id", lazy_entry::string_t, 20, key_desc_t::last_child}, }; @@ -444,7 +444,7 @@ int test_main() , 0, no, 0, 0, 0, true); 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}, {"BFpe", 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}, { "token", lazy_entry::string_t, 0, 0}, { "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)); @@ -601,7 +601,7 @@ int test_main() 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));