Added "-b" for binding the listening ip addresse.

Throw an error if no listening port is opened.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@386 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-04-09 18:19:14 +00:00
parent 874e46fc64
commit 8bf6a42048
8 changed files with 37 additions and 12 deletions
+1 -1
View File
@@ -5,10 +5,10 @@ LICENSE
Options and flags:
-b <a.b.c.d> Bind the listening socket to this IP.
-i <a.b.c.d> Set the IP address sent to the tracker.
-p <a-b> Open a port in the range a to b.
-s <dir> Use <dir> as the session directory. The torrents will be
saved with the info-hash in hex as the filename.
+8 -1
View File
@@ -26,4 +26,11 @@ Make accumulate return the value, no refs please...
Make sure it gracefully handles torrents that fail to open files.
Make throttle show off on 0 and up/down.
Bug: Add the same torrent while it is hash checking.
RELEASE:
Enable change of default download path.
Make sure we show better messages for signal_storage_error.
+2
View File
@@ -36,12 +36,14 @@ Download::set_download(torrent::Download d) {
m_connTrackerSucceded = m_download.signal_tracker_succeded(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));
m_connStorageError = m_download.signal_storage_error(sigc::mem_fun(*this, &Download::receive_tracker_msg));
}
void
Download::release_download() {
m_connTrackerSucceded.disconnect();
m_connTrackerFailed.disconnect();
m_connStorageError.disconnect();
}
void
+1
View File
@@ -58,6 +58,7 @@ private:
sigc::connection m_connTrackerSucceded;
sigc::connection m_connTrackerFailed;
sigc::connection m_connStorageError;
};
}
+3 -1
View File
@@ -48,7 +48,9 @@ Manager::initialize() {
CurlStack::init();
torrent::initialize();
torrent::listen_open(m_portFirst, m_portLast);
if (!torrent::listen_open(m_portFirst, m_portLast, m_listenIp))
throw std::runtime_error("Could not open port for listening.");
// Register log signals.
}
+5 -3
View File
@@ -62,12 +62,13 @@ public:
void start(Download* d);
void stop(Download* d);
const std::string& get_dns() { return m_dns; }
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; }
void set_port_range(int a, int b) { m_portFirst = a; m_portLast = b; }
void set_listen_ip(const std::string& ip) { m_listenIp = ip; }
void debug_tracker() { m_debugTracker = 0; }
void debug_tracker() { m_debugTracker = 0; }
private:
void receive_http_done(CurlGet* http);
@@ -92,6 +93,7 @@ private:
std::string m_dns;
int m_portFirst;
int m_portLast;
std::string m_listenIp;
int m_debugTracker;
};
+12 -5
View File
@@ -42,11 +42,18 @@ WindowStatusbar::redraw() {
m_nextDraw = utils::Timer::cache().round_seconds() + 1000000;
m_canvas->erase();
m_canvas->print(0, 0, "Throttle: %i Listen: %s:%i Handshakes: %i",
(int)torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) / 1024,
m_core->get_dns().empty() ? "<default>" : m_core->get_dns().c_str(),
(int)torrent::get(torrent::LISTEN_PORT),
(int)torrent::get(torrent::HANDSHAKES_TOTAL));
if (torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) == 0)
m_canvas->print(0, 0, "Throttle: off Listen: %s:%i Handshakes: %i",
m_core->get_dns().empty() ? "<default>" : m_core->get_dns().c_str(),
(int)torrent::get(torrent::LISTEN_PORT),
(int)torrent::get(torrent::HANDSHAKES_TOTAL));
else
m_canvas->print(0, 0, "Throttle: %i Listen: %s:%i Handshakes: %i",
(int)torrent::get(torrent::THROTTLE_ROOT_CONST_RATE) / 1024,
m_core->get_dns().empty() ? "<default>" : m_core->get_dns().c_str(),
(int)torrent::get(torrent::LISTEN_PORT),
(int)torrent::get(torrent::HANDSHAKES_TOTAL));
}
}
+5 -1
View File
@@ -92,7 +92,10 @@ int
parse_options(ui::Control* c, int argc, char** argv) {
OptionParser optionParser;
optionParser.insert_flag('h', sigc::ptr_fun(&print_help));
optionParser.insert_option('b', sigc::mem_fun(c->get_core(), &core::Manager::set_listen_ip));
optionParser.insert_option('i', sigc::mem_fun(c->get_core(), &core::Manager::set_dns));
optionParser.insert_option('p', sigc::bind(sigc::ptr_fun(OptionParser::call_int_pair),
sigc::mem_fun(c->get_core(), &core::Manager::set_port_range)));
optionParser.insert_option('s', sigc::mem_fun(c->get_core().get_download_store(), &core::DownloadStore::activate));
@@ -224,7 +227,8 @@ print_help() {
std::cout << std::endl;
std::cout << "Usage: rtorrent [OPTIONS]... [FILE]... [URL]..." << std::endl;
std::cout << " -h Display this very helpful text" << std::endl;
std::cout << " -i <a.b.c.d> Set the IP address that is sent to the tracker" << std::endl;
std::cout << " -b <a.b.c.d> Bind the listening socket to this IP" << std::endl;
std::cout << " -i <a.b.c.d> Change the IP that is sent to the tracker" << std::endl;
std::cout << " -p <int>-<int> Set port range for incoming connections" << std::endl;
std::cout << " -s <directory> Set the session directory" << std::endl;
std::cout << std::endl;