mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-14 13:16:17 +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>
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>i</term>
|
||||||
|
<listitem><para>
|
||||||
|
Display chunk rarity.
|
||||||
|
</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>o</term>
|
<term>o</term>
|
||||||
<listitem><para>
|
<listitem><para>
|
||||||
@@ -603,6 +610,18 @@ Controls whetever a lock file is created in the session directory.
|
|||||||
</para></listitem>
|
</para></listitem>
|
||||||
</varlistentry>
|
</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>
|
</variablelist>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|||||||
@@ -158,24 +158,20 @@ DownloadFactory::receive_success() {
|
|||||||
root->erase_key("libtorrent");
|
root->erase_key("libtorrent");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!root->has_key("rtorrent") ||
|
if (!root->has_key_map("rtorrent"))
|
||||||
!root->get_key("rtorrent").is_map())
|
|
||||||
root->insert_key("rtorrent", torrent::Object(torrent::Object::TYPE_MAP));
|
root->insert_key("rtorrent", torrent::Object(torrent::Object::TYPE_MAP));
|
||||||
|
|
||||||
torrent::Object* rtorrent = &root->get_key("rtorrent");
|
torrent::Object* rtorrent = &root->get_key("rtorrent");
|
||||||
|
|
||||||
if (!rtorrent->has_key("state") ||
|
if (!rtorrent->has_key_string("state") ||
|
||||||
!rtorrent->get_key("state").is_string() ||
|
|
||||||
(rtorrent->get_key("state").as_string() != "stopped" &&
|
(rtorrent->get_key("state").as_string() != "stopped" &&
|
||||||
rtorrent->get_key("state").as_string() != "started"))
|
rtorrent->get_key("state").as_string() != "started"))
|
||||||
rtorrent->insert_key("state", "stopped");
|
rtorrent->insert_key("state", "stopped");
|
||||||
|
|
||||||
if (!rtorrent->has_key("tied_to_file") ||
|
if (!rtorrent->has_key_string("tied_to_file"))
|
||||||
!rtorrent->get_key("tied_to_file").is_string())
|
|
||||||
rtorrent->insert_key("tied_to_file", std::string());
|
rtorrent->insert_key("tied_to_file", std::string());
|
||||||
|
|
||||||
if (rtorrent->has_key("priority") &&
|
if (rtorrent->has_key_value("priority"))
|
||||||
rtorrent->get_key("priority").is_value())
|
|
||||||
(*itr)->variable()->set("priority", rtorrent->get_key("priority").as_value() % 4);
|
(*itr)->variable()->set("priority", rtorrent->get_key("priority").as_value() % 4);
|
||||||
else
|
else
|
||||||
(*itr)->variable()->set("priority", (int64_t)2);
|
(*itr)->variable()->set("priority", (int64_t)2);
|
||||||
@@ -190,12 +186,11 @@ DownloadFactory::receive_success() {
|
|||||||
if (control->variable()->get_string("use_udp_trackers") == "no")
|
if (control->variable()->get_string("use_udp_trackers") == "no")
|
||||||
(*itr)->enable_udp_trackers(false);
|
(*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());
|
(*itr)->download()->up_rate()->set_total(rtorrent->get_key("total_uploaded").as_value());
|
||||||
|
|
||||||
if (m_session) {
|
if (m_session) {
|
||||||
if (!rtorrent->has_key("directory") ||
|
if (!rtorrent->has_key_string("directory"))
|
||||||
!rtorrent->get_key("directory").is_string())
|
|
||||||
(*itr)->variable()->set("directory", m_variables.get("directory"));
|
(*itr)->variable()->set("directory", m_variables.get("directory"));
|
||||||
else
|
else
|
||||||
(*itr)->variable()->set("directory", rtorrent->get_key("directory"));
|
(*itr)->variable()->set("directory", rtorrent->get_key("directory"));
|
||||||
|
|||||||
+28
-2
@@ -39,6 +39,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <fstream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <rak/address_info.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);
|
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.
|
// Hmm... find some better place for all this.
|
||||||
static void
|
static void
|
||||||
delete_tied(Download* d) {
|
delete_tied(Download* d) {
|
||||||
@@ -113,8 +138,9 @@ Manager::initialize_second() {
|
|||||||
|
|
||||||
// Register slots to be called when a download is inserted/erased,
|
// Register slots to be called when a download is inserted/erased,
|
||||||
// opened or closed.
|
// 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_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_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_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);
|
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_open", new utils::VariableAny("yes"));
|
||||||
variables->insert("port_random", 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", 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_lock", new utils::VariableAny("yes"));
|
||||||
variables->insert("session_on_completion", new utils::VariableAny("yes"));
|
variables->insert("session_on_completion", new utils::VariableAny("yes"));
|
||||||
|
|||||||
Reference in New Issue
Block a user