merged all proxy settings into a single one
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
* merged all proxy settings into a single one
|
||||||
* improved SOCKS5 support by proxying hostname lookups
|
* improved SOCKS5 support by proxying hostname lookups
|
||||||
* improved support for multi-homed clients
|
* improved support for multi-homed clients
|
||||||
* added feature to not count downloaded bytes from web seeds in stats
|
* added feature to not count downloaded bytes from web seeds in stats
|
||||||
|
@@ -304,40 +304,24 @@ namespace libtorrent
|
|||||||
void save_state(entry* e, boost::uint32_t flags) const;
|
void save_state(entry* e, boost::uint32_t flags) const;
|
||||||
void load_state(lazy_entry const* e);
|
void load_state(lazy_entry const* e);
|
||||||
|
|
||||||
// TODO: just use a single proxy for everything. That's essentially how
|
void set_proxy(proxy_settings const& s);
|
||||||
// it works behind the scene anyway, with the udp socket being used for
|
proxy_settings const& proxy() const { return m_proxy; }
|
||||||
// both DHT, uTP peers and udp trackers.
|
|
||||||
void set_peer_proxy(proxy_settings const& s)
|
|
||||||
{
|
|
||||||
m_peer_proxy = s;
|
|
||||||
// in case we just set a socks proxy, we might have to
|
|
||||||
// open the socks incoming connection
|
|
||||||
if (!m_socks_listen_socket) open_new_incoming_socks_connection();
|
|
||||||
m_udp_socket.set_proxy_settings(m_peer_proxy);
|
|
||||||
}
|
|
||||||
void set_web_seed_proxy(proxy_settings const& s)
|
|
||||||
{ m_web_seed_proxy = s; }
|
|
||||||
void set_tracker_proxy(proxy_settings const& s)
|
|
||||||
{
|
|
||||||
m_udp_socket.set_proxy_settings(s);
|
|
||||||
m_tracker_proxy = s;
|
|
||||||
}
|
|
||||||
|
|
||||||
proxy_settings const& peer_proxy() const
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
{ return m_peer_proxy; }
|
void set_peer_proxy(proxy_settings const& s) { set_proxy(s); }
|
||||||
proxy_settings const& web_seed_proxy() const
|
void set_web_seed_proxy(proxy_settings const& s) { set_proxy(s); }
|
||||||
{ return m_web_seed_proxy; }
|
void set_tracker_proxy(proxy_settings const& s) { set_proxy(s); }
|
||||||
proxy_settings const& tracker_proxy() const
|
proxy_settings const& peer_proxy() const { return proxy(); }
|
||||||
{ return m_tracker_proxy; }
|
proxy_settings const& web_seed_proxy() const { return proxy(); }
|
||||||
|
proxy_settings const& tracker_proxy() const { return proxy(); }
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
|
void set_dht_proxy(proxy_settings const& s) { set_proxy(s); }
|
||||||
|
proxy_settings const& dht_proxy() const { return proxy(); }
|
||||||
|
#endif
|
||||||
|
#endif // TORRENT_NO_DEPRECATE
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
void set_dht_proxy(proxy_settings const& s)
|
|
||||||
{
|
|
||||||
m_dht_proxy = s;
|
|
||||||
m_udp_socket.set_proxy_settings(s);
|
|
||||||
}
|
|
||||||
proxy_settings const& dht_proxy() const
|
|
||||||
{ return m_dht_proxy; }
|
|
||||||
bool is_dht_running() const { return m_dht; }
|
bool is_dht_running() const { return m_dht; }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -605,14 +589,9 @@ namespace libtorrent
|
|||||||
|
|
||||||
// the settings for the client
|
// the settings for the client
|
||||||
session_settings m_settings;
|
session_settings m_settings;
|
||||||
// the proxy settings for different
|
|
||||||
// kinds of connections
|
// the proxy used for bittorrent
|
||||||
proxy_settings m_peer_proxy;
|
proxy_settings m_proxy;
|
||||||
proxy_settings m_web_seed_proxy;
|
|
||||||
proxy_settings m_tracker_proxy;
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
|
||||||
proxy_settings m_dht_proxy;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
entry m_dht_state;
|
entry m_dht_state;
|
||||||
|
@@ -180,14 +180,18 @@ namespace libtorrent
|
|||||||
{
|
{
|
||||||
save_settings = 0x001,
|
save_settings = 0x001,
|
||||||
save_dht_settings = 0x002,
|
save_dht_settings = 0x002,
|
||||||
save_dht_proxy = 0x004,
|
save_dht_state = 0x004,
|
||||||
save_dht_state = 0x008,
|
save_proxy = 0x008,
|
||||||
save_i2p_proxy = 0x010,
|
save_i2p_proxy = 0x010,
|
||||||
save_encryption_settings = 0x020,
|
save_encryption_settings = 0x020,
|
||||||
save_peer_proxy = 0x040,
|
save_as_map = 0x040,
|
||||||
save_web_proxy = 0x080,
|
|
||||||
save_tracker_proxy = 0x100,
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
save_as_map = 0x200
|
save_dht_proxy = save_proxy,
|
||||||
|
save_peer_proxy = save_proxy,
|
||||||
|
save_web_proxy = save_proxy,
|
||||||
|
save_tracker_proxy = save_proxy
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
void save_state(entry& e, boost::uint32_t flags = 0xffffffff) const;
|
void save_state(entry& e, boost::uint32_t flags = 0xffffffff) const;
|
||||||
void load_state(lazy_entry const& e);
|
void load_state(lazy_entry const& e);
|
||||||
@@ -356,17 +360,31 @@ namespace libtorrent
|
|||||||
void set_settings(session_settings const& s);
|
void set_settings(session_settings const& s);
|
||||||
session_settings settings();
|
session_settings settings();
|
||||||
|
|
||||||
void set_peer_proxy(proxy_settings const& s);
|
void set_proxy(proxy_settings const& s);
|
||||||
void set_web_seed_proxy(proxy_settings const& s);
|
proxy_settings proxy() const;
|
||||||
void set_tracker_proxy(proxy_settings const& s);
|
|
||||||
|
|
||||||
proxy_settings peer_proxy() const;
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
proxy_settings web_seed_proxy() const;
|
// deprecated in 0.16
|
||||||
proxy_settings tracker_proxy() const;
|
TORRENT_DEPRECATED_PREFIX
|
||||||
|
void set_peer_proxy(proxy_settings const& s) TORRENT_DEPRECATED;
|
||||||
|
TORRENT_DEPRECATED_PREFIX
|
||||||
|
void set_web_seed_proxy(proxy_settings const& s) TORRENT_DEPRECATED;
|
||||||
|
TORRENT_DEPRECATED_PREFIX
|
||||||
|
void set_tracker_proxy(proxy_settings const& s) TORRENT_DEPRECATED;
|
||||||
|
|
||||||
|
TORRENT_DEPRECATED_PREFIX
|
||||||
|
proxy_settings peer_proxy() const TORRENT_DEPRECATED;
|
||||||
|
TORRENT_DEPRECATED_PREFIX
|
||||||
|
proxy_settings web_seed_proxy() const TORRENT_DEPRECATED;
|
||||||
|
TORRENT_DEPRECATED_PREFIX
|
||||||
|
proxy_settings tracker_proxy() const TORRENT_DEPRECATED;
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
void set_dht_proxy(proxy_settings const& s);
|
TORRENT_DEPRECATED_PREFIX
|
||||||
proxy_settings dht_proxy() const;
|
void set_dht_proxy(proxy_settings const& s) TORRENT_DEPRECATED;
|
||||||
|
TORRENT_DEPRECATED_PREFIX
|
||||||
|
proxy_settings dht_proxy() const TORRENT_DEPRECATED;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
|
@@ -197,7 +197,7 @@ namespace libtorrent
|
|||||||
size -= pr.length;
|
size -= pr.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy_settings const& ps = m_ses.web_seed_proxy();
|
proxy_settings const& ps = m_ses.proxy();
|
||||||
bool using_proxy = ps.type == proxy_settings::http
|
bool using_proxy = ps.type == proxy_settings::http
|
||||||
|| ps.type == proxy_settings::http_pw;
|
|| ps.type == proxy_settings::http_pw;
|
||||||
|
|
||||||
|
@@ -738,6 +738,18 @@ namespace libtorrent
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void session::set_proxy(proxy_settings const& s)
|
||||||
|
{
|
||||||
|
TORRENT_ASYNC_CALL1(set_proxy, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy_settings session::proxy() const
|
||||||
|
{
|
||||||
|
TORRENT_SYNC_CALL_RET(proxy_settings, proxy);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
void session::set_peer_proxy(proxy_settings const& s)
|
void session::set_peer_proxy(proxy_settings const& s)
|
||||||
{
|
{
|
||||||
TORRENT_ASYNC_CALL1(set_peer_proxy, s);
|
TORRENT_ASYNC_CALL1(set_peer_proxy, s);
|
||||||
@@ -784,6 +796,7 @@ namespace libtorrent
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#endif // TORRENT_NO_DEPRECATE
|
||||||
|
|
||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
void session::set_i2p_proxy(proxy_settings const& s)
|
void session::set_i2p_proxy(proxy_settings const& s)
|
||||||
|
@@ -379,7 +379,7 @@ namespace aux {
|
|||||||
TORRENT_CATEGORY("settings", save_settings, m_settings, session_settings_map)
|
TORRENT_CATEGORY("settings", save_settings, m_settings, session_settings_map)
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
// TORRENT_CATEGORY("dht", save_dht_settings, m_dht_settings, dht_settings_map)
|
// TORRENT_CATEGORY("dht", save_dht_settings, m_dht_settings, dht_settings_map)
|
||||||
TORRENT_CATEGORY("dht proxy", save_dht_proxy, m_dht_proxy, proxy_settings_map)
|
TORRENT_CATEGORY("proxy", save_proxy, m_proxy, proxy_settings_map)
|
||||||
#endif
|
#endif
|
||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
// TORRENT_CATEGORY("i2p", save_i2p_proxy, m_i2p_proxy, proxy_settings_map)
|
// TORRENT_CATEGORY("i2p", save_i2p_proxy, m_i2p_proxy, proxy_settings_map)
|
||||||
@@ -387,9 +387,6 @@ namespace aux {
|
|||||||
#ifndef TORRENT_DISABLE_ENCRYPTION
|
#ifndef TORRENT_DISABLE_ENCRYPTION
|
||||||
TORRENT_CATEGORY("encryption", save_encryption_settings, m_pe_settings, pe_settings_map)
|
TORRENT_CATEGORY("encryption", save_encryption_settings, m_pe_settings, pe_settings_map)
|
||||||
#endif
|
#endif
|
||||||
TORRENT_CATEGORY("peer proxy", save_peer_proxy, m_peer_proxy, proxy_settings_map)
|
|
||||||
TORRENT_CATEGORY("web proxy", save_web_proxy, m_web_seed_proxy, proxy_settings_map)
|
|
||||||
TORRENT_CATEGORY("tracker proxy", save_tracker_proxy, m_tracker_proxy, proxy_settings_map)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef lenof
|
#undef lenof
|
||||||
@@ -482,7 +479,7 @@ namespace aux {
|
|||||||
#else
|
#else
|
||||||
, m_upload_rate(peer_connection::upload_channel)
|
, m_upload_rate(peer_connection::upload_channel)
|
||||||
#endif
|
#endif
|
||||||
, m_tracker_manager(*this, m_tracker_proxy)
|
, m_tracker_manager(*this, m_proxy)
|
||||||
, m_listen_port_retries(listen_port_range.second - listen_port_range.first)
|
, m_listen_port_retries(listen_port_range.second - listen_port_range.first)
|
||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
, m_i2p_conn(m_io_service)
|
, m_i2p_conn(m_io_service)
|
||||||
@@ -837,6 +834,15 @@ namespace aux {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void session_impl::set_proxy(proxy_settings const& s)
|
||||||
|
{
|
||||||
|
m_proxy = s;
|
||||||
|
// in case we just set a socks proxy, we might have to
|
||||||
|
// open the socks incoming connection
|
||||||
|
if (!m_socks_listen_socket) open_new_incoming_socks_connection();
|
||||||
|
m_udp_socket.set_proxy_settings(m_proxy);
|
||||||
|
}
|
||||||
|
|
||||||
void session_impl::load_state(lazy_entry const* e)
|
void session_impl::load_state(lazy_entry const* e)
|
||||||
{
|
{
|
||||||
lazy_entry const* settings;
|
lazy_entry const* settings;
|
||||||
@@ -1566,15 +1572,15 @@ namespace aux {
|
|||||||
|
|
||||||
void session_impl::open_new_incoming_socks_connection()
|
void session_impl::open_new_incoming_socks_connection()
|
||||||
{
|
{
|
||||||
if (m_peer_proxy.type != proxy_settings::socks5
|
if (m_proxy.type != proxy_settings::socks5
|
||||||
&& m_peer_proxy.type != proxy_settings::socks5_pw
|
&& m_proxy.type != proxy_settings::socks5_pw
|
||||||
&& m_peer_proxy.type != proxy_settings::socks4)
|
&& m_proxy.type != proxy_settings::socks4)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_socks_listen_socket) return;
|
if (m_socks_listen_socket) return;
|
||||||
|
|
||||||
m_socks_listen_socket = boost::shared_ptr<socket_type>(new socket_type(m_io_service));
|
m_socks_listen_socket = boost::shared_ptr<socket_type>(new socket_type(m_io_service));
|
||||||
bool ret = instantiate_connection(m_io_service, m_peer_proxy
|
bool ret = instantiate_connection(m_io_service, m_proxy
|
||||||
, *m_socks_listen_socket);
|
, *m_socks_listen_socket);
|
||||||
TORRENT_ASSERT(ret);
|
TORRENT_ASSERT(ret);
|
||||||
|
|
||||||
@@ -3321,7 +3327,7 @@ namespace aux {
|
|||||||
// proxy, and it's the same one as we're using for the tracker
|
// proxy, and it's the same one as we're using for the tracker
|
||||||
// just tell the tracker the socks5 port we're listening on
|
// just tell the tracker the socks5 port we're listening on
|
||||||
if (m_socks_listen_socket && m_socks_listen_socket->is_open()
|
if (m_socks_listen_socket && m_socks_listen_socket->is_open()
|
||||||
&& m_peer_proxy.hostname == m_tracker_proxy.hostname)
|
&& m_proxy.hostname == m_proxy.hostname)
|
||||||
return m_socks_listen_port;
|
return m_socks_listen_port;
|
||||||
|
|
||||||
// if not, don't tell the tracker anything if we're in anonymous
|
// if not, don't tell the tracker anything if we're in anonymous
|
||||||
|
@@ -1480,7 +1480,7 @@ namespace libtorrent
|
|||||||
// in anonymous_mode we don't talk directly to trackers
|
// in anonymous_mode we don't talk directly to trackers
|
||||||
// only if there is a proxy
|
// only if there is a proxy
|
||||||
std::string protocol = req.url.substr(0, req.url.find(':'));
|
std::string protocol = req.url.substr(0, req.url.find(':'));
|
||||||
int proxy_type = m_ses.m_tracker_proxy.type;
|
int proxy_type = m_ses.m_proxy.type;
|
||||||
|
|
||||||
if ((protocol == "http" || protocol == "https")
|
if ((protocol == "http" || protocol == "https")
|
||||||
&& proxy_type == proxy_settings::none)
|
&& proxy_type == proxy_settings::none)
|
||||||
@@ -3345,7 +3345,7 @@ namespace libtorrent
|
|||||||
}
|
}
|
||||||
|
|
||||||
web->resolving = true;
|
web->resolving = true;
|
||||||
proxy_settings const& ps = m_ses.web_seed_proxy();
|
proxy_settings const& ps = m_ses.proxy();
|
||||||
if (ps.type == proxy_settings::http
|
if (ps.type == proxy_settings::http
|
||||||
|| ps.type == proxy_settings::http_pw)
|
|| ps.type == proxy_settings::http_pw)
|
||||||
{
|
{
|
||||||
@@ -3481,11 +3481,11 @@ namespace libtorrent
|
|||||||
boost::shared_ptr<socket_type> s(new (std::nothrow) socket_type(m_ses.m_io_service));
|
boost::shared_ptr<socket_type> s(new (std::nothrow) socket_type(m_ses.m_io_service));
|
||||||
if (!s) return;
|
if (!s) return;
|
||||||
|
|
||||||
bool ret = instantiate_connection(m_ses.m_io_service, m_ses.web_seed_proxy(), *s);
|
bool ret = instantiate_connection(m_ses.m_io_service, m_ses.proxy(), *s);
|
||||||
(void)ret;
|
(void)ret;
|
||||||
TORRENT_ASSERT(ret);
|
TORRENT_ASSERT(ret);
|
||||||
|
|
||||||
proxy_settings const& ps = m_ses.web_seed_proxy();
|
proxy_settings const& ps = m_ses.proxy();
|
||||||
if (ps.type == proxy_settings::http
|
if (ps.type == proxy_settings::http
|
||||||
|| ps.type == proxy_settings::http_pw)
|
|| ps.type == proxy_settings::http_pw)
|
||||||
{
|
{
|
||||||
@@ -4295,7 +4295,7 @@ namespace libtorrent
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool ret = instantiate_connection(m_ses.m_io_service, m_ses.peer_proxy(), *s);
|
bool ret = instantiate_connection(m_ses.m_io_service, m_ses.proxy(), *s);
|
||||||
(void)ret;
|
(void)ret;
|
||||||
TORRENT_ASSERT(ret);
|
TORRENT_ASSERT(ret);
|
||||||
}
|
}
|
||||||
|
@@ -218,7 +218,7 @@ namespace libtorrent
|
|||||||
size -= pr.length;
|
size -= pr.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy_settings const& ps = m_ses.web_seed_proxy();
|
proxy_settings const& ps = m_ses.proxy();
|
||||||
bool using_proxy = ps.type == proxy_settings::http
|
bool using_proxy = ps.type == proxy_settings::http
|
||||||
|| ps.type == proxy_settings::http_pw;
|
|| ps.type == proxy_settings::http_pw;
|
||||||
|
|
||||||
|
@@ -254,8 +254,8 @@ void test_transfer(int proxy_type, bool test_disk_full = false, bool test_allowe
|
|||||||
ps.username = "testuser";
|
ps.username = "testuser";
|
||||||
ps.password = "testpass";
|
ps.password = "testpass";
|
||||||
ps.type = (proxy_settings::proxy_type)proxy_type;
|
ps.type = (proxy_settings::proxy_type)proxy_type;
|
||||||
ses1.set_tracker_proxy(ps);
|
ses1.set_proxy(ps);
|
||||||
ses2.set_tracker_proxy(ps);
|
ses2.set_proxy(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
session_settings sett;
|
session_settings sett;
|
||||||
|
@@ -73,7 +73,7 @@ void test_transfer(boost::intrusive_ptr<torrent_info> torrent_file, int proxy, i
|
|||||||
ps.username = "testuser";
|
ps.username = "testuser";
|
||||||
ps.password = "testpass";
|
ps.password = "testpass";
|
||||||
ps.type = (proxy_settings::proxy_type)proxy;
|
ps.type = (proxy_settings::proxy_type)proxy;
|
||||||
ses.set_web_seed_proxy(ps);
|
ses.set_proxy(ps);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_torrent_params p;
|
add_torrent_params p;
|
||||||
|
Reference in New Issue
Block a user