diff --git a/doc/rtorrent.1.xml b/doc/rtorrent.1.xml
index 20447673..255756b0 100644
--- a/doc/rtorrent.1.xml
+++ b/doc/rtorrent.1.xml
@@ -218,6 +218,13 @@
+
+ i
+
+Display chunk rarity.
+
+
+
o
@@ -603,6 +610,18 @@ Controls whetever a lock file is created in the session directory.
+
+ tracker_dump = filename
+
+
+Dump tracker requests to filename, disable by
+supplying an empty string. Only torrents loaded while
+tracker_dump contains a non-empty string will be
+logged at the moment, although disabling it will work as expected.
+
+
+
+
diff --git a/src/core/download_factory.cc b/src/core/download_factory.cc
index 278b9534..faffe8bc 100644
--- a/src/core/download_factory.cc
+++ b/src/core/download_factory.cc
@@ -158,24 +158,20 @@ DownloadFactory::receive_success() {
root->erase_key("libtorrent");
}
- if (!root->has_key("rtorrent") ||
- !root->get_key("rtorrent").is_map())
+ if (!root->has_key_map("rtorrent"))
root->insert_key("rtorrent", torrent::Object(torrent::Object::TYPE_MAP));
torrent::Object* rtorrent = &root->get_key("rtorrent");
- if (!rtorrent->has_key("state") ||
- !rtorrent->get_key("state").is_string() ||
+ if (!rtorrent->has_key_string("state") ||
(rtorrent->get_key("state").as_string() != "stopped" &&
rtorrent->get_key("state").as_string() != "started"))
rtorrent->insert_key("state", "stopped");
- if (!rtorrent->has_key("tied_to_file") ||
- !rtorrent->get_key("tied_to_file").is_string())
+ if (!rtorrent->has_key_string("tied_to_file"))
rtorrent->insert_key("tied_to_file", std::string());
- if (rtorrent->has_key("priority") &&
- rtorrent->get_key("priority").is_value())
+ if (rtorrent->has_key_value("priority"))
(*itr)->variable()->set("priority", rtorrent->get_key("priority").as_value() % 4);
else
(*itr)->variable()->set("priority", (int64_t)2);
@@ -190,12 +186,11 @@ DownloadFactory::receive_success() {
if (control->variable()->get_string("use_udp_trackers") == "no")
(*itr)->enable_udp_trackers(false);
- if (rtorrent->has_key("total_uploaded") && rtorrent->get_key("total_uploaded").is_value())
+ if (rtorrent->has_key_value("total_uploaded"))
(*itr)->download()->up_rate()->set_total(rtorrent->get_key("total_uploaded").as_value());
if (m_session) {
- if (!rtorrent->has_key("directory") ||
- !rtorrent->get_key("directory").is_string())
+ if (!rtorrent->has_key_string("directory"))
(*itr)->variable()->set("directory", m_variables.get("directory"));
else
(*itr)->variable()->set("directory", rtorrent->get_key("directory"));
diff --git a/src/core/manager.cc b/src/core/manager.cc
index d27d9062..7081879d 100644
--- a/src/core/manager.cc
+++ b/src/core/manager.cc
@@ -39,6 +39,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -73,6 +74,30 @@ connect_signal_storage_log(Download* d, torrent::Download::slot_string_type s) {
d->download()->signal_storage_error(s);
}
+// Need a proper logging class for this.
+static void
+connect_signal_tracker_dump(Download* d, torrent::Download::slot_dump_type s) {
+ if (!control->variable()->get_string("tracker_dump").empty())
+ d->download()->signal_tracker_dump(s);
+}
+
+static void
+receive_tracker_dump(const std::string& url, const char* data, size_t size) {
+ const std::string& filename = control->variable()->get_string("tracker_dump");
+
+ if (filename.empty())
+ return;
+
+ std::fstream fstr(filename.c_str(), std::ios::out | std::ios::app);
+
+ if (!fstr.is_open())
+ return;
+
+ fstr << "url: " << url << std::endl << "---" << std::endl;
+ fstr.write(data, size);
+ fstr << std::endl <<"---" << std::endl;
+}
+
// Hmm... find some better place for all this.
static void
delete_tied(Download* d) {
@@ -113,8 +138,9 @@ Manager::initialize_second() {
// Register slots to be called when a download is inserted/erased,
// opened or closed.
- m_downloadList.slot_map_insert()["1_connect_network_log"] = sigc::bind(sigc::ptr_fun(&connect_signal_network_log), sigc::mem_fun(m_logComplete, &Log::push_front));
- m_downloadList.slot_map_insert()["1_connect_storage_log"] = sigc::bind(sigc::ptr_fun(&connect_signal_storage_log), sigc::mem_fun(m_logComplete, &Log::push_front));
+ m_downloadList.slot_map_insert()["1_connect_network_log"] = sigc::bind(sigc::ptr_fun(&connect_signal_network_log), sigc::mem_fun(m_logComplete, &Log::push_front));
+ m_downloadList.slot_map_insert()["1_connect_storage_log"] = sigc::bind(sigc::ptr_fun(&connect_signal_storage_log), sigc::mem_fun(m_logComplete, &Log::push_front));
+ m_downloadList.slot_map_insert()["1_connect_tracker_dump"] = sigc::bind(sigc::ptr_fun(&connect_signal_tracker_dump), sigc::ptr_fun(&receive_tracker_dump));
m_downloadList.slot_map_erase()["1_hash_queue_remove"] = sigc::mem_fun(m_hashQueue, &HashQueue::remove);
m_downloadList.slot_map_erase()["1_store_remove"] = sigc::mem_fun(m_downloadStore, &DownloadStore::remove);
diff --git a/src/option_handler_rules.cc b/src/option_handler_rules.cc
index 2709e605..9fe00cc4 100644
--- a/src/option_handler_rules.cc
+++ b/src/option_handler_rules.cc
@@ -184,6 +184,8 @@ initialize_option_handler(Control* c) {
variables->insert("port_open", new utils::VariableAny("yes"));
variables->insert("port_random", new utils::VariableAny("yes"));
+ variables->insert("tracker_dump", new utils::VariableAny(std::string()));
+
variables->insert("session", new utils::VariableSlotString<>(NULL, rak::mem_fn(&control->core()->download_store(), &core::DownloadStore::set_path)));
variables->insert("session_lock", new utils::VariableAny("yes"));
variables->insert("session_on_completion", new utils::VariableAny("yes"));