mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 06:39:23 +00:00
* Return torrent::Object instead of reference from
utils::VariableMap::call_command(...). * More cleanup of the command calls. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@895 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
@@ -207,9 +207,9 @@ Download::receive_chunk_failed(__UNUSED uint32_t idx) {
|
||||
}
|
||||
|
||||
int64_t Download::get_value(const char* key) { return control->download_variables()->get_d_value(this, key); }
|
||||
const std::string& Download::get_string(const char* key) { return control->download_variables()->get_d_string(this, key); }
|
||||
const std::string Download::get_string(const char* key) { return control->download_variables()->get_d_string(this, key); }
|
||||
int64_t Download::get_std_value(const std::string& key) { return control->download_variables()->get_d_value(this, key.c_str()); }
|
||||
const std::string& Download::get_std_string(const std::string& key) { return control->download_variables()->get_d_string(this, key.c_str()); }
|
||||
const std::string Download::get_std_string(const std::string& key) { return control->download_variables()->get_d_string(this, key.c_str()); }
|
||||
void Download::set(const char* key, const torrent::Object& value) { return control->download_variables()->set_d(this, key, value); }
|
||||
void Download::set_value(const char* key, int64_t value) { return control->download_variables()->set_d_value(this, key, value); }
|
||||
void Download::set_string(const char* key, const std::string& value) { return control->download_variables()->set_d_string(this, key, value); }
|
||||
|
||||
+2
-2
@@ -101,10 +101,10 @@ public:
|
||||
void set_priority(uint32_t p);
|
||||
|
||||
int64_t get_value(const char* key);
|
||||
const std::string& get_string(const char* key);
|
||||
const std::string get_string(const char* key);
|
||||
|
||||
int64_t get_std_value(const std::string& key);
|
||||
const std::string& get_std_string(const std::string& key);
|
||||
const std::string get_std_string(const std::string& key);
|
||||
|
||||
void set(const char* key, const torrent::Object& value);
|
||||
|
||||
|
||||
+23
-10
@@ -184,9 +184,7 @@ Manager::delete_tied(Download* download) {
|
||||
Manager::Manager() :
|
||||
m_hashingView(NULL),
|
||||
|
||||
m_pollManager(NULL),
|
||||
m_portFirst(6890),
|
||||
m_portLast(6999) {
|
||||
m_pollManager(NULL) {
|
||||
|
||||
m_downloadStore = new DownloadStore();
|
||||
m_downloadList = new DownloadList();
|
||||
@@ -276,25 +274,40 @@ Manager::shutdown(bool force) {
|
||||
|
||||
void
|
||||
Manager::listen_open() {
|
||||
// This stuff really should be moved outside of manager, make it
|
||||
// part of the init script.
|
||||
if (!control->variable()->get_value("get_port_open"))
|
||||
return;
|
||||
|
||||
if (m_portFirst > m_portLast)
|
||||
throw torrent::input_error("Invalid port range for listening");
|
||||
int portFirst, portLast;
|
||||
torrent::Object portRange = control->variable()->get("get_port_range");
|
||||
|
||||
if (portRange.is_string()) {
|
||||
if (std::sscanf(portRange.as_string().c_str(), "%i-%i", &portFirst, &portLast) != 2)
|
||||
throw torrent::input_error("Invalid port_range argument.");
|
||||
|
||||
// } else if (portRange.is_list()) {
|
||||
|
||||
} else {
|
||||
throw torrent::input_error("Invalid port_range argument.");
|
||||
}
|
||||
|
||||
if (portFirst > portLast || portLast >= (1 << 16))
|
||||
throw torrent::input_error("Invalid port range.");
|
||||
|
||||
if (control->variable()->get_value("get_port_random")) {
|
||||
int boundary = m_portFirst + random() % (m_portLast - m_portFirst + 1);
|
||||
int boundary = portFirst + random() % (portLast - portFirst + 1);
|
||||
|
||||
if (torrent::connection_manager()->listen_open(boundary, m_portLast) ||
|
||||
torrent::connection_manager()->listen_open(m_portFirst, boundary))
|
||||
if (torrent::connection_manager()->listen_open(boundary, portLast) ||
|
||||
torrent::connection_manager()->listen_open(portFirst, boundary))
|
||||
return;
|
||||
|
||||
} else {
|
||||
if (torrent::connection_manager()->listen_open(m_portFirst, m_portLast))
|
||||
if (torrent::connection_manager()->listen_open(portFirst, portLast))
|
||||
return;
|
||||
}
|
||||
|
||||
throw torrent::input_error("Could not open/bind a port for listening: " + std::string(rak::error_number::current().c_str()));
|
||||
throw torrent::input_error("Could not open/bind port for listening: " + std::string(rak::error_number::current().c_str()));
|
||||
}
|
||||
|
||||
std::string
|
||||
|
||||
@@ -74,8 +74,6 @@ public:
|
||||
Log& get_log_important() { return m_logImportant; }
|
||||
Log& get_log_complete() { return m_logComplete; }
|
||||
|
||||
void set_port_range(int a, int b) { m_portFirst = a; m_portLast = b; }
|
||||
|
||||
// Really should find a more descriptive name.
|
||||
void initialize_first();
|
||||
void initialize_second();
|
||||
@@ -123,9 +121,6 @@ private:
|
||||
PollManager* m_pollManager;
|
||||
Log m_logImportant;
|
||||
Log m_logComplete;
|
||||
|
||||
int m_portFirst;
|
||||
int m_portLast;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user