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 openssl : off on : composite propagated symmetric link-incompatible ;
|
||||||
feature.compose <openssl>on : <define>TORRENT_USE_OPENSSL ;
|
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 character-set : ansi unicode : composite propagated link-incompatible ;
|
||||||
feature.compose <character-set>unicode : <define>_UNICODE <define>UNICODE ;
|
feature.compose <character-set>unicode : <define>_UNICODE <define>UNICODE ;
|
||||||
|
|
||||||
|
|
|
@ -351,6 +351,7 @@ namespace libtorrent
|
||||||
buffer::interval allocate_send_buffer(int size);
|
buffer::interval allocate_send_buffer(int size);
|
||||||
void setup_send();
|
void setup_send();
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
void set_country(char const* c)
|
void set_country(char const* c)
|
||||||
{
|
{
|
||||||
assert(strlen(c) == 2);
|
assert(strlen(c) == 2);
|
||||||
|
@ -358,6 +359,7 @@ namespace libtorrent
|
||||||
m_country[1] = c[1];
|
m_country[1] = c[1];
|
||||||
}
|
}
|
||||||
bool has_country() const { return m_country[0] != 0; }
|
bool has_country() const { return m_country[0] != 0; }
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -447,11 +449,13 @@ namespace libtorrent
|
||||||
extension_list_t m_extensions;
|
extension_list_t m_extensions;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
// in case the session settings is set
|
// in case the session settings is set
|
||||||
// to resolve countries, this is set to
|
// to resolve countries, this is set to
|
||||||
// the two character country code this
|
// the two character country code this
|
||||||
// peer resides in.
|
// peer resides in.
|
||||||
char m_country[2];
|
char m_country[2];
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
|
@ -82,12 +82,14 @@ namespace libtorrent
|
||||||
bool seed; // true if this is a seed
|
bool seed; // true if this is a seed
|
||||||
int upload_limit;
|
int upload_limit;
|
||||||
int download_limit;
|
int download_limit;
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
// in case the session settings is set
|
// in case the session settings is set
|
||||||
// to resolve countries, this is set to
|
// to resolve countries, this is set to
|
||||||
// the two character country code this
|
// the two character country code this
|
||||||
// peer resides in.
|
// peer resides in.
|
||||||
char country[2];
|
char country[2];
|
||||||
|
#endif
|
||||||
|
|
||||||
size_type load_balancing;
|
size_type load_balancing;
|
||||||
|
|
||||||
|
|
|
@ -207,10 +207,12 @@ namespace libtorrent
|
||||||
float ratio() const
|
float ratio() const
|
||||||
{ return m_ratio; }
|
{ return m_ratio; }
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
void resolve_countries(bool r)
|
void resolve_countries(bool r)
|
||||||
{ m_resolve_countries = r; }
|
{ m_resolve_countries = r; }
|
||||||
|
|
||||||
bool resolving_countries() const { return m_resolve_countries; }
|
bool resolving_countries() const { return m_resolve_countries; }
|
||||||
|
#endif
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
// BANDWIDTH MANAGEMENT
|
// BANDWIDTH MANAGEMENT
|
||||||
|
@ -585,15 +587,17 @@ namespace libtorrent
|
||||||
// used to resolve the names of web seeds
|
// used to resolve the names of web seeds
|
||||||
mutable tcp::resolver m_host_resolver;
|
mutable tcp::resolver m_host_resolver;
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
// this is true while there is a country
|
// this is true while there is a country
|
||||||
// resolution in progress. To avoid flodding
|
// 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.
|
// at a time.
|
||||||
mutable bool m_resolving_country;
|
mutable bool m_resolving_country;
|
||||||
|
|
||||||
// this is true if the user has enabled
|
// this is true if the user has enabled
|
||||||
// country resolution in this torrent
|
// country resolution in this torrent
|
||||||
bool m_resolve_countries;
|
bool m_resolve_countries;
|
||||||
|
#endif
|
||||||
|
|
||||||
// this announce timer is used both
|
// this announce timer is used both
|
||||||
// by Local service discovery and
|
// by Local service discovery and
|
||||||
|
|
|
@ -246,9 +246,11 @@ namespace libtorrent
|
||||||
bool is_paused() const;
|
bool is_paused() const;
|
||||||
void pause() const;
|
void pause() const;
|
||||||
void resume() const;
|
void resume() const;
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
void resolve_countries(bool r);
|
void resolve_countries(bool r);
|
||||||
bool resolve_countries() const;
|
bool resolve_countries() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
// all these are deprecated, use piece
|
// all these are deprecated, use piece
|
||||||
// priority functions instead
|
// priority functions instead
|
||||||
|
|
|
@ -190,8 +190,10 @@ namespace libtorrent
|
||||||
p.pid = pid();
|
p.pid = pid();
|
||||||
p.ip = remote();
|
p.ip = remote();
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
p.country[0] = m_country[0];
|
p.country[0] = m_country[0];
|
||||||
p.country[1] = m_country[1];
|
p.country[1] = m_country[1];
|
||||||
|
#endif
|
||||||
|
|
||||||
p.total_download = statistics().total_payload_download();
|
p.total_download = statistics().total_payload_download();
|
||||||
p.total_upload = statistics().total_payload_upload();
|
p.total_upload = statistics().total_payload_upload();
|
||||||
|
|
|
@ -129,7 +129,9 @@ namespace libtorrent
|
||||||
, m_in_constructor(true)
|
, m_in_constructor(true)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
std::fill(m_country, m_country + 2, 0);
|
std::fill(m_country, m_country + 2, 0);
|
||||||
|
#endif
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
m_logger = m_ses.create_log(m_remote.address().to_string() + "_"
|
m_logger = m_ses.create_log(m_remote.address().to_string() + "_"
|
||||||
+ boost::lexical_cast<std::string>(m_remote.port()), m_ses.listen_port());
|
+ boost::lexical_cast<std::string>(m_remote.port()), m_ses.listen_port());
|
||||||
|
@ -195,7 +197,9 @@ namespace libtorrent
|
||||||
, m_in_constructor(true)
|
, m_in_constructor(true)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
std::fill(m_country, m_country + 2, 0);
|
std::fill(m_country, m_country + 2, 0);
|
||||||
|
#endif
|
||||||
m_remote = m_socket->remote_endpoint();
|
m_remote = m_socket->remote_endpoint();
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_VERBOSE_LOGGING
|
||||||
|
|
|
@ -202,8 +202,10 @@ namespace libtorrent
|
||||||
, m_complete(-1)
|
, m_complete(-1)
|
||||||
, m_incomplete(-1)
|
, m_incomplete(-1)
|
||||||
, m_host_resolver(ses.m_io_service)
|
, m_host_resolver(ses.m_io_service)
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
, m_resolving_country(false)
|
, m_resolving_country(false)
|
||||||
, m_resolve_countries(false)
|
, m_resolve_countries(false)
|
||||||
|
#endif
|
||||||
, m_announce_timer(ses.m_io_service)
|
, m_announce_timer(ses.m_io_service)
|
||||||
, m_policy()
|
, m_policy()
|
||||||
, m_ses(ses)
|
, m_ses(ses)
|
||||||
|
@ -283,8 +285,10 @@ namespace libtorrent
|
||||||
, m_complete(-1)
|
, m_complete(-1)
|
||||||
, m_incomplete(-1)
|
, m_incomplete(-1)
|
||||||
, m_host_resolver(ses.m_io_service)
|
, m_host_resolver(ses.m_io_service)
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
, m_resolving_country(false)
|
, m_resolving_country(false)
|
||||||
, m_resolve_countries(false)
|
, m_resolve_countries(false)
|
||||||
|
#endif
|
||||||
, m_announce_timer(ses.m_io_service)
|
, m_announce_timer(ses.m_io_service)
|
||||||
, m_policy()
|
, m_policy()
|
||||||
, m_ses(ses)
|
, m_ses(ses)
|
||||||
|
@ -1563,6 +1567,7 @@ namespace libtorrent
|
||||||
assert(false);
|
assert(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
void torrent::resolve_peer_country(boost::intrusive_ptr<peer_connection> const& p) const
|
void torrent::resolve_peer_country(boost::intrusive_ptr<peer_connection> const& p) const
|
||||||
{
|
{
|
||||||
if (m_resolving_country
|
if (m_resolving_country
|
||||||
|
@ -1876,6 +1881,7 @@ namespace libtorrent
|
||||||
p->set_country(i->second);
|
p->set_country(i->second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
peer_connection* torrent::connect_to_peer(policy::peer* peerinfo)
|
peer_connection* torrent::connect_to_peer(policy::peer* peerinfo)
|
||||||
{
|
{
|
||||||
|
|
|
@ -696,6 +696,7 @@ namespace libtorrent
|
||||||
, bind(&torrent::set_ratio, _1, ratio));
|
, bind(&torrent::set_ratio, _1, ratio));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
void torrent_handle::resolve_countries(bool r)
|
void torrent_handle::resolve_countries(bool r)
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
@ -709,6 +710,7 @@ namespace libtorrent
|
||||||
return call_member<bool>(m_ses, m_chk, m_info_hash
|
return call_member<bool>(m_ses, m_chk, m_info_hash
|
||||||
, bind(&torrent::resolving_countries, _1));
|
, bind(&torrent::resolving_countries, _1));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void torrent_handle::get_peer_info(std::vector<peer_info>& v) const
|
void torrent_handle::get_peer_info(std::vector<peer_info>& v) const
|
||||||
{
|
{
|
||||||
|
@ -735,8 +737,10 @@ namespace libtorrent
|
||||||
peer_info& p = v.back();
|
peer_info& p = v.back();
|
||||||
|
|
||||||
peer->get_peer_info(p);
|
peer->get_peer_info(p);
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
if (t->resolving_countries())
|
if (t->resolving_countries())
|
||||||
t->resolve_peer_country(intrusive_ptr<peer_connection>(peer));
|
t->resolve_peer_country(intrusive_ptr<peer_connection>(peer));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -539,9 +539,11 @@ namespace libtorrent
|
||||||
p.payload_up_speed = statistics().upload_payload_rate();
|
p.payload_up_speed = statistics().upload_payload_rate();
|
||||||
p.pid = pid();
|
p.pid = pid();
|
||||||
p.ip = remote();
|
p.ip = remote();
|
||||||
|
|
||||||
|
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
||||||
p.country[0] = m_country[0];
|
p.country[0] = m_country[0];
|
||||||
p.country[1] = m_country[1];
|
p.country[1] = m_country[1];
|
||||||
|
#endif
|
||||||
|
|
||||||
p.total_download = statistics().total_payload_download();
|
p.total_download = statistics().total_payload_download();
|
||||||
p.total_upload = statistics().total_payload_upload();
|
p.total_upload = statistics().total_payload_upload();
|
||||||
|
|
Loading…
Reference in New Issue