mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-11 08:39:21 +00:00
* Added preliminary support for tunneling peer connections through a
http proxy. Doesn't currently support error checking or such. Use the 'connection_proxy' option to enable. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@796 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+41
-2
@@ -133,11 +133,14 @@ Manager::handshake_log(const sockaddr* sa, torrent::ConnectionManager::Handshake
|
||||
case torrent::ConnectionManager::handshake_incoming:
|
||||
m_logComplete.push_front("Incoming connection from " + peer + download);
|
||||
break;
|
||||
case torrent::ConnectionManager::handshake_outgoing:
|
||||
m_logComplete.push_front("Outgoing connection to " + peer + download);
|
||||
break;
|
||||
case torrent::ConnectionManager::handshake_outgoing_encrypted:
|
||||
m_logComplete.push_front("Outgoing encrypted connection to " + peer + download);
|
||||
break;
|
||||
case torrent::ConnectionManager::handshake_outgoing:
|
||||
m_logComplete.push_front("Outgoing connection to " + peer + download);
|
||||
case torrent::ConnectionManager::handshake_outgoing_proxy:
|
||||
m_logComplete.push_front("Outgoing proxy connection to " + peer + download);
|
||||
break;
|
||||
case torrent::ConnectionManager::handshake_success:
|
||||
m_logComplete.push_front("Successful handshake: " + peer + download);
|
||||
@@ -350,6 +353,42 @@ Manager::set_local_address(const std::string& addr) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
Manager::proxy_address() const {
|
||||
return rak::socket_address::cast_from(torrent::connection_manager()->proxy_address())->address_str();
|
||||
}
|
||||
|
||||
void
|
||||
Manager::set_proxy_address(const std::string& addr) {
|
||||
int port;
|
||||
rak::address_info* ai;
|
||||
|
||||
char buf[addr.length() + 1];
|
||||
|
||||
int err = std::sscanf(addr.c_str(), "%[^:]:%i", buf, &port);
|
||||
|
||||
if (err <= 0)
|
||||
throw torrent::input_error("Could not parse proxy address.");
|
||||
|
||||
if (err == 1)
|
||||
port = 80;
|
||||
|
||||
if ((err = rak::address_info::get_address_info(buf, PF_INET, SOCK_STREAM, &ai)) != 0)
|
||||
throw torrent::input_error("Could not set proxy address: " + std::string(rak::address_info::strerror(err)) + ".");
|
||||
|
||||
try {
|
||||
|
||||
ai->address()->set_port(port);
|
||||
torrent::connection_manager()->set_proxy_address(ai->address()->c_sockaddr());
|
||||
|
||||
rak::address_info::free_address_info(ai);
|
||||
|
||||
} catch (torrent::input_error& e) {
|
||||
rak::address_info::free_address_info(ai);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Manager::receive_http_failed(std::string msg) {
|
||||
m_logImportant.push_front("Http download error: \"" + msg + "\"");
|
||||
|
||||
Reference in New Issue
Block a user