mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-13 13:42:30 +00:00
* Added combined Object::has_key and Object::is_* functions.
* Re-added 'tracker_dump' option which takes a filename. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@661 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -218,6 +218,13 @@
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>i</term>
|
||||
<listitem><para>
|
||||
Display chunk rarity.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>o</term>
|
||||
<listitem><para>
|
||||
@@ -603,6 +610,18 @@ Controls whetever a lock file is created in the session directory.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>tracker_dump = <replaceable>filename</replaceable></term>
|
||||
<listitem><para>
|
||||
|
||||
Dump tracker requests to <emphasis>filename</emphasis>, disable by
|
||||
supplying an empty string. Only torrents loaded while
|
||||
<emphasis>tracker_dump</emphasis> contains a non-empty string will be
|
||||
logged at the moment, although disabling it will work as expected.
|
||||
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
</variablelist>
|
||||
|
||||
</refsect1>
|
||||
|
||||
@@ -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"));
|
||||
|
||||
+28
-2
@@ -39,6 +39,7 @@
|
||||
#include <stdexcept>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
#include <sys/select.h>
|
||||
#include <rak/address_info.h>
|
||||
@@ -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);
|
||||
|
||||
@@ -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"));
|
||||
|
||||
Reference in New Issue
Block a user