Added -t for dumping tracker requests.

git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@315 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-03-01 19:21:49 +00:00
parent ef3a8fcd83
commit b840476527
8 changed files with 49 additions and 15 deletions
+2 -1
View File
@@ -3,6 +3,7 @@
#include "download.h"
#include <sigc++/bind.h>
#include <sigc++/hide.h>
#include <sigc++/signal.h>
namespace core {
@@ -11,7 +12,7 @@ void
Download::set_download(torrent::Download d) {
m_download = d;
m_connTrackerSucceded = m_download.signal_tracker_succeded(sigc::bind(sigc::mem_fun(*this, &Download::receive_tracker_msg), ""));
m_connTrackerSucceded = m_download.signal_tracker_succeded(sigc::hide(sigc::bind(sigc::mem_fun(*this, &Download::receive_tracker_msg), "")));
m_connTrackerFailed = m_download.signal_tracker_failed(sigc::mem_fun(*this, &Download::receive_tracker_msg));
}
+18
View File
@@ -6,7 +6,9 @@
#include <fstream>
#include <istream>
#include <sstream>
#include <iterator>
#include <sigc++/bind.h>
#include <torrent/bencode.h>
#include <torrent/exceptions.h>
#include <torrent/torrent.h>
@@ -138,7 +140,23 @@ Manager::create_final(std::istream* s) {
start(*itr);
m_downloadStore.save(*itr);
if (m_debugTracker >= 0)
(*itr)->get_download().signal_tracker_succeded(sigc::mem_fun(*this, &Manager::receive_debug_tracker));
return itr;
}
void
Manager::receive_debug_tracker(torrent::Bencode& bencode) {
std::stringstream filename;
filename << "./tracker_dump." << m_debugTracker++;
std::fstream out(filename.str().c_str(), std::ios::out | std::ios::trunc);
if (!out.good())
return;
out << bencode;
}
}
+11 -1
View File
@@ -8,6 +8,10 @@
#include "poll.h"
#include "log.h"
namespace torrent {
class Bencode;
}
namespace core {
class Manager {
@@ -16,7 +20,7 @@ public:
typedef sigc::slot1<void, DownloadList::iterator> SlotReady;
typedef sigc::slot0<void> SlotFailed;
Manager() : m_portFirst(6890), m_portLast(6999) {}
Manager() : m_portFirst(6890), m_portLast(6999), m_debugTracker(-1) {}
DownloadList& get_download_list() { return m_downloadList; }
DownloadStore& get_download_store() { return m_downloadStore; }
@@ -40,6 +44,8 @@ public:
void set_port_range(int a, int b) { m_portFirst = a; m_portLast = b; }
void debug_tracker() { m_debugTracker = 0; }
private:
void receive_http_done(CurlGet* http);
void receive_http_failed(std::string msg);
@@ -49,6 +55,8 @@ private:
iterator create_final(std::istream* s);
void receive_debug_tracker(torrent::Bencode& bencode);
DownloadList m_downloadList;
DownloadStore m_downloadStore;
HashQueue m_hashQueue;
@@ -60,6 +68,8 @@ private:
std::string m_dns;
int m_portFirst;
int m_portLast;
int m_debugTracker;
};
}