remove resolve-country feature (#656)
This commit is contained in:
parent
5f5aa2361e
commit
10ec0234a7
|
@ -162,7 +162,6 @@ option(tcmalloc "link against google performance tools tcmalloc" OFF)
|
||||||
option(pool-allocators "Uses a pool allocator for disk and piece buffers" ON)
|
option(pool-allocators "Uses a pool allocator for disk and piece buffers" ON)
|
||||||
option(encryption "link against openssl and enable encryption" ON)
|
option(encryption "link against openssl and enable encryption" ON)
|
||||||
option(dht "enable support for Mainline DHT" ON)
|
option(dht "enable support for Mainline DHT" ON)
|
||||||
option(resolve-countries "enable support for resolving countries from peer IPs" ON)
|
|
||||||
option(unicode "enable unicode support" ON)
|
option(unicode "enable unicode support" ON)
|
||||||
option(deprecated-functions "enable deprecated functions for backwards compatibility" ON)
|
option(deprecated-functions "enable deprecated functions for backwards compatibility" ON)
|
||||||
option(exceptions "build with exception support" ON)
|
option(exceptions "build with exception support" ON)
|
||||||
|
@ -285,10 +284,6 @@ if (NOT pool-allocators)
|
||||||
add_definitions(-DTORRENT_DISABLE_POOL_ALLOCATOR)
|
add_definitions(-DTORRENT_DISABLE_POOL_ALLOCATOR)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT resolve-countries)
|
|
||||||
add_definitions(-DTORRENT_DISABLE_RESOLVE_COUNTRIES)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (unicode)
|
if (unicode)
|
||||||
add_definitions(-DUNICODE -D_UNICODE)
|
add_definitions(-DUNICODE -D_UNICODE)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
* removed feature to resolve country for peers
|
||||||
* added support for BEP 32, "IPv6 extension for DHT"
|
* added support for BEP 32, "IPv6 extension for DHT"
|
||||||
* overhauled listen socket and UDP socket handling, improving multi-home
|
* overhauled listen socket and UDP socket handling, improving multi-home
|
||||||
support and bind-to-device
|
support and bind-to-device
|
||||||
|
|
3
Jamfile
3
Jamfile
|
@ -476,9 +476,6 @@ feature crypto : built-in openssl gcrypt : composite propagated ;
|
||||||
feature.compose <crypto>openssl : <define>TORRENT_USE_OPENSSL ;
|
feature.compose <crypto>openssl : <define>TORRENT_USE_OPENSSL ;
|
||||||
feature.compose <crypto>gcrypt : <define>TORRENT_USE_GCRYPT ;
|
feature.compose <crypto>gcrypt : <define>TORRENT_USE_GCRYPT ;
|
||||||
|
|
||||||
feature resolve-countries : on off : composite propagated link-incompatible ;
|
|
||||||
feature.compose <resolve-countries>off : <define>TORRENT_DISABLE_RESOLVE_COUNTRIES ;
|
|
||||||
|
|
||||||
feature character-set : unicode ansi : composite propagated link-incompatible ;
|
feature character-set : unicode ansi : composite propagated link-incompatible ;
|
||||||
feature.compose <character-set>unicode : <define>_UNICODE <define>UNICODE ;
|
feature.compose <character-set>unicode : <define>_UNICODE <define>UNICODE ;
|
||||||
|
|
||||||
|
|
|
@ -25,15 +25,6 @@ boost::int64_t get_download_queue_time(peer_info const& pi)
|
||||||
return total_seconds(pi.download_queue_time);
|
return total_seconds(pi.download_queue_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
str get_country(peer_info const& pi)
|
|
||||||
{
|
|
||||||
return str(pi.country, 2);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
|
|
||||||
tuple get_local_endpoint(peer_info const& pi)
|
tuple get_local_endpoint(peer_info const& pi)
|
||||||
{
|
{
|
||||||
return boost::python::make_tuple(pi.local_endpoint.address().to_string(), pi.local_endpoint.port());
|
return boost::python::make_tuple(pi.local_endpoint.address().to_string(), pi.local_endpoint.port());
|
||||||
|
@ -87,11 +78,6 @@ void bind_peer_info()
|
||||||
.def_readonly("receive_buffer_size", &peer_info::receive_buffer_size)
|
.def_readonly("receive_buffer_size", &peer_info::receive_buffer_size)
|
||||||
.def_readonly("used_receive_buffer", &peer_info::used_receive_buffer)
|
.def_readonly("used_receive_buffer", &peer_info::used_receive_buffer)
|
||||||
.def_readonly("num_hashfails", &peer_info::num_hashfails)
|
.def_readonly("num_hashfails", &peer_info::num_hashfails)
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
.add_property("country", get_country)
|
|
||||||
#endif
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
.def_readonly("download_queue_length", &peer_info::download_queue_length)
|
.def_readonly("download_queue_length", &peer_info::download_queue_length)
|
||||||
.def_readonly("upload_queue_length", &peer_info::upload_queue_length)
|
.def_readonly("upload_queue_length", &peer_info::upload_queue_length)
|
||||||
.def_readonly("failcount", &peer_info::failcount)
|
.def_readonly("failcount", &peer_info::failcount)
|
||||||
|
|
|
@ -351,14 +351,6 @@ void bind_torrent_handle()
|
||||||
void (torrent_handle::*rename_file1)(int, std::wstring const&) const = &torrent_handle::rename_file;
|
void (torrent_handle::*rename_file1)(int, std::wstring const&) const = &torrent_handle::rename_file;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
// deprecated in 1.1
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
bool (torrent_handle::*resolve_countries0)() const = &torrent_handle::resolve_countries;
|
|
||||||
void (torrent_handle::*resolve_countries1)(bool) = &torrent_handle::resolve_countries;
|
|
||||||
#endif
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
|
|
||||||
#define _ allow_threads
|
#define _ allow_threads
|
||||||
|
|
||||||
class_<torrent_handle>("torrent_handle")
|
class_<torrent_handle>("torrent_handle")
|
||||||
|
@ -397,11 +389,6 @@ void bind_torrent_handle()
|
||||||
|
|
||||||
// deprecated
|
// deprecated
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// resolve countries deprecated in 1.1
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
.def("resolve_countries", _(resolve_countries0))
|
|
||||||
.def("resolve_countries", _(resolve_countries1))
|
|
||||||
#endif
|
|
||||||
.def("get_torrent_info", &get_torrent_info)
|
.def("get_torrent_info", &get_torrent_info)
|
||||||
.def("super_seeding", super_seeding0)
|
.def("super_seeding", super_seeding0)
|
||||||
.def("filter_piece", _(&torrent_handle::filter_piece))
|
.def("filter_piece", _(&torrent_handle::filter_piece))
|
||||||
|
|
|
@ -577,9 +577,6 @@ defines you can use to control the build.
|
||||||
| | use wide character API, to properly support |
|
| | use wide character API, to properly support |
|
||||||
| | non-ansi characters. |
|
| | non-ansi characters. |
|
||||||
+----------------------------------------+-------------------------------------------------+
|
+----------------------------------------+-------------------------------------------------+
|
||||||
| ``TORRENT_DISABLE_RESOLVE_COUNTRIES`` | Defining this will disable the ability to |
|
|
||||||
| | resolve countries of origin for peer IPs. |
|
|
||||||
+----------------------------------------+-------------------------------------------------+
|
|
||||||
| ``TORRENT_DISABLE_INVARIANT_CHECKS`` | This will disable internal invariant checks in |
|
| ``TORRENT_DISABLE_INVARIANT_CHECKS`` | This will disable internal invariant checks in |
|
||||||
| | libtorrent. The invariant checks can sometime |
|
| | libtorrent. The invariant checks can sometime |
|
||||||
| | be quite expensive, they typically don't scale |
|
| | be quite expensive, they typically don't scale |
|
||||||
|
|
|
@ -669,18 +669,6 @@ namespace libtorrent
|
||||||
, void* userdata = NULL, block_cache_reference ref
|
, void* userdata = NULL, block_cache_reference ref
|
||||||
= block_cache_reference());
|
= block_cache_reference());
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
void set_country(char const* c)
|
|
||||||
{
|
|
||||||
TORRENT_ASSERT(strlen(c) == 2);
|
|
||||||
m_country[0] = c[0];
|
|
||||||
m_country[1] = c[1];
|
|
||||||
}
|
|
||||||
bool has_country() const { return m_country[0] != 0; }
|
|
||||||
#endif
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
|
|
||||||
int outstanding_bytes() const { return m_outstanding_bytes; }
|
int outstanding_bytes() const { return m_outstanding_bytes; }
|
||||||
|
|
||||||
int send_buffer_size() const
|
int send_buffer_size() const
|
||||||
|
@ -1115,16 +1103,6 @@ namespace libtorrent
|
||||||
// TODO: 2 rename this target queue size
|
// TODO: 2 rename this target queue size
|
||||||
boost::uint16_t m_desired_queue_size;
|
boost::uint16_t m_desired_queue_size;
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
#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
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
|
|
||||||
// if set to non-zero, this peer will always prefer
|
// if set to non-zero, this peer will always prefer
|
||||||
// to request entire n pieces, rather than blocks.
|
// to request entire n pieces, rather than blocks.
|
||||||
// where n is the value of this variable.
|
// where n is the value of this variable.
|
||||||
|
|
|
@ -399,19 +399,6 @@ namespace libtorrent
|
||||||
char write_state;
|
char write_state;
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// country code deprecated in 1.1
|
|
||||||
|
|
||||||
// the two letter `ISO 3166 country code`__ for the country the peer is
|
|
||||||
// connected from. If the country hasn't been resolved yet, both chars
|
|
||||||
// are set to 0. If the resolution failed for some reason, the field is
|
|
||||||
// set to "--". If the resolution service returns an invalid country
|
|
||||||
// code, it is set to "!!". The ``countries.nerd.dk`` service is used to
|
|
||||||
// look up countries. This field will remain set to 0 unless the torrent
|
|
||||||
// is set to resolve countries, see `resolve_countries()`_.
|
|
||||||
//
|
|
||||||
// __ http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html
|
|
||||||
char country[2];
|
|
||||||
|
|
||||||
// the number of bytes per second we are allowed to send to or receive
|
// the number of bytes per second we are allowed to send to or receive
|
||||||
// from this peer. It may be -1 if there's no local limit on the peer.
|
// from this peer. It may be -1 if there's no local limit on the peer.
|
||||||
// The global limit and the torrent limit may also be enforced.
|
// The global limit and the torrent limit may also be enforced.
|
||||||
|
|
|
@ -559,20 +559,6 @@ namespace libtorrent
|
||||||
state_updated();
|
state_updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
// deprecated in 1.1
|
|
||||||
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
void resolve_countries(bool r);
|
|
||||||
bool resolving_countries() const;
|
|
||||||
|
|
||||||
void resolve_peer_country(boost::shared_ptr<peer_connection> const& p) const;
|
|
||||||
void on_country_lookup(error_code const& error
|
|
||||||
, std::vector<address> const& host_list
|
|
||||||
, boost::shared_ptr<peer_connection> p) const;
|
|
||||||
#endif
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
|
|
||||||
// --------------------------------------------
|
// --------------------------------------------
|
||||||
// BANDWIDTH MANAGEMENT
|
// BANDWIDTH MANAGEMENT
|
||||||
|
|
||||||
|
@ -1506,24 +1492,12 @@ namespace libtorrent
|
||||||
// from a non-downloading/seeding state, the torrent is paused.
|
// from a non-downloading/seeding state, the torrent is paused.
|
||||||
bool m_stop_when_ready:1;
|
bool m_stop_when_ready:1;
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
#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 resolved
|
|
||||||
// at a time.
|
|
||||||
mutable bool m_resolving_country:1;
|
|
||||||
|
|
||||||
// this is true if the user has enabled
|
|
||||||
// country resolution in this torrent
|
|
||||||
bool m_resolve_countries:1;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// set to false when saving resume data. Set to true
|
// set to false when saving resume data. Set to true
|
||||||
// whenever something is downloaded
|
// whenever something is downloaded
|
||||||
bool m_need_save_resume_data:1;
|
bool m_need_save_resume_data:1;
|
||||||
|
|
||||||
|
// 2 bits here
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
// total time we've been available as a seed on this torrent.
|
// total time we've been available as a seed on this torrent.
|
||||||
|
|
|
@ -236,7 +236,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
// TODO: 3 consider replacing all the setters and getters for pause,
|
// TODO: 3 consider replacing all the setters and getters for pause,
|
||||||
// resume, stop-when-ready, share-mode, upload-mode, super-seeding,
|
// resume, stop-when-ready, share-mode, upload-mode, super-seeding,
|
||||||
// apply-ip-filter, resolve-countries, pinned, sequential-download,
|
// apply-ip-filter, pinned, sequential-download,
|
||||||
// seed-mode
|
// seed-mode
|
||||||
// with just set_flags() and clear_flags() using the flags from
|
// with just set_flags() and clear_flags() using the flags from
|
||||||
// add_torrent_params. Perhaps those flags should have a more generic
|
// add_torrent_params. Perhaps those flags should have a more generic
|
||||||
|
@ -832,20 +832,6 @@ namespace libtorrent
|
||||||
void queue_position_top() const;
|
void queue_position_top() const;
|
||||||
void queue_position_bottom() const;
|
void queue_position_bottom() const;
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
// deprecated in 1.1
|
|
||||||
|
|
||||||
// Sets or gets the flag that determines if countries should be resolved
|
|
||||||
// for the peers of this torrent. It defaults to false. If it is set to
|
|
||||||
// true, the peer_info structure for the peers in this torrent will have
|
|
||||||
// their ``country`` member set. See peer_info for more information on
|
|
||||||
// how to interpret this field.
|
|
||||||
TORRENT_DEPRECATED
|
|
||||||
void resolve_countries(bool r);
|
|
||||||
TORRENT_DEPRECATED
|
|
||||||
bool resolve_countries() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// For SSL torrents, use this to specify a path to a .pem file to use as
|
// For SSL torrents, use this to specify a path to a .pem file to use as
|
||||||
// this client's certificate. The certificate must be signed by the
|
// this client's certificate. The certificate must be signed by the
|
||||||
// certificate in the .torrent file to be valid.
|
// certificate in the .torrent file to be valid.
|
||||||
|
|
|
@ -218,11 +218,6 @@ namespace libtorrent
|
||||||
m_quota[1] = 0;
|
m_quota[1] = 0;
|
||||||
|
|
||||||
TORRENT_ASSERT(pack.peerinfo == 0 || pack.peerinfo->banned == false);
|
TORRENT_ASSERT(pack.peerinfo == 0 || pack.peerinfo->banned == false);
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
std::fill(m_country, m_country + 2, 0);
|
|
||||||
#endif
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
#ifndef TORRENT_DISABLE_LOGGING
|
||||||
error_code ec;
|
error_code ec;
|
||||||
TORRENT_ASSERT(m_socket->remote_endpoint(ec) == m_remote || ec);
|
TORRENT_ASSERT(m_socket->remote_endpoint(ec) == m_remote || ec);
|
||||||
|
@ -4411,15 +4406,6 @@ namespace libtorrent
|
||||||
p.download_queue_time = download_queue_time();
|
p.download_queue_time = download_queue_time();
|
||||||
p.queue_bytes = m_outstanding_bytes;
|
p.queue_bytes = m_outstanding_bytes;
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
p.country[0] = m_country[0];
|
|
||||||
p.country[1] = m_country[1];
|
|
||||||
#else
|
|
||||||
std::fill(p.country, p.country + 2, 0);
|
|
||||||
#endif
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
|
|
||||||
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();
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
|
|
173
src/torrent.cpp
173
src/torrent.cpp
|
@ -241,12 +241,6 @@ namespace libtorrent
|
||||||
, m_seed_mode(false)
|
, m_seed_mode(false)
|
||||||
, m_super_seeding(false)
|
, m_super_seeding(false)
|
||||||
, m_stop_when_ready((p.flags & add_torrent_params::flag_stop_when_ready) != 0)
|
, m_stop_when_ready((p.flags & add_torrent_params::flag_stop_when_ready) != 0)
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
, m_resolving_country(false)
|
|
||||||
, m_resolve_countries(false)
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
, m_need_save_resume_data((p.flags & add_torrent_params::flag_need_save_resume) != 0)
|
, m_need_save_resume_data((p.flags & add_torrent_params::flag_need_save_resume) != 0)
|
||||||
, m_seeding_time(0)
|
, m_seeding_time(0)
|
||||||
, m_max_uploads((1<<24)-1)
|
, m_max_uploads((1<<24)-1)
|
||||||
|
@ -6453,166 +6447,6 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
// deprecated in 1.1
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
unsigned long swap_bytes(unsigned long a)
|
|
||||||
{
|
|
||||||
return (a >> 24) | ((a & 0xff0000) >> 8) | ((a & 0xff00) << 8) | ((a & 0xff) << 24);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void torrent::resolve_countries(bool r)
|
|
||||||
{ m_resolve_countries = r; }
|
|
||||||
|
|
||||||
bool torrent::resolving_countries() const
|
|
||||||
{
|
|
||||||
return m_resolve_countries && !settings().get_bool(settings_pack::force_proxy);
|
|
||||||
}
|
|
||||||
|
|
||||||
void torrent::resolve_peer_country(boost::shared_ptr<peer_connection> const& p) const
|
|
||||||
{
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
|
||||||
if (m_resolving_country
|
|
||||||
|| is_local(p->remote().address())
|
|
||||||
|| p->has_country()
|
|
||||||
|| p->is_connecting()
|
|
||||||
|| p->in_handshake()
|
|
||||||
|| p->remote().address().is_v6()) return;
|
|
||||||
|
|
||||||
boost::asio::ip::address_v4 reversed(swap_bytes(p->remote().address().to_v4().to_ulong()));
|
|
||||||
error_code ec;
|
|
||||||
std::string hostname = reversed.to_string(ec) + ".zz.countries.nerd.dk";
|
|
||||||
if (ec)
|
|
||||||
{
|
|
||||||
p->set_country("!!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_resolving_country = true;
|
|
||||||
m_ses.async_resolve(hostname, resolver_interface::abort_on_shutdown
|
|
||||||
, boost::bind(&torrent::on_country_lookup, shared_from_this(), _1, _2, p));
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
struct country_entry
|
|
||||||
{
|
|
||||||
int code;
|
|
||||||
char const* name;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void torrent::on_country_lookup(error_code const& error
|
|
||||||
, std::vector<address> const& host_list
|
|
||||||
, boost::shared_ptr<peer_connection> p) const
|
|
||||||
{
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
|
||||||
|
|
||||||
m_resolving_country = false;
|
|
||||||
|
|
||||||
if (m_abort) return;
|
|
||||||
|
|
||||||
// must be ordered in increasing order
|
|
||||||
static const country_entry country_map[] =
|
|
||||||
{
|
|
||||||
{ 4, "AF"}, { 8, "AL"}, { 10, "AQ"}, { 12, "DZ"}, { 16, "AS"}
|
|
||||||
, { 20, "AD"}, { 24, "AO"}, { 28, "AG"}, { 31, "AZ"}, { 32, "AR"}
|
|
||||||
, { 36, "AU"}, { 40, "AT"}, { 44, "BS"}, { 48, "BH"}, { 50, "BD"}
|
|
||||||
, { 51, "AM"}, { 52, "BB"}, { 56, "BE"}, { 60, "BM"}, { 64, "BT"}
|
|
||||||
, { 68, "BO"}, { 70, "BA"}, { 72, "BW"}, { 74, "BV"}, { 76, "BR"}
|
|
||||||
, { 84, "BZ"}, { 86, "IO"}, { 90, "SB"}, { 92, "VG"}, { 96, "BN"}
|
|
||||||
, {100, "BG"}, {104, "MM"}, {108, "BI"}, {112, "BY"}, {116, "KH"}
|
|
||||||
, {120, "CM"}, {124, "CA"}, {132, "CV"}, {136, "KY"}, {140, "CF"}
|
|
||||||
, {144, "LK"}, {148, "TD"}, {152, "CL"}, {156, "CN"}, {158, "TW"}
|
|
||||||
, {162, "CX"}, {166, "CC"}, {170, "CO"}, {174, "KM"}, {175, "YT"}
|
|
||||||
, {178, "CG"}, {180, "CD"}, {184, "CK"}, {188, "CR"}, {191, "HR"}
|
|
||||||
, {192, "CU"}, {203, "CZ"}, {204, "BJ"}, {208, "DK"}, {212, "DM"}
|
|
||||||
, {214, "DO"}, {218, "EC"}, {222, "SV"}, {226, "GQ"}, {231, "ET"}
|
|
||||||
, {232, "ER"}, {233, "EE"}, {234, "FO"}, {238, "FK"}, {239, "GS"}
|
|
||||||
, {242, "FJ"}, {246, "FI"}, {248, "AX"}, {250, "FR"}, {254, "GF"}
|
|
||||||
, {258, "PF"}, {260, "TF"}, {262, "DJ"}, {266, "GA"}, {268, "GE"}
|
|
||||||
, {270, "GM"}, {275, "PS"}, {276, "DE"}, {288, "GH"}, {292, "GI"}
|
|
||||||
, {296, "KI"}, {300, "GR"}, {304, "GL"}, {308, "GD"}, {312, "GP"}
|
|
||||||
, {316, "GU"}, {320, "GT"}, {324, "GN"}, {328, "GY"}, {332, "HT"}
|
|
||||||
, {334, "HM"}, {336, "VA"}, {340, "HN"}, {344, "HK"}, {348, "HU"}
|
|
||||||
, {352, "IS"}, {356, "IN"}, {360, "ID"}, {364, "IR"}, {368, "IQ"}
|
|
||||||
, {372, "IE"}, {376, "IL"}, {380, "IT"}, {384, "CI"}, {388, "JM"}
|
|
||||||
, {392, "JP"}, {398, "KZ"}, {400, "JO"}, {404, "KE"}, {408, "KP"}
|
|
||||||
, {410, "KR"}, {414, "KW"}, {417, "KG"}, {418, "LA"}, {422, "LB"}
|
|
||||||
, {426, "LS"}, {428, "LV"}, {430, "LR"}, {434, "LY"}, {438, "LI"}
|
|
||||||
, {440, "LT"}, {442, "LU"}, {446, "MO"}, {450, "MG"}, {454, "MW"}
|
|
||||||
, {458, "MY"}, {462, "MV"}, {466, "ML"}, {470, "MT"}, {474, "MQ"}
|
|
||||||
, {478, "MR"}, {480, "MU"}, {484, "MX"}, {492, "MC"}, {496, "MN"}
|
|
||||||
, {498, "MD"}, {500, "MS"}, {504, "MA"}, {508, "MZ"}, {512, "OM"}
|
|
||||||
, {516, "NA"}, {520, "NR"}, {524, "NP"}, {528, "NL"}, {530, "AN"}
|
|
||||||
, {533, "AW"}, {540, "NC"}, {548, "VU"}, {554, "NZ"}, {558, "NI"}
|
|
||||||
, {562, "NE"}, {566, "NG"}, {570, "NU"}, {574, "NF"}, {578, "NO"}
|
|
||||||
, {580, "MP"}, {581, "UM"}, {583, "FM"}, {584, "MH"}, {585, "PW"}
|
|
||||||
, {586, "PK"}, {591, "PA"}, {598, "PG"}, {600, "PY"}, {604, "PE"}
|
|
||||||
, {608, "PH"}, {612, "PN"}, {616, "PL"}, {620, "PT"}, {624, "GW"}
|
|
||||||
, {626, "TL"}, {630, "PR"}, {634, "QA"}, {634, "QA"}, {638, "RE"}
|
|
||||||
, {642, "RO"}, {643, "RU"}, {646, "RW"}, {654, "SH"}, {659, "KN"}
|
|
||||||
, {660, "AI"}, {662, "LC"}, {666, "PM"}, {670, "VC"}, {674, "SM"}
|
|
||||||
, {678, "ST"}, {682, "SA"}, {686, "SN"}, {690, "SC"}, {694, "SL"}
|
|
||||||
, {702, "SG"}, {703, "SK"}, {704, "VN"}, {705, "SI"}, {706, "SO"}
|
|
||||||
, {710, "ZA"}, {716, "ZW"}, {724, "ES"}, {732, "EH"}, {736, "SD"}
|
|
||||||
, {740, "SR"}, {744, "SJ"}, {748, "SZ"}, {752, "SE"}, {756, "CH"}
|
|
||||||
, {760, "SY"}, {762, "TJ"}, {764, "TH"}, {768, "TG"}, {772, "TK"}
|
|
||||||
, {776, "TO"}, {780, "TT"}, {784, "AE"}, {788, "TN"}, {792, "TR"}
|
|
||||||
, {795, "TM"}, {796, "TC"}, {798, "TV"}, {800, "UG"}, {804, "UA"}
|
|
||||||
, {807, "MK"}, {818, "EG"}, {826, "GB"}, {834, "TZ"}, {840, "US"}
|
|
||||||
, {850, "VI"}, {854, "BF"}, {858, "UY"}, {860, "UZ"}, {862, "VE"}
|
|
||||||
, {876, "WF"}, {882, "WS"}, {887, "YE"}, {891, "CS"}, {894, "ZM"}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (error || host_list.empty())
|
|
||||||
{
|
|
||||||
// this is used to indicate that we shouldn't
|
|
||||||
// try to resolve it again
|
|
||||||
p->set_country("--");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int idx = 0;
|
|
||||||
while (idx < host_list.size() && !host_list[idx].is_v4())
|
|
||||||
++idx;
|
|
||||||
|
|
||||||
if (idx >= host_list.size())
|
|
||||||
{
|
|
||||||
p->set_country("--");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// country is an ISO 3166 country code
|
|
||||||
int country = host_list[idx].to_v4().to_ulong() & 0xffff;
|
|
||||||
|
|
||||||
// look up the country code in the map
|
|
||||||
const int size = sizeof(country_map)/sizeof(country_map[0]);
|
|
||||||
country_entry tmp = {country, ""};
|
|
||||||
country_entry const* j =
|
|
||||||
std::lower_bound(country_map, country_map + size, tmp
|
|
||||||
, boost::bind(&country_entry::code, _1) < boost::bind(&country_entry::code, _2));
|
|
||||||
if (j == country_map + size
|
|
||||||
|| j->code != country)
|
|
||||||
{
|
|
||||||
// unknown country!
|
|
||||||
p->set_country("!!");
|
|
||||||
#ifndef TORRENT_DISABLE_LOGGING
|
|
||||||
debug_log("IP \"%s\" was mapped to unknown country: %d"
|
|
||||||
, print_address(p->remote().address()).c_str(), country);
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
p->set_country(j->name);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
|
|
||||||
boost::shared_ptr<const torrent_info> torrent::get_torrent_copy()
|
boost::shared_ptr<const torrent_info> torrent::get_torrent_copy()
|
||||||
{
|
{
|
||||||
if (!m_torrent_file->is_valid()) return boost::shared_ptr<const torrent_info>();
|
if (!m_torrent_file->is_valid()) return boost::shared_ptr<const torrent_info>();
|
||||||
|
@ -7007,13 +6841,6 @@ namespace libtorrent
|
||||||
peer_info& p = v->back();
|
peer_info& p = v->back();
|
||||||
|
|
||||||
peer->get_peer_info(p);
|
peer->get_peer_info(p);
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
// deprecated in 1.1
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
if (resolving_countries())
|
|
||||||
resolve_peer_country(peer->self());
|
|
||||||
#endif
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -730,25 +730,6 @@ namespace libtorrent
|
||||||
TORRENT_ASYNC_CALL1(super_seeding, on);
|
TORRENT_ASYNC_CALL1(super_seeding, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
|
||||||
void torrent_handle::resolve_countries(bool r)
|
|
||||||
{
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
TORRENT_ASYNC_CALL1(resolve_countries, r);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool torrent_handle::resolve_countries() const
|
|
||||||
{
|
|
||||||
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
|
|
||||||
TORRENT_SYNC_CALL_RET(bool, false, resolving_countries);
|
|
||||||
return r;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif // TORRENT_NO_DEPRECATE
|
|
||||||
|
|
||||||
void torrent_handle::get_full_peer_list(std::vector<peer_list_entry>& v) const
|
void torrent_handle::get_full_peer_list(std::vector<peer_list_entry>& v) const
|
||||||
{
|
{
|
||||||
TORRENT_SYNC_CALL1(get_full_peer_list, &v);
|
TORRENT_SYNC_CALL1(get_full_peer_list, &v);
|
||||||
|
|
Loading…
Reference in New Issue