Browse Source

adjust dht stored obj size, print dht get results in test_dht

miguelfreitas
Miguel Freitas 12 years ago
parent
commit
6a1d35a582
  1. 7
      libtorrent/src/kademlia/node.cpp
  2. 9
      libtorrent/test/test_dht.cpp

7
libtorrent/src/kademlia/node.cpp

@ -1068,7 +1068,8 @@ void node_impl::incoming_request(msg const& m, entry& e) @@ -1068,7 +1068,8 @@ void node_impl::incoming_request(msg const& m, entry& e)
// pointer and length to the whole entry
std::pair<char const*, int> buf = msg_keys[mk_p]->data_section();
if (buf.second > 767 || buf.second <= 0)
int maxSize = (multi) ? 512 : 8192; // single is bigger for avatar image etc
if (buf.second > maxSize || buf.second <= 0)
{
incoming_error(e, "message too big");
return;
@ -1245,8 +1246,8 @@ void node_impl::incoming_request(msg const& m, entry& e) @@ -1245,8 +1246,8 @@ void node_impl::incoming_request(msg const& m, entry& e)
{
entry::dictionary_type v;
v["p"] = bdecode(j->p.begin(), j->p.end());
v["sig_p"] = bdecode(j->sig_p.begin(), j->sig_p.end());
v["sig_user"] = bdecode(j->sig_user.begin(), j->sig_user.end());
v["sig_p"] = j->sig_p;
v["sig_user"] = j->sig_user;
values.push_back(v);
}
}

9
libtorrent/test/test_dht.cpp

@ -315,7 +315,8 @@ void get_put_get(node_impl& node, udp::endpoint const* eps @@ -315,7 +315,8 @@ void get_put_get(node_impl& node, udp::endpoint const* eps
{
std::string username("username");
std::string resource("res");
bool multi = false;
//bool multi = false;
bool multi = true;
std::string sig_user("username");
int seq=1;
@ -364,9 +365,11 @@ void get_put_get(node_impl& node, udp::endpoint const* eps @@ -364,9 +365,11 @@ void get_put_get(node_impl& node, udp::endpoint const* eps
TEST_EQUAL(addr, eps[i].address());
}
entry testentry;
testentry["j"] = j;
send_put_dht(node, eps[i], &response, "10",
username.c_str(), resource.c_str(), multi,
token, &items[j].ent, sig_user, seq++, 1000, getBestHeight());
token, &testentry, sig_user, seq++, 1000, getBestHeight());
key_desc_t desc2[] =
{
@ -408,10 +411,12 @@ void get_put_get(node_impl& node, udp::endpoint const* eps @@ -408,10 +411,12 @@ void get_put_get(node_impl& node, udp::endpoint const* eps
lazy_entry const* parsed[4];
char error_string[200];
//fprintf(stderr, "msg: %s\n", print_entry(response).c_str());
int ret = verify_message(&response, desc, parsed, 4, error_string, sizeof(error_string));
if (ret)
{
items_num.insert(items_num.begin(), j);
fprintf(stderr, "values: %s\n", print_entry(*parsed[1]).c_str());
}
}

Loading…
Cancel
Save