added option to disable country resolving
This commit is contained in:
parent
13bcb48dba
commit
54805ca60b
3
Jamfile
3
Jamfile
|
@ -31,6 +31,9 @@ feature.compose <dht-support>logging : <define>TORRENT_DHT_VERBOSE_LOGGING ;
|
|||
feature openssl : off on : composite propagated symmetric link-incompatible ;
|
||||
feature.compose <openssl>on : <define>TORRENT_USE_OPENSSL ;
|
||||
|
||||
feature resolve-countries : on off : composite propagated link-incompatible ;
|
||||
feature.compose <resolve-countries>off : <define>TORRENT_DISABLE_RESOLVE_COUNTRIES ;
|
||||
|
||||
feature character-set : ansi unicode : composite propagated link-incompatible ;
|
||||
feature.compose <character-set>unicode : <define>_UNICODE <define>UNICODE ;
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
||||
|
|
|
@ -83,11 +83,13 @@ namespace libtorrent
|
|||
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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -247,8 +247,10 @@ namespace libtorrent
|
|||
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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<std::string>(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
|
||||
|
|
|
@ -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<peer_connection> 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)
|
||||
{
|
||||
|
|
|
@ -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<bool>(m_ses, m_chk, m_info_hash
|
||||
, bind(&torrent::resolving_countries, _1));
|
||||
}
|
||||
#endif
|
||||
|
||||
void torrent_handle::get_peer_info(std::vector<peer_info>& 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_connection>(peer));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -540,8 +540,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();
|
||||
|
|
Loading…
Reference in New Issue