mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 14:12:31 +00:00
* Changed to using sockaddr* in libtorrent's api.
* Prepared SocketManager for inclusion in the api. * From <nornagon@gmail.com>: bound some control keys in text input. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@650 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+23
-8
@@ -39,12 +39,13 @@
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <rak/socket_address.h>
|
||||
#include <rak/timer.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/rate.h>
|
||||
#include <torrent/tracker.h>
|
||||
|
||||
#include "core/download.h"
|
||||
#include <rak/timer.h>
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
@@ -90,6 +91,19 @@ print_ddmmyyyy(char* first, char* last, time_t t) {
|
||||
return print_buffer(first, last, "%02u/%02u/%04u", u->tm_mday, (u->tm_mon + 1), (1900 + u->tm_year));
|
||||
}
|
||||
|
||||
char*
|
||||
print_address(char* first, char* last, const rak::socket_address* sa) {
|
||||
if (!sa->address_c_str(first, last - first))
|
||||
return first;
|
||||
|
||||
return std::find(first, last, '\0');
|
||||
}
|
||||
|
||||
inline char*
|
||||
print_address(char* first, char* last, const sockaddr* sa) {
|
||||
return print_address(first, last, rak::socket_address::cast_from(sa));
|
||||
}
|
||||
|
||||
char*
|
||||
print_download_title(char* first, char* last, core::Download* d) {
|
||||
return print_buffer(first, last, " %s", d->get_download().name().c_str());
|
||||
@@ -198,17 +212,18 @@ print_status_info(char* first, char* last) {
|
||||
(double)torrent::up_rate()->rate() / 1024.0,
|
||||
(double)torrent::down_rate()->rate() / 1024.0);
|
||||
|
||||
first = print_buffer(first, last, " [Listen %s:%u]",
|
||||
torrent::local_address().c_str(),
|
||||
(unsigned int)torrent::listen_port());
|
||||
first = print_buffer(first, last, " [Listen ");
|
||||
first = print_address(first, last, torrent::local_address());
|
||||
first = print_buffer(first, last, ":%u]", (unsigned int)torrent::listen_port());
|
||||
|
||||
if (first > last)
|
||||
throw torrent::internal_error("print_status_info(...) wrote past end of the buffer.");
|
||||
|
||||
std::string bindAddress = torrent::bind_address();
|
||||
|
||||
if (!bindAddress.empty())
|
||||
first = print_buffer(first, last, " [Bind %s]", bindAddress.c_str());
|
||||
if (!rak::socket_address::cast_from(torrent::bind_address())->is_address_any()) {
|
||||
first = print_buffer(first, last, " [Bind ");
|
||||
first = print_address(first, last, torrent::bind_address());
|
||||
first = print_buffer(first, last, "]");
|
||||
}
|
||||
|
||||
return first;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user