diff --git a/ChangeLog b/ChangeLog index 78d0d5119..0be6b8224 100644 --- a/ChangeLog +++ b/ChangeLog @@ -78,6 +78,7 @@ release 0.14.7 * resume data alerts are always posted, regardless of alert mask * added wait_for_alert to python binding * improved invalid filename character replacement + * improved forward compatibility in DHT release 0.14.6 diff --git a/src/kademlia/node.cpp b/src/kademlia/node.cpp index 56f9278fc..f8f502728 100644 --- a/src/kademlia/node.cpp +++ b/src/kademlia/node.cpp @@ -664,7 +664,25 @@ void node_impl::incoming_request(msg const& m, entry& e) } else { - incoming_error(e, "unknown message"); + // if we don't recognize the message but there's a + // 'target' or 'info_hash' in the arguments, treat it + // as find_node to be future compatible + lazy_entry const* target_ent = arg_ent->dict_find_string("target"); + if (target_ent == 0 || target_ent->string_length() != 20) + { + target_ent = arg_ent->dict_find_string("info_hash"); + if (target_ent == 0 || target_ent->string_length() != 20) + { + incoming_error(e, "unknown message"); + return; + } + } + + sha1_hash target(target_ent->string_ptr()); + nodes_t n; + // always return nodes as well as peers + m_table.find_node(target, n, 0); + write_nodes_entry(reply, n); return; } }