mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-07 14:49:21 +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;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <rak/socket_address.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <torrent/rate.h>
|
||||
|
||||
@@ -101,8 +102,11 @@ WindowPeerInfo::redraw() {
|
||||
|
||||
m_canvas->print(0, y++, "*** Peer Info ***");
|
||||
|
||||
m_canvas->print(0, y++, "DNS: %s:%hu", (*m_focus)->address().c_str(), (*m_focus)->port());
|
||||
m_canvas->print(0, y++, "Id: %s" , rak::copy_escape_html((*m_focus)->id()).c_str());
|
||||
m_canvas->print(0, y++, "IP: %s:%hu",
|
||||
rak::socket_address::cast_from((*m_focus)->address())->address_str().c_str(),
|
||||
rak::socket_address::cast_from((*m_focus)->address())->port());
|
||||
|
||||
m_canvas->print(0, y++, "ID: %s" , rak::copy_escape_html((*m_focus)->id()).c_str());
|
||||
|
||||
char buf[128];
|
||||
control->client_info()->print(buf, buf + 128, (*m_focus)->id().c_str());
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <rak/socket_address.h>
|
||||
#include <torrent/rate.h>
|
||||
|
||||
#include "core/download.h"
|
||||
@@ -63,7 +64,7 @@ WindowPeerList::redraw() {
|
||||
int x = 2;
|
||||
int y = 0;
|
||||
|
||||
m_canvas->print(x, y, "DNS"); x += 16;
|
||||
m_canvas->print(x, y, "IP"); x += 16;
|
||||
m_canvas->print(x, y, "UP"); x += 7;
|
||||
m_canvas->print(x, y, "DOWN"); x += 7;
|
||||
m_canvas->print(x, y, "PEER"); x += 7;
|
||||
@@ -95,7 +96,7 @@ WindowPeerList::redraw() {
|
||||
|
||||
m_canvas->print(x, y, "%c %s",
|
||||
range.first == *m_focus ? '*' : ' ',
|
||||
p.address().c_str());
|
||||
rak::socket_address::cast_from(p.address())->address_str().c_str());
|
||||
x += 18;
|
||||
|
||||
m_canvas->print(x, y, "%.1f", (double)p.up_rate()->rate() / 1024); x += 7;
|
||||
|
||||
Reference in New Issue
Block a user