merged changes from RC_1_0
This commit is contained in:
parent
ca3c1620bd
commit
0977d94dbc
|
@ -38,6 +38,10 @@
|
|||
* almost completely changed the storage interface (for custom storage)
|
||||
* added support for hashing pieces in multiple threads
|
||||
|
||||
* support conditional DHT get
|
||||
* OpenSSL build fixes
|
||||
* fix DHT scrape bug
|
||||
|
||||
1.0.3 release
|
||||
|
||||
* python binding build fix for boost-1.57.0
|
||||
|
|
|
@ -1000,7 +1000,7 @@ namespace libtorrent
|
|||
// The priority values are the same as for piece_priority().
|
||||
//
|
||||
// Whenever a file priority is changed, all other piece priorities are
|
||||
// reset to match the file priorities. In order to maintain sepcial
|
||||
// reset to match the file priorities. In order to maintain special
|
||||
// priorities for particular pieces, piece_priority() has to be called
|
||||
// again for those pieces.
|
||||
//
|
||||
|
|
|
@ -614,7 +614,7 @@ void node_impl::lookup_peers(sha1_hash const& info_hash, entry& reply
|
|||
}
|
||||
|
||||
reply["BFpe"] = downloaders.to_string();
|
||||
reply["BFse"] = seeds.to_string();
|
||||
reply["BFsd"] = seeds.to_string();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1230,34 +1230,41 @@ void node_impl::incoming_request(msg const& m, entry& e)
|
|||
else if (strcmp(query, "get") == 0)
|
||||
{
|
||||
key_desc_t msg_desc[] = {
|
||||
{"seq", lazy_entry::int_t, 0, key_desc_t::optional},
|
||||
{"target", lazy_entry::string_t, 20, 0},
|
||||
};
|
||||
|
||||
// k is not used for now
|
||||
|
||||
// attempt to parse the message
|
||||
lazy_entry const* msg_keys[1];
|
||||
if (!verify_message(arg_ent, msg_desc, msg_keys, 1, error_string, sizeof(error_string)))
|
||||
lazy_entry const* msg_keys[2];
|
||||
if (!verify_message(arg_ent, msg_desc, msg_keys, 2, error_string, sizeof(error_string)))
|
||||
{
|
||||
incoming_error(e, error_string);
|
||||
return;
|
||||
}
|
||||
|
||||
m_counters.inc_stats_counter(counters::dht_get_in);
|
||||
sha1_hash target(msg_keys[0]->string_ptr());
|
||||
sha1_hash target(msg_keys[1]->string_ptr());
|
||||
|
||||
// fprintf(stderr, "%s GET target: %s\n"
|
||||
// , msg_keys[1] ? "mutable":"immutable"
|
||||
// , to_hex(target.to_string()).c_str());
|
||||
|
||||
reply["token"] = generate_token(m.addr, msg_keys[0]->string_ptr());
|
||||
reply["token"] = generate_token(m.addr, msg_keys[1]->string_ptr());
|
||||
|
||||
nodes_t n;
|
||||
// always return nodes as well as peers
|
||||
m_table.find_node(target, n, 0);
|
||||
write_nodes_entry(reply, n);
|
||||
|
||||
dht_immutable_table_t::iterator i = m_immutable_table.find(target);
|
||||
dht_immutable_table_t::iterator i = m_immutable_table.end();
|
||||
|
||||
// if the get has a sequence number it must be for a mutable item
|
||||
// so don't bother searching the immutable table
|
||||
if (!msg_keys[0])
|
||||
i = m_immutable_table.find(target);
|
||||
|
||||
if (i != m_immutable_table.end())
|
||||
{
|
||||
dht_immutable_item const& f = i->second;
|
||||
|
@ -1269,10 +1276,13 @@ void node_impl::incoming_request(msg const& m, entry& e)
|
|||
if (i != m_mutable_table.end())
|
||||
{
|
||||
dht_mutable_item const& f = i->second;
|
||||
reply["v"] = bdecode(f.value, f.value + f.size);
|
||||
reply["seq"] = f.seq;
|
||||
reply["sig"] = std::string(f.sig, f.sig + sizeof(f.sig));
|
||||
reply["k"] = std::string(f.key.bytes, f.key.bytes + sizeof(f.key.bytes));
|
||||
if (!msg_keys[0] || uint64_t(msg_keys[0]->int_value()) < f.seq)
|
||||
{
|
||||
reply["v"] = bdecode(f.value, f.value + f.size);
|
||||
reply["sig"] = std::string(f.sig, f.sig + sizeof(f.sig));
|
||||
reply["k"] = std::string(f.key.bytes, f.key.bytes + sizeof(f.key.bytes));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,11 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <boost/bind.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#if defined TORRENT_LOGGING
|
||||
#ifdef TORRENT_LOGGING
|
||||
#include <stdarg.h> // for va_start, va_end
|
||||
#include <stdio.h> // for vsnprintf
|
||||
#include "libtorrent/escape_string.hpp"
|
||||
#include "libtorrent/socket_io.hpp"
|
||||
#endif
|
||||
|
||||
#include "libtorrent/peer_connection.hpp"
|
||||
|
@ -73,9 +75,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include <set>
|
||||
#endif
|
||||
|
||||
#if defined TORRENT_LOGGING
|
||||
#include "libtorrent/escape_string.hpp"
|
||||
#include "libtorrent/socket_io.hpp"
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
#include <openssl/rand.h>
|
||||
#endif
|
||||
|
||||
//#define TORRENT_CORRUPT_DATA
|
||||
|
|
|
@ -147,6 +147,7 @@ namespace
|
|||
#ifdef TORRENT_USE_OPENSSL
|
||||
|
||||
#include <openssl/crypto.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
|
|
@ -90,6 +90,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#ifdef TORRENT_USE_OPENSSL
|
||||
#include "libtorrent/ssl_stream.hpp"
|
||||
#include <boost/asio/ssl/context.hpp>
|
||||
#include <openssl/rand.h>
|
||||
#if BOOST_VERSION >= 104700
|
||||
#include <boost/asio/ssl/verify_context.hpp>
|
||||
#endif // BOOST_VERSION
|
||||
|
|
|
@ -589,7 +589,7 @@ int test_main()
|
|||
{"y", 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},
|
||||
{"BFsd", lazy_entry::string_t, 256, 0},
|
||||
{"id", lazy_entry::string_t, 20, key_desc_t::last_child},
|
||||
};
|
||||
|
||||
|
@ -810,7 +810,7 @@ int test_main()
|
|||
|
||||
send_dht_request(node, "get", source, &response, "10", 0
|
||||
, 0, no, 0, (char*)&target_id[0]
|
||||
, 0, false, false, std::string(), std::string(), 64);
|
||||
, 0, false, false, std::string(), std::string());
|
||||
|
||||
key_desc_t desc[] =
|
||||
{
|
||||
|
@ -866,7 +866,7 @@ int test_main()
|
|||
|
||||
send_dht_request(node, "get", source, &response, "10", 0
|
||||
, 0, no, 0, (char*)&target_id[0]
|
||||
, 0, false, false, std::string(), std::string(), 64);
|
||||
, 0, false, false, std::string(), std::string());
|
||||
|
||||
fprintf(stderr, "target_id: %s\n"
|
||||
, to_hex(target_id.to_string()).c_str());
|
||||
|
@ -938,6 +938,30 @@ int test_main()
|
|||
TEST_ERROR(error_string);
|
||||
}
|
||||
|
||||
// === test conditional get ===
|
||||
|
||||
send_dht_request(node, "get", source, &response, "10", 0
|
||||
, 0, no, 0, (char*)&target_id[0]
|
||||
, 0, false, false, std::string(), std::string(), seq-1);
|
||||
|
||||
{
|
||||
lazy_entry const* r = response.dict_find_dict("r");
|
||||
TEST_CHECK(r->dict_find("v"));
|
||||
TEST_CHECK(r->dict_find("k"));
|
||||
TEST_CHECK(r->dict_find("sig"));
|
||||
}
|
||||
|
||||
send_dht_request(node, "get", source, &response, "10", 0
|
||||
, 0, no, 0, (char*)&target_id[0]
|
||||
, 0, false, false, std::string(), std::string(), seq);
|
||||
|
||||
{
|
||||
lazy_entry const* r = response.dict_find_dict("r");
|
||||
TEST_CHECK(!r->dict_find("v"));
|
||||
TEST_CHECK(!r->dict_find("k"));
|
||||
TEST_CHECK(!r->dict_find("sig"));
|
||||
}
|
||||
|
||||
// === test CAS put ===
|
||||
|
||||
// this is the sequence number we expect to be there
|
||||
|
|
Loading…
Reference in New Issue