mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-15 05:36:17 +00:00
* Clear the download rate when finishing a torrent.
* Fixed torrent::set_{bind,local}_address(...) so they update
correctly.
* Tweaked the time left display, show minutes instead of seconds.
* Add earlier check on validity of the socket address of
incoming/outgoing connection.
git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@610 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+8
-7
@@ -24,7 +24,7 @@
|
|||||||
# Default session directory. Make sure you don't run multiple instance
|
# Default session directory. Make sure you don't run multiple instance
|
||||||
# of rtorrent using the same session directory. Perhaps using a
|
# of rtorrent using the same session directory. Perhaps using a
|
||||||
# relative path?
|
# relative path?
|
||||||
#session =
|
#session = ./session
|
||||||
|
|
||||||
# The ip address reported to the tracker.
|
# The ip address reported to the tracker.
|
||||||
#ip = 127.0.0.1
|
#ip = 127.0.0.1
|
||||||
@@ -70,10 +70,11 @@
|
|||||||
# Number of sockets to simultaneously keep open.
|
# Number of sockets to simultaneously keep open.
|
||||||
#max_open_sockets = <no default>
|
#max_open_sockets = <no default>
|
||||||
|
|
||||||
# Dump data received from trackers to the files
|
|
||||||
# "./tracker_dump.<time>".
|
|
||||||
#tracker_dump = no
|
|
||||||
|
|
||||||
# Change the interval between each throttle tick, in milliseconds. In
|
# Example of scheduling commands: Switch between two ip's every 5
|
||||||
# the range 1-5000 ms.
|
# seconds.
|
||||||
#throttle_interval = 1000
|
#schedule = "ip_tick1,5,10,ip=torretta"
|
||||||
|
#schedule = "ip_tick2,10,10,ip=lampedusa"
|
||||||
|
|
||||||
|
# Remove a scheduled event.
|
||||||
|
#schedule_remove = "ip_tick1"
|
||||||
|
|||||||
+3
-3
@@ -245,18 +245,18 @@ Manager::receive_download_done(Download* d) {
|
|||||||
void
|
void
|
||||||
Manager::listen_open() {
|
Manager::listen_open() {
|
||||||
if (m_portFirst > m_portLast)
|
if (m_portFirst > m_portLast)
|
||||||
throw std::runtime_error("Invalid port range for listening");
|
throw torrent::input_error("Invalid port range for listening");
|
||||||
|
|
||||||
if (m_portRandom) {
|
if (m_portRandom) {
|
||||||
int boundary = m_portFirst + random() % (m_portLast - m_portFirst + 1);
|
int boundary = m_portFirst + random() % (m_portLast - m_portFirst + 1);
|
||||||
|
|
||||||
if (!torrent::listen_open(boundary, m_portLast) &&
|
if (!torrent::listen_open(boundary, m_portLast) &&
|
||||||
!torrent::listen_open(m_portFirst, boundary))
|
!torrent::listen_open(m_portFirst, boundary))
|
||||||
throw std::runtime_error("Could not open port for listening.");
|
throw torrent::input_error("Could not open/bind a port for listening.");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!torrent::listen_open(m_portFirst, m_portLast))
|
if (!torrent::listen_open(m_portFirst, m_portLast))
|
||||||
throw std::runtime_error("Could not open port for listening.");
|
throw torrent::input_error("Could not open/bind a port for listening.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -79,6 +79,8 @@ public:
|
|||||||
void initialize_second();
|
void initialize_second();
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
|
void listen_open();
|
||||||
|
|
||||||
void shutdown(bool force);
|
void shutdown(bool force);
|
||||||
|
|
||||||
DListItr insert(std::istream* s);
|
DListItr insert(std::istream* s);
|
||||||
@@ -92,8 +94,6 @@ public:
|
|||||||
void push_log(const std::string& msg) { m_logImportant.push_front(msg); m_logComplete.push_front(msg); }
|
void push_log(const std::string& msg) { m_logImportant.push_front(msg); m_logComplete.push_front(msg); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void listen_open();
|
|
||||||
|
|
||||||
void create_http(const std::string& uri);
|
void create_http(const std::string& uri);
|
||||||
void create_final(std::istream* s);
|
void create_final(std::istream* s);
|
||||||
|
|
||||||
|
|||||||
+10
-10
@@ -66,19 +66,19 @@ print_hhmmss(char* buf, unsigned int length, time_t t) {
|
|||||||
if (u == NULL)
|
if (u == NULL)
|
||||||
return "inv_time";
|
return "inv_time";
|
||||||
|
|
||||||
unsigned int s = snprintf(buf, length, "%02u:%02u:%02u", u->tm_hour, u->tm_min, u->tm_sec);
|
unsigned int s = snprintf(buf, length, "%2u:%02u:%02u", u->tm_hour, u->tm_min, u->tm_sec);
|
||||||
|
|
||||||
return buf + std::min(s, length);
|
return buf + std::min(s, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
print_hhhhmmss(char* buf, unsigned int length, time_t t) {
|
print_ddhhmm(char* buf, unsigned int length, time_t t) {
|
||||||
std::tm *u = std::localtime(&t);
|
unsigned int s;
|
||||||
|
|
||||||
if (u == NULL)
|
if (t / (24 * 3600) < 100)
|
||||||
return "inv_time";
|
s = snprintf(buf, length, "%2li:%02li:%02li", t / (24 * 3600), (t / 3600) % 24, (t / 60) % 60);
|
||||||
|
else
|
||||||
unsigned int s = snprintf(buf, length, "%2u:%02u:%02u", u->tm_hour, u->tm_min, u->tm_sec);
|
s = snprintf(buf, length, "--:--:--");
|
||||||
|
|
||||||
return buf + std::min(s, length);
|
return buf + std::min(s, length);
|
||||||
}
|
}
|
||||||
@@ -117,12 +117,12 @@ print_download_info(char* buf, unsigned int length, core::Download* d) {
|
|||||||
(double)d->get_download().bytes_done() / (double)(1 << 20),
|
(double)d->get_download().bytes_done() / (double)(1 << 20),
|
||||||
(double)d->get_download().bytes_total() / (double)(1 << 20)));
|
(double)d->get_download().bytes_total() / (double)(1 << 20)));
|
||||||
|
|
||||||
buf += std::max(0, snprintf(buf, last - buf, " Rate: %5.1f / %5.1f KB Uploaded: %.1f MB",
|
buf += std::max(0, snprintf(buf, last - buf, " Rate: %5.1f / %5.1f KB Uploaded: %7.1f MB ",
|
||||||
(double)d->get_download().up_rate()->rate() / (1 << 10),
|
(double)d->get_download().up_rate()->rate() / (1 << 10),
|
||||||
(double)d->get_download().down_rate()->rate() / (1 << 10),
|
(double)d->get_download().down_rate()->rate() / (1 << 10),
|
||||||
(double)d->get_download().up_rate()->total() / (1 << 20)));
|
(double)d->get_download().up_rate()->total() / (1 << 20)));
|
||||||
|
|
||||||
buf += std::max(0, snprintf(buf, length, " Left: "));
|
//buf += std::max(0, snprintf(buf, length, " Left: "));
|
||||||
buf = print_download_time_left(buf, length, d);
|
buf = print_download_time_left(buf, length, d);
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
@@ -165,7 +165,7 @@ print_download_time_left(char* buf, unsigned int length, core::Download* d) {
|
|||||||
|
|
||||||
time_t remaining = (d->get_download().bytes_total() - d->get_download().bytes_done()) / (rate & ~(uint32_t)(512 - 1));
|
time_t remaining = (d->get_download().bytes_total() - d->get_download().bytes_done()) / (rate & ~(uint32_t)(512 - 1));
|
||||||
|
|
||||||
return print_hhhhmmss(buf, length, remaining);
|
return print_ddhhmm(buf, length, remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
// char*
|
// char*
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ namespace display {
|
|||||||
char* print_string(char* buf, unsigned int length, char* str);
|
char* print_string(char* buf, unsigned int length, char* str);
|
||||||
|
|
||||||
char* print_hhmmss(char* buf, unsigned int length, time_t t);
|
char* print_hhmmss(char* buf, unsigned int length, time_t t);
|
||||||
char* print_hhhhmmss(char* buf, unsigned int length, time_t t);
|
char* print_ddhhmm(char* buf, unsigned int length, time_t t);
|
||||||
char* print_ddmmyyyy(char* buf, unsigned int length, time_t t);
|
char* print_ddmmyyyy(char* buf, unsigned int length, time_t t);
|
||||||
|
|
||||||
char* print_download_title(char* buf, unsigned int length, core::Download* d);
|
char* print_download_title(char* buf, unsigned int length, core::Download* d);
|
||||||
|
|||||||
@@ -158,7 +158,15 @@ apply_max_open_sockets(Control* m, int arg) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
apply_bind(Control* m, const std::string& arg) {
|
apply_bind(Control* m, const std::string& arg) {
|
||||||
|
bool reopenListen = torrent::listen_port();
|
||||||
|
|
||||||
|
if (reopenListen)
|
||||||
|
torrent::listen_close();
|
||||||
|
|
||||||
torrent::set_bind_address(arg);
|
torrent::set_bind_address(arg);
|
||||||
|
|
||||||
|
if (reopenListen)
|
||||||
|
m->core()->listen_open();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user