mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 21:22:31 +00:00
Added the -i switch.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@306 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+36
-18
@@ -1,9 +1,11 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <istream>
|
||||
#include <sstream>
|
||||
#include <sigc++/bind.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/torrent.h>
|
||||
@@ -77,16 +79,35 @@ Manager::stop(Download* d) {
|
||||
}
|
||||
|
||||
void
|
||||
Manager::create_file(const std::string& uri) {
|
||||
DownloadList::iterator itr = m_downloadList.end();
|
||||
Manager::set_dns(const std::string& dns) {
|
||||
unsigned int a, b, c, d;
|
||||
|
||||
if (std::sscanf(dns.c_str(), "%i.%i.%i.%i", &a, &b, &c, &d) != 4 ||
|
||||
(a >= 256 || b >= 256 || c >= 256 || d >= 256))
|
||||
throw std::runtime_error("Tried to set invalid ip address.");
|
||||
|
||||
std::stringstream str;
|
||||
str << a << '.' << b << '.' << c << '.' << d;
|
||||
|
||||
m_dns = str.str();
|
||||
}
|
||||
|
||||
void
|
||||
Manager::receive_http_done(CurlGet* http) {
|
||||
try {
|
||||
create_final(http->get_stream());
|
||||
|
||||
} catch (torrent::local_error& e) {
|
||||
// What to do? Keep in list for now.
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Manager::create_file(const std::string& uri) {
|
||||
try {
|
||||
std::fstream f(uri.c_str(), std::ios::in);
|
||||
|
||||
itr = m_downloadList.insert(&f);
|
||||
|
||||
start(*itr);
|
||||
m_downloadStore.save(*itr);
|
||||
create_final(&f);
|
||||
|
||||
} catch (torrent::local_error& e) {
|
||||
// What to do? Keep in list for now.
|
||||
@@ -101,19 +122,16 @@ Manager::create_http(const std::string& uri) {
|
||||
// Add the failed signal here.
|
||||
}
|
||||
|
||||
void
|
||||
Manager::receive_http_done(CurlGet* http) {
|
||||
DownloadList::iterator itr = m_downloadList.end();
|
||||
Manager::iterator
|
||||
Manager::create_final(std::istream* s) {
|
||||
iterator itr = m_downloadList.insert(s);
|
||||
|
||||
(*itr)->get_download().set_ip(m_dns);
|
||||
|
||||
try {
|
||||
itr = m_downloadList.insert(http->get_stream());
|
||||
start(*itr);
|
||||
m_downloadStore.save(*itr);
|
||||
|
||||
start(*itr);
|
||||
m_downloadStore.save(*itr);
|
||||
|
||||
} catch (torrent::local_error& e) {
|
||||
// What to do? Keep in list for now.
|
||||
}
|
||||
}
|
||||
return itr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+28
-22
@@ -17,38 +17,44 @@ public:
|
||||
|
||||
Manager() : m_portFirst(6890), m_portLast(6999) {}
|
||||
|
||||
DownloadList& get_download_list() { return m_downloadList; }
|
||||
DownloadStore& get_download_store() { return m_downloadStore; }
|
||||
HashQueue& get_hash_queue() { return m_hashQueue; }
|
||||
HttpQueue& get_http_queue() { return m_httpQueue; }
|
||||
DownloadList& get_download_list() { return m_downloadList; }
|
||||
DownloadStore& get_download_store() { return m_downloadStore; }
|
||||
HashQueue& get_hash_queue() { return m_hashQueue; }
|
||||
HttpQueue& get_http_queue() { return m_httpQueue; }
|
||||
|
||||
Poll& get_poll() { return m_poll; }
|
||||
Poll& get_poll() { return m_poll; }
|
||||
|
||||
void initialize();
|
||||
void cleanup();
|
||||
void initialize();
|
||||
void cleanup();
|
||||
|
||||
void insert(std::string uri);
|
||||
iterator erase(DownloadList::iterator itr);
|
||||
void insert(std::string uri);
|
||||
iterator erase(DownloadList::iterator itr);
|
||||
|
||||
void start(Download* d);
|
||||
void stop(Download* d);
|
||||
void start(Download* d);
|
||||
void stop(Download* d);
|
||||
|
||||
void set_port_range(int a, int b) { m_portFirst = a; m_portLast = b; }
|
||||
const std::string& get_dns() { return m_dns; }
|
||||
void set_dns(const std::string& dns);
|
||||
|
||||
void set_port_range(int a, int b) { m_portFirst = a; m_portLast = b; }
|
||||
|
||||
private:
|
||||
void receive_http_done(CurlGet* http);
|
||||
void receive_http_done(CurlGet* http);
|
||||
|
||||
void create_file(const std::string& uri);
|
||||
void create_http(const std::string& uri);
|
||||
void create_file(const std::string& uri);
|
||||
void create_http(const std::string& uri);
|
||||
|
||||
DownloadList m_downloadList;
|
||||
DownloadStore m_downloadStore;
|
||||
HashQueue m_hashQueue;
|
||||
HttpQueue m_httpQueue;
|
||||
Poll m_poll;
|
||||
iterator create_final(std::istream* s);
|
||||
|
||||
int m_portFirst;
|
||||
int m_portLast;
|
||||
DownloadList m_downloadList;
|
||||
DownloadStore m_downloadStore;
|
||||
HashQueue m_hashQueue;
|
||||
HttpQueue m_httpQueue;
|
||||
Poll m_poll;
|
||||
|
||||
std::string m_dns;
|
||||
int m_portFirst;
|
||||
int m_portLast;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user