diff --git a/Jamfile b/Jamfile index 36275fa82..08965ca99 100755 --- a/Jamfile +++ b/Jamfile @@ -31,6 +31,9 @@ feature.compose logging : TORRENT_DHT_VERBOSE_LOGGING ; feature openssl : off on : composite propagated symmetric link-incompatible ; feature.compose on : TORRENT_USE_OPENSSL ; +feature resolve-countries : on off : composite propagated link-incompatible ; +feature.compose off : TORRENT_DISABLE_RESOLVE_COUNTRIES ; + feature character-set : ansi unicode : composite propagated link-incompatible ; feature.compose unicode : _UNICODE UNICODE ; diff --git a/include/libtorrent/peer_connection.hpp b/include/libtorrent/peer_connection.hpp index d513b955d..52eb47335 100755 --- a/include/libtorrent/peer_connection.hpp +++ b/include/libtorrent/peer_connection.hpp @@ -351,6 +351,7 @@ namespace libtorrent buffer::interval allocate_send_buffer(int size); void setup_send(); +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES void set_country(char const* c) { assert(strlen(c) == 2); @@ -358,6 +359,7 @@ namespace libtorrent m_country[1] = c[1]; } bool has_country() const { return m_country[0] != 0; } +#endif protected: @@ -447,11 +449,13 @@ namespace libtorrent extension_list_t m_extensions; #endif +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES // in case the session settings is set // to resolve countries, this is set to // the two character country code this // peer resides in. char m_country[2]; +#endif private: diff --git a/include/libtorrent/peer_info.hpp b/include/libtorrent/peer_info.hpp index f535c307c..86480ba11 100755 --- a/include/libtorrent/peer_info.hpp +++ b/include/libtorrent/peer_info.hpp @@ -82,12 +82,14 @@ namespace libtorrent bool seed; // true if this is a seed int upload_limit; int download_limit; - + +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES // in case the session settings is set // to resolve countries, this is set to // the two character country code this // peer resides in. char country[2]; +#endif size_type load_balancing; diff --git a/include/libtorrent/torrent.hpp b/include/libtorrent/torrent.hpp index 0dde2dcd9..d7e74ff19 100755 --- a/include/libtorrent/torrent.hpp +++ b/include/libtorrent/torrent.hpp @@ -207,10 +207,12 @@ namespace libtorrent float ratio() const { return m_ratio; } +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES void resolve_countries(bool r) { m_resolve_countries = r; } bool resolving_countries() const { return m_resolve_countries; } +#endif // -------------------------------------------- // BANDWIDTH MANAGEMENT @@ -585,15 +587,17 @@ namespace libtorrent // used to resolve the names of web seeds mutable tcp::resolver m_host_resolver; +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES // this is true while there is a country // resolution in progress. To avoid flodding - // the DNS request queue, only one ip is reolved + // the DNS request queue, only one ip is resolved // at a time. mutable bool m_resolving_country; // this is true if the user has enabled // country resolution in this torrent bool m_resolve_countries; +#endif // this announce timer is used both // by Local service discovery and diff --git a/include/libtorrent/torrent_handle.hpp b/include/libtorrent/torrent_handle.hpp index 86bccd94a..1edd06cf8 100755 --- a/include/libtorrent/torrent_handle.hpp +++ b/include/libtorrent/torrent_handle.hpp @@ -246,9 +246,11 @@ namespace libtorrent bool is_paused() const; void pause() const; void resume() const; - + +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES void resolve_countries(bool r); bool resolve_countries() const; +#endif // all these are deprecated, use piece // priority functions instead diff --git a/src/bt_peer_connection.cpp b/src/bt_peer_connection.cpp index f7f72c47a..877edf23b 100755 --- a/src/bt_peer_connection.cpp +++ b/src/bt_peer_connection.cpp @@ -190,8 +190,10 @@ namespace libtorrent p.pid = pid(); p.ip = remote(); +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES p.country[0] = m_country[0]; p.country[1] = m_country[1]; +#endif p.total_download = statistics().total_payload_download(); p.total_upload = statistics().total_payload_upload(); diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index f239a5fea..acb8b4896 100755 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -129,7 +129,9 @@ namespace libtorrent , m_in_constructor(true) #endif { +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES std::fill(m_country, m_country + 2, 0); +#endif #ifdef TORRENT_VERBOSE_LOGGING m_logger = m_ses.create_log(m_remote.address().to_string() + "_" + boost::lexical_cast(m_remote.port()), m_ses.listen_port()); @@ -195,7 +197,9 @@ namespace libtorrent , m_in_constructor(true) #endif { +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES std::fill(m_country, m_country + 2, 0); +#endif m_remote = m_socket->remote_endpoint(); #ifdef TORRENT_VERBOSE_LOGGING diff --git a/src/torrent.cpp b/src/torrent.cpp index 1d1738807..445b7cddc 100755 --- a/src/torrent.cpp +++ b/src/torrent.cpp @@ -202,8 +202,10 @@ namespace libtorrent , m_complete(-1) , m_incomplete(-1) , m_host_resolver(ses.m_io_service) +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES , m_resolving_country(false) , m_resolve_countries(false) +#endif , m_announce_timer(ses.m_io_service) , m_policy() , m_ses(ses) @@ -283,8 +285,10 @@ namespace libtorrent , m_complete(-1) , m_incomplete(-1) , m_host_resolver(ses.m_io_service) +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES , m_resolving_country(false) , m_resolve_countries(false) +#endif , m_announce_timer(ses.m_io_service) , m_policy() , m_ses(ses) @@ -1563,6 +1567,7 @@ namespace libtorrent assert(false); }; +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES void torrent::resolve_peer_country(boost::intrusive_ptr const& p) const { if (m_resolving_country @@ -1876,6 +1881,7 @@ namespace libtorrent p->set_country(i->second); } } +#endif peer_connection* torrent::connect_to_peer(policy::peer* peerinfo) { diff --git a/src/torrent_handle.cpp b/src/torrent_handle.cpp index c7584f87e..dfdccf86e 100755 --- a/src/torrent_handle.cpp +++ b/src/torrent_handle.cpp @@ -696,6 +696,7 @@ namespace libtorrent , bind(&torrent::set_ratio, _1, ratio)); } +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES void torrent_handle::resolve_countries(bool r) { INVARIANT_CHECK; @@ -709,6 +710,7 @@ namespace libtorrent return call_member(m_ses, m_chk, m_info_hash , bind(&torrent::resolving_countries, _1)); } +#endif void torrent_handle::get_peer_info(std::vector& v) const { @@ -735,8 +737,10 @@ namespace libtorrent peer_info& p = v.back(); peer->get_peer_info(p); +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES if (t->resolving_countries()) t->resolve_peer_country(intrusive_ptr(peer)); +#endif } } diff --git a/src/web_peer_connection.cpp b/src/web_peer_connection.cpp index 32fe029ce..382f044a1 100755 --- a/src/web_peer_connection.cpp +++ b/src/web_peer_connection.cpp @@ -539,9 +539,11 @@ namespace libtorrent p.payload_up_speed = statistics().upload_payload_rate(); p.pid = pid(); p.ip = remote(); - + +#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES p.country[0] = m_country[0]; p.country[1] = m_country[1]; +#endif p.total_download = statistics().total_payload_download(); p.total_upload = statistics().total_payload_upload();