From 2685674eb92715018800979bcc180d66b03b8b24 Mon Sep 17 00:00:00 2001 From: Thomas Yuan Date: Thu, 27 Aug 2015 23:45:29 -0400 Subject: [PATCH 1/2] Fix dht_put. --- tools/dht_put.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/dht_put.cpp b/tools/dht_put.cpp index 4a32cd9d1..93cf21b64 100644 --- a/tools/dht_put.cpp +++ b/tools/dht_put.cpp @@ -159,10 +159,13 @@ int main(int argc, char* argv[]) } settings_pack sett; + sett.set_bool(settings_pack::enable_dht, false); sett.set_int(settings_pack::alert_mask, 0xffffffff); lt::session s(sett); s.add_dht_router(std::pair("router.utorrent.com", 6881)); + sett.set_bool(settings_pack::enable_dht, true); + s.apply_settings(sett); FILE* f = fopen(".dht", "rb"); if (f != NULL) From a4aa2f9e4b3ee08df792947e504243f0bd6a0f6c Mon Sep 17 00:00:00 2001 From: Thomas Yuan Date: Fri, 28 Aug 2015 12:27:48 -0400 Subject: [PATCH 2/2] After PR #70, mget will get multi alerts. --- tools/dht_put.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/dht_put.cpp b/tools/dht_put.cpp index 93cf21b64..64c8adf54 100644 --- a/tools/dht_put.cpp +++ b/tools/dht_put.cpp @@ -300,14 +300,20 @@ int main(int argc, char* argv[]) bootstrap(s); s.dht_get_item(public_key); - alert* a = wait_for_alert(s, dht_mutable_item_alert::alert_type); + bool authoritative = false; - dht_mutable_item_alert* item = alert_cast(a); - entry data; - if (item) - data.swap(item->item); + while (!authoritative) + { + alert* a = wait_for_alert(s, dht_mutable_item_alert::alert_type); - printf("%s", data.to_string().c_str()); + dht_mutable_item_alert* item = alert_cast(a); + entry data; + if (item) + data.swap(item->item); + + authoritative = item->authoritative; + printf("%s: %s", authoritative ? "auth" : "non-auth", data.to_string().c_str()); + } } else {