diff --git a/examples/client_test.cpp b/examples/client_test.cpp index 605e7e1a4..16ca55282 100644 --- a/examples/client_test.cpp +++ b/examples/client_test.cpp @@ -768,6 +768,7 @@ int main(int argc, char* argv[]) " -A allowed pieces set size\n" " -R number of blocks per read cache line\n" " -O Disallow disk job reordering\n" + " -P Use the specified SOCKS5 proxy\n" " -H Don't start DHT\n" " " "\n\n" @@ -930,6 +931,31 @@ int main(int argc, char* argv[]) case 'A': settings.allowed_fast_set_size = atoi(arg); break; case 'R': settings.read_cache_line_size = atoi(arg); break; case 'O': settings.allow_reordered_disk_operations = false; --i; break; + case 'P': + { + char* port = strchr(arg, ':'); + if (port == 0) + { + fprintf(stderr, "invalid proxy hostname, no port found\n"); + break; + } + *port++ = 0; + proxy_settings ps; + ps.hostname = arg; + ps.port = atoi(port); + if (ps.port == 0) { + fprintf(stderr, "invalid proxy port\n"); + break; + } + ps.type = proxy_settings::socks5; + ses.set_peer_proxy(ps); + ses.set_web_seed_proxy(ps); + ses.set_tracker_proxy(ps); +#ifndef TORRENT_DISABLE_DHT + ses.set_dht_proxy(ps); +#endif + } + break; } ++i; // skip the argument } diff --git a/include/libtorrent/proxy_base.hpp b/include/libtorrent/proxy_base.hpp index 298019cbd..8b35c85ef 100644 --- a/include/libtorrent/proxy_base.hpp +++ b/include/libtorrent/proxy_base.hpp @@ -165,8 +165,9 @@ public: } #endif - endpoint_type remote_endpoint(error_code& /*ec*/) const + endpoint_type remote_endpoint(error_code& ec) const { + if (!m_sock.is_open()) ec = asio::error::not_connected; return m_remote_endpoint; }