mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-17 22:56:18 +00:00
* Moved {bind,local}_address() to ConnectionManager.
* Various other API cleanups. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@651 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+6
-3
@@ -49,6 +49,7 @@
|
|||||||
#include <sigc++/bind.h>
|
#include <sigc++/bind.h>
|
||||||
#include <sigc++/hide.h>
|
#include <sigc++/hide.h>
|
||||||
#include <torrent/bencode.h>
|
#include <torrent/bencode.h>
|
||||||
|
#include <torrent/connection_manager.h>
|
||||||
#include <torrent/exceptions.h>
|
#include <torrent/exceptions.h>
|
||||||
|
|
||||||
#include "utils/variable_map.h"
|
#include "utils/variable_map.h"
|
||||||
@@ -289,11 +290,11 @@ Manager::set_bind_address(const std::string& addr) {
|
|||||||
|
|
||||||
if (torrent::listen_port() != 0) {
|
if (torrent::listen_port() != 0) {
|
||||||
torrent::listen_close();
|
torrent::listen_close();
|
||||||
torrent::set_bind_address(ai->address()->c_sockaddr());
|
torrent::connection_manager()->set_bind_address(ai->address()->c_sockaddr());
|
||||||
listen_open();
|
listen_open();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
torrent::set_bind_address(ai->address()->c_sockaddr());
|
torrent::connection_manager()->set_bind_address(ai->address()->c_sockaddr());
|
||||||
}
|
}
|
||||||
|
|
||||||
rak::address_info::free_address_info(ai);
|
rak::address_info::free_address_info(ai);
|
||||||
@@ -301,6 +302,7 @@ Manager::set_bind_address(const std::string& addr) {
|
|||||||
m_pollManager->get_http_stack()->set_bind_address(addr);
|
m_pollManager->get_http_stack()->set_bind_address(addr);
|
||||||
|
|
||||||
} catch (torrent::input_error& e) {
|
} catch (torrent::input_error& e) {
|
||||||
|
rak::address_info::free_address_info(ai);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -315,12 +317,13 @@ Manager::set_local_address(const std::string& addr) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
torrent::set_local_address(ai->address()->c_sockaddr());
|
torrent::connection_manager()->set_local_address(ai->address()->c_sockaddr());
|
||||||
rak::address_info::free_address_info(ai);
|
rak::address_info::free_address_info(ai);
|
||||||
|
|
||||||
m_pollManager->get_http_stack()->set_bind_address(addr);
|
m_pollManager->get_http_stack()->set_bind_address(addr);
|
||||||
|
|
||||||
} catch (torrent::input_error& e) {
|
} catch (torrent::input_error& e) {
|
||||||
|
rak::address_info::free_address_info(ai);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-5
@@ -42,6 +42,7 @@
|
|||||||
#include <rak/socket_address.h>
|
#include <rak/socket_address.h>
|
||||||
#include <rak/timer.h>
|
#include <rak/timer.h>
|
||||||
#include <torrent/exceptions.h>
|
#include <torrent/exceptions.h>
|
||||||
|
#include <torrent/connection_manager.h>
|
||||||
#include <torrent/rate.h>
|
#include <torrent/rate.h>
|
||||||
#include <torrent/tracker.h>
|
#include <torrent/tracker.h>
|
||||||
|
|
||||||
@@ -212,16 +213,20 @@ print_status_info(char* first, char* last) {
|
|||||||
(double)torrent::up_rate()->rate() / 1024.0,
|
(double)torrent::up_rate()->rate() / 1024.0,
|
||||||
(double)torrent::down_rate()->rate() / 1024.0);
|
(double)torrent::down_rate()->rate() / 1024.0);
|
||||||
|
|
||||||
first = print_buffer(first, last, " [Listen ");
|
first = print_buffer(first, last, " [Port: %i]", (unsigned int)torrent::listen_port());
|
||||||
first = print_address(first, last, torrent::local_address());
|
|
||||||
first = print_buffer(first, last, ":%u]", (unsigned int)torrent::listen_port());
|
if (!rak::socket_address::cast_from(torrent::connection_manager()->local_address())->is_address_any()) {
|
||||||
|
first = print_buffer(first, last, " [Local ");
|
||||||
|
first = print_address(first, last, torrent::connection_manager()->local_address());
|
||||||
|
first = print_buffer(first, last, "]");
|
||||||
|
}
|
||||||
|
|
||||||
if (first > last)
|
if (first > last)
|
||||||
throw torrent::internal_error("print_status_info(...) wrote past end of the buffer.");
|
throw torrent::internal_error("print_status_info(...) wrote past end of the buffer.");
|
||||||
|
|
||||||
if (!rak::socket_address::cast_from(torrent::bind_address())->is_address_any()) {
|
if (!rak::socket_address::cast_from(torrent::connection_manager()->bind_address())->is_address_any()) {
|
||||||
first = print_buffer(first, last, " [Bind ");
|
first = print_buffer(first, last, " [Bind ");
|
||||||
first = print_address(first, last, torrent::bind_address());
|
first = print_address(first, last, torrent::connection_manager()->bind_address());
|
||||||
first = print_buffer(first, last, "]");
|
first = print_buffer(first, last, "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user