remove built-in GeoIP support

This commit is contained in:
Arvid Norberg 2014-09-21 21:01:48 +00:00
parent b707ea008b
commit 27b7705cf2
19 changed files with 23 additions and 584 deletions

View File

@ -141,7 +141,6 @@ option(static_runtime "build libtorrent with static runtime" OFF)
option(tcmalloc "link against google performance tools tcmalloc" OFF)
option(pool-allocators "Uses a pool allocator for disk and piece buffers" ON)
option(encryption "link against openssl and enable encryption" ON)
option(geoip "link against LGPL GeoIP code from Maxmind, to enable geoip database support" OFF)
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)
@ -263,10 +262,6 @@ if (NOT pool-allocators)
add_definitions(-DTORRENT_DISABLE_POOL_ALLOCATOR)
endif()
if (NOT geoip)
add_definitions(-DTORRENT_DISABLE_GEO_IP)
endif()
if (NOT resolve-countries)
add_definitions(-DTORRENT_DISABLE_RESOLVE_COUNTRIES)
endif()

View File

@ -1,3 +1,4 @@
* removed built-in GeoIP support (this functionality is orthogonal to libtorrent)
* deprecate proxy settings in favor of regular settings
* deprecate separate settings for peer protocol encryption
* support specifying listen interfaces and outgoing interfaces as device

13
Jamfile
View File

@ -102,11 +102,6 @@ rule linking ( properties * )
result += <library>gcrypt <include>/opt/local/include ;
}
if <geoip>shared in $(properties)
{
result += <library>GeoIP ;
}
# socket functions on windows require winsock libraries
if <target-os>windows in $(properties)
|| <target-os>cygwin in $(properties)
@ -263,11 +258,6 @@ rule building ( properties * )
result += <source>src/mpi.c ;
}
if <geoip>static in $(properties)
{
result += <source>src/GeoIP.c ;
}
if <encryption>off in $(properties)
|| <encryption>tommath in $(properties)
{
@ -390,9 +380,6 @@ feature piece-allocator : valloc memalign posix_memalign : composite propagated
feature.compose <piece-allocator>memalign : <define>TORRENT_USE_MEMALIGN=1 ;
feature.compose <piece-allocator>posix_memalign : <define>TORRENT_USE_POSIX_MEMALIGN=1 ;
feature geoip : off static shared : composite propagated link-incompatible ;
feature.compose <geoip>off : <define>TORRENT_DISABLE_GEO_IP ;
feature bandwidth-limit-logging : off on : composite propagated link-incompatible ;
feature.compose <bandwidth-limit-logging>on : <define>TORRENT_VERBOSE_BANDWIDTH_LIMIT ;

View File

@ -281,21 +281,6 @@ AC_ARG_ENABLE(
[[ARG_ENABLE_DISK_STATS=no]]
)
AC_ARG_ENABLE(
[geoip],
[AS_HELP_STRING(
[--enable-geoip],
[enable geoip support (if enabled, you can use --with-libgeoip to choose whether to link against shipped or system library) [default=yes]])],
[
ARG_ENABLE_GEOIP=$enableval
ac_arg_enable_geoip=$enableval
],
[
ARG_ENABLE_GEOIP=yes
ac_arg_enable_geoip=yes
]
)
AC_ARG_ENABLE(
[examples],
[AS_HELP_STRING(
@ -323,15 +308,6 @@ AC_ARG_ENABLE(
[[ARG_ENABLE_PYTHON_BINDING=no]]
)
AC_ARG_WITH(
[libgeoip],
[AS_HELP_STRING(
[--with-libgeoip],
[enable linking against system libgeoip [default=shipped]])],
[[ARG_WITH_LIBGEOIP=$withval]],
[[ARG_WITH_LIBGEOIP=no]]
)
AC_ARG_WITH(
[libiconv],
[AS_HELP_STRING(
@ -477,20 +453,6 @@ AS_CASE(["$ARG_ENABLE_ENCRYPTION"],
AC_MSG_ERROR([Unknown option "$ARG_ENABLE_ENCRYPTION". Use either "yes" or "no".])]
)
AC_MSG_CHECKING([whether geoip support should be enabled])
AS_CASE(["$ARG_ENABLE_GEOIP"],
["yes"], [
AC_MSG_RESULT([yes])
],
["no"], [
AC_MSG_RESULT([no])
AC_DEFINE([TORRENT_DISABLE_GEO_IP],[1],[Define to disable the GeoIP support and avoid linking against LGPLed code.])
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_DISABLE_GEO_IP "
],
[AC_MSG_RESULT([$ARG_ENABLE_GEOIP])
AC_MSG_ERROR([Unknown option "$ARG_ENABLE_GEOIP". Use either "yes" or "no".])]
)
AC_MSG_CHECKING([whether dht support should be enabled])
AS_CASE(["$ARG_ENABLE_DHT"],
["yes"|"on"], [
@ -564,41 +526,6 @@ AS_CASE(["$ARG_ENABLE_PYTHON_BINDING"],
AS_ECHO
AS_ECHO "Checking for external libraries:"
AC_MSG_CHECKING([whether to link against system libgeoip]) #depends: $ac_arg_enable_geoip
AS_CASE(["$ARG_WITH_LIBGEOIP"],
["yes"|"system"], [
AC_MSG_RESULT([yes])
AS_IF([test "x$ac_arg_enable_geoip" = "xno"],
[AC_MSG_ERROR([GeoIP support is disabled with this build configuration. Try using --enable-geoip.])])
AC_MSG_NOTICE([libgeoip: now checking for the libgeoip library...])
AC_CHECK_GEOIP([
LIBS="$GEOIP_LIBS $LIBS"
CFLAGS="$GEOIP_CFLAGS $CFLAGS"
],[
AC_MSG_ERROR([GeoIP library not found. Try using --without-libgeoip to link against the shipped copy.])
])
],
["no"|"shipped"], [
AS_IF([test "x$ac_arg_enable_geoip" = "xno"], [
# redundant check: session_impl.hpp just won't check for any
# GeoIP.h, so any value would be ok (ie. this AS_IF could be
# removed)
AC_MSG_RESULT([disabled])
ARG_WITH_LIBGEOIP="disabled"
], [
AC_MSG_RESULT([no])
ARG_WITH_LIBGEOIP="no"
AC_DEFINE([WITH_SHIPPED_GEOIP_H],[1],[Define to use shipped copy of GeoIP.h])
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DWITH_SHIPPED_GEOIP_H "
])
],
[AC_MSG_RESULT([$ARG_WITH_LIBGEOIP])
AC_MSG_ERROR([Unknown option "$ARG_WITH_LIBGEOIP". Use either "yes" or "no".])]
)
AC_MSG_CHECKING([whether to link against system libiconv])
AS_CASE(["$ARG_WITH_LIBICONV"],
["yes"], [
@ -628,7 +555,6 @@ AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$ARG_ENABLE_EXAMPLES" = "xyes"])
AM_CONDITIONAL([ENABLE_TESTS], [test "x$ARG_ENABLE_TESTS" = "xyes"])
AM_CONDITIONAL([ENABLE_PYTHON_BINDING], [test "x$ARG_ENABLE_PYTHON_BINDING" = "xyes"])
AM_CONDITIONAL([WITH_SHIPPED_GEOIP], [test "x$ARG_WITH_LIBGEOIP" = "xno" ])
AM_CONDITIONAL([WITH_OPENSSL], [test "x$ARG_ENABLE_ENCRYPTION" = "xyes" -o "x$ARG_ENABLE_ENCRYPTION" = "xon" ])
@ -738,7 +664,6 @@ Build options:
Features:
encryption support: ${ARG_ENABLE_ENCRYPTION:-yes}
geoip support: ${ARG_ENABLE_GEOIP:-yes}
dht support: ${ARG_ENABLE_DHT:-yes}
pool allocators: ${ARG_ENABLE_POOL_ALLOC:-yes}
@ -787,7 +712,6 @@ END
cat >> config.report << END
External libraries:
system libgeoip: ${ARG_WITH_LIBGEOIP:-no}
system libiconv: ${ARG_WITH_LIBICONV:-no}
END

View File

@ -273,14 +273,6 @@ Build features:
| | to ``asserts.log`` in the current working |
| | directory, but won't abort the process. |
+--------------------------+----------------------------------------------------+
| ``geoip`` | * ``off`` - geo ip lookups disabled |
| | * ``static`` - MaxMind_ geo ip lookup code linked |
| | in statically. Note that this code is under |
| | LGPL license. |
| | * ``shared`` - The MaxMind_ geo ip lookup library |
| | is expected to be installed on the system and |
| | it will be used. |
+--------------------------+----------------------------------------------------+
| ``upnp-logging`` | * ``off`` - default. Does not log UPnP traffic. |
| | * ``on`` - creates "upnp.log" with the messages |
| | sent to and received from UPnP devices. |
@ -568,10 +560,6 @@ defines you can use to control the build.
| | events, such as tracker announces and incoming |
| | connections (as well as blocked connections). |
+----------------------------------------+-------------------------------------------------+
| ``TORRENT_DISABLE_GEO_IP`` | This is defined by default by the Jamfile. It |
| | disables the GeoIP features, and avoids linking |
| | against LGPL:ed code. |
+----------------------------------------+-------------------------------------------------+
| ``TORRENT_VERBOSE_LOGGING`` | If you define this macro, every peer connection |
| | will log its traffic to a log file as well as |
| | the session log. |

View File

@ -1,179 +0,0 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
/* GeoIP.h
*
* Copyright (C) 2006 MaxMind LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef GEOIP_H
#define GEOIP_H
#ifdef __cplusplus
extern "C" {
#endif
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <sys/types.h> /* for fstat */
#define SEGMENT_RECORD_LENGTH 3
#define STANDARD_RECORD_LENGTH 3
#define ORG_RECORD_LENGTH 4
#define MAX_RECORD_LENGTH 4
#define NUM_DB_TYPES 20
typedef struct GeoIPTag {
FILE *GeoIPDatabase;
char *file_path;
unsigned char *cache;
unsigned char *index_cache;
unsigned int *databaseSegments;
char databaseType;
time_t mtime;
int flags;
off_t size;
char record_length;
int charset; /* 0 iso-8859-1 1 utf8 */
int record_iter; /* used in GeoIP_next_record */
int netmask; /* netmask of last lookup - set using depth in _GeoIP_seek_record */
} GeoIP;
typedef enum {
GEOIP_CHARSET_ISO_8859_1 = 0,
GEOIP_CHARSET_UTF8 = 1
} GeoIPCharset;
typedef struct GeoIPRegionTag {
char country_code[3];
char region[3];
} GeoIPRegion;
typedef enum {
GEOIP_STANDARD = 0,
GEOIP_MEMORY_CACHE = 1,
GEOIP_CHECK_CACHE = 2,
GEOIP_INDEX_CACHE = 4,
GEOIP_MMAP_CACHE = 8
} GeoIPOptions;
typedef enum {
GEOIP_COUNTRY_EDITION = 1,
GEOIP_REGION_EDITION_REV0 = 7,
GEOIP_CITY_EDITION_REV0 = 6,
GEOIP_ORG_EDITION = 5,
GEOIP_ISP_EDITION = 4,
GEOIP_CITY_EDITION_REV1 = 2,
GEOIP_REGION_EDITION_REV1 = 3,
GEOIP_PROXY_EDITION = 8,
GEOIP_ASNUM_EDITION = 9,
GEOIP_NETSPEED_EDITION = 10,
GEOIP_DOMAIN_EDITION = 11
} GeoIPDBTypes;
typedef enum {
GEOIP_ANON_PROXY = 1,
GEOIP_HTTP_X_FORWARDED_FOR_PROXY = 2,
GEOIP_HTTP_CLIENT_IP_PROXY = 3
} GeoIPProxyTypes;
typedef enum {
GEOIP_UNKNOWN_SPEED = 0,
GEOIP_DIALUP_SPEED = 1,
GEOIP_CABLEDSL_SPEED = 2,
GEOIP_CORPORATE_SPEED = 3
} GeoIPNetspeedValues;
extern char **GeoIPDBFileName;
extern const char * GeoIPDBDescription[NUM_DB_TYPES];
extern const char *GeoIPCountryDBFileName;
extern const char *GeoIPRegionDBFileName;
extern const char *GeoIPCityDBFileName;
extern const char *GeoIPOrgDBFileName;
extern const char *GeoIPISPDBFileName;
extern const char GeoIP_country_code[253][3];
extern const char GeoIP_country_code3[253][4];
extern const char * GeoIP_country_name[253];
extern const char GeoIP_country_continent[253][3];
#ifdef DLL
#define GEOIP_API __declspec(dllexport)
#else
#define GEOIP_API
#endif /* DLL */
GEOIP_API void GeoIP_setup_custom_directory(char *dir);
GEOIP_API GeoIP* GeoIP_open_type (int type, int flags);
GEOIP_API GeoIP* GeoIP_new(int flags);
GEOIP_API GeoIP* GeoIP_open(const char * filename, int flags);
GEOIP_API int GeoIP_db_avail(int type);
GEOIP_API void GeoIP_delete(GeoIP* gi);
GEOIP_API const char *GeoIP_country_code_by_addr (GeoIP* gi, const char *addr);
GEOIP_API const char *GeoIP_country_code_by_name (GeoIP* gi, const char *host);
GEOIP_API const char *GeoIP_country_code3_by_addr (GeoIP* gi, const char *addr);
GEOIP_API const char *GeoIP_country_code3_by_name (GeoIP* gi, const char *host);
GEOIP_API const char *GeoIP_country_name_by_addr (GeoIP* gi, const char *addr);
GEOIP_API const char *GeoIP_country_name_by_name (GeoIP* gi, const char *host);
GEOIP_API const char *GeoIP_country_name_by_ipnum (GeoIP* gi, unsigned long ipnum);
GEOIP_API const char *GeoIP_country_code_by_ipnum (GeoIP* gi, unsigned long ipnum);
GEOIP_API const char *GeoIP_country_code3_by_ipnum (GeoIP* gi, unsigned long ipnum);
/* Deprecated - for backwards compatibility only */
GEOIP_API int GeoIP_country_id_by_addr (GeoIP* gi, const char *addr);
GEOIP_API int GeoIP_country_id_by_name (GeoIP* gi, const char *host);
GEOIP_API char *GeoIP_org_by_addr (GeoIP* gi, const char *addr);
GEOIP_API char *GeoIP_org_by_name (GeoIP* gi, const char *host);
/* End deprecated */
GEOIP_API int GeoIP_id_by_addr (GeoIP* gi, const char *addr);
GEOIP_API int GeoIP_id_by_name (GeoIP* gi, const char *host);
GEOIP_API int GeoIP_id_by_ipnum (GeoIP* gi, unsigned long ipnum);
GEOIP_API GeoIPRegion * GeoIP_region_by_addr (GeoIP* gi, const char *addr);
GEOIP_API GeoIPRegion * GeoIP_region_by_name (GeoIP* gi, const char *host);
GEOIP_API GeoIPRegion * GeoIP_region_by_ipnum (GeoIP *gi, unsigned long ipnum);
/* Warning - don't call this after GeoIP_assign_region_by_inetaddr calls */
GEOIP_API void GeoIPRegion_delete (GeoIPRegion *gir);
GEOIP_API void GeoIP_assign_region_by_inetaddr(GeoIP* gi, unsigned long inetaddr, GeoIPRegion *gir);
/* Used to query GeoIP Organization, ISP and AS Number databases */
GEOIP_API char *GeoIP_name_by_ipnum (GeoIP* gi, unsigned long ipnum);
GEOIP_API char *GeoIP_name_by_addr (GeoIP* gi, const char *addr);
GEOIP_API char *GeoIP_name_by_name (GeoIP* gi, const char *host);
GEOIP_API char *GeoIP_database_info (GeoIP* gi);
GEOIP_API unsigned char GeoIP_database_edition (GeoIP* gi);
GEOIP_API int GeoIP_charset (GeoIP* gi);
GEOIP_API int GeoIP_set_charset (GeoIP* gi, int charset);
GEOIP_API int GeoIP_last_netmask (GeoIP* gi);
/* Convert region code to region name */
GEOIP_API const char * GeoIP_region_name_by_code(const char *country_code, const char *region_code);
/* Get timezone from country and region code */
GEOIP_API const char * GeoIP_time_zone_by_country_and_region(const char *country_code, const char *region_code);
#ifdef __cplusplus
}
#endif
#endif /* GEOIP_H */

View File

@ -1,9 +1,5 @@
includedir = @includedir@/libtorrent
if WITH_SHIPPED_GEOIP
GEOIP_H = GeoIP.h
endif
nobase_include_HEADERS = \
address.hpp \
add_torrent_params.hpp \

View File

@ -48,14 +48,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/torrent_peer_allocator.hpp"
#include "libtorrent/performance_counters.hpp" // for counters
#ifndef TORRENT_DISABLE_GEO_IP
#ifdef WITH_SHIPPED_GEOIP_H
#include "libtorrent/GeoIP.h"
#else
#include <GeoIP.h>
#endif
#endif
#ifdef _MSC_VER
#pragma warning(push, 1)
#endif
@ -555,25 +547,6 @@ namespace libtorrent
, error_code const& e);
#endif
#ifndef TORRENT_DISABLE_GEO_IP
std::string as_name_for_ip(address const& a);
int as_for_ip(address const& a);
std::pair<const int, int>* lookup_as(int as);
void load_asnum_db(std::string file);
bool has_asnum_db() const { return m_asnum_db; }
void load_country_db(std::string file);
bool has_country_db() const { return m_country_db; }
char const* country_for_ip(address const& a);
#if TORRENT_USE_WSTRING
#ifndef TORRENT_NO_DEPRECATE
void load_asnum_dbw(std::wstring file);
void load_country_dbw(std::wstring file);
#endif // TORRENT_NO_DEPRECATE
#endif // TORRENT_USE_WSTRING
#endif // TORRENT_DISABLE_GEO_IP
void start_lsd();
natpmp* start_natpmp();
upnp* start_upnp();
@ -1230,17 +1203,6 @@ namespace libtorrent
// to be unloaded. If it isn't, torrents will never be unloaded
user_load_function_t m_user_load_torrent;
#ifndef TORRENT_DISABLE_GEO_IP
GeoIP* m_asnum_db;
GeoIP* m_country_db;
// maps AS number to the peak download rate
// we've seen from it. Entries are never removed
// from this map. Pointers to its elements
// are kept in the torrent_peer structures.
std::map<int, int> m_as_peak;
#endif
// this is true whenever we have posted a deferred-disk job
// it means we don't need to post another one
bool m_deferred_submit_disk_jobs;

View File

@ -296,15 +296,6 @@ namespace libtorrent { namespace aux
virtual void prioritize_dht(boost::weak_ptr<torrent> t) = 0;
#endif
#ifndef TORRENT_DISABLE_GEO_IP
virtual bool has_asnum_db() const = 0;
virtual bool has_country_db() const = 0;
virtual char const* country_for_ip(address const& a) = 0;
virtual std::string as_name_for_ip(address const& a) = 0;
virtual int as_for_ip(address const& a) = 0;
virtual std::pair<const int, int>* lookup_as(int as) = 0;
#endif
#if TORRENT_USE_ASSERTS
virtual bool is_single_thread() const = 0;
virtual bool has_peer(peer_connection const* p) const = 0;

View File

@ -54,7 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
#if TORRENT_USE_IPV6
#define TORRENT_CFG_IPV6 ipv6_
#else
#define TORRENT_CFG_IPV6 noipv_-
#define TORRENT_CFG_IPV6 noipv6_-
#endif
#ifdef TORRENT_NO_DEPRECATE

View File

@ -1084,10 +1084,6 @@ namespace libtorrent
handler_storage<TORRENT_READ_HANDLER_MAX_SIZE> m_read_handler_storage;
handler_storage<TORRENT_WRITE_HANDLER_MAX_SIZE> m_write_handler_storage;
#ifndef TORRENT_DISABLE_GEO_IP
std::string m_inet_as_name;
#endif
// if this peer is receiving a piece, this
// points to a disk buffer that the data is
// read into. This eliminates a memcopy from

View File

@ -700,8 +700,12 @@ namespace libtorrent
torrent*, void*)> ext);
void add_extension(boost::shared_ptr<plugin> ext);
// These functions are not available if ``TORRENT_DISABLE_GEO_IP`` is
// defined. They expects a path to the `MaxMind ASN database`_ and
#ifndef TORRENT_NO_DEPRECATE
// GeoIP support has been removed from libtorrent internals. If you
// still need to resolve peers, please do so on the client side, using
// libgeoip directly. This was removed in libtorrent 1.1
// These functions expects a path to the `MaxMind ASN database`_ and
// `MaxMind GeoIP database`_ respectively. This will be used to look up
// which AS and country peers belong to.
//
@ -711,10 +715,12 @@ namespace libtorrent
//
// .. _`MaxMind ASN database`: http://www.maxmind.com/app/asnum
// .. _`MaxMind GeoIP database`: http://www.maxmind.com/app/geolitecountry
void load_asnum_db(char const* file);
void load_country_db(char const* file);
int as_for_ip(address const& addr);
#ifndef TORRENT_NO_DEPRECATE
TORRENT_DEPRECATED_PREFIX
void load_asnum_db(char const* file) TORRENT_DEPRECATED;
TORRENT_DEPRECATED_PREFIX
void load_country_db(char const* file) TORRENT_DEPRECATED;
TORRENT_DEPRECATED_PREFIX
int as_for_ip(address const& addr) TORRENT_DEPRECATED;
#if TORRENT_USE_WSTRING
// all wstring APIs are deprecated since 0.16.11
// instead, use the wchar -> utf8 conversion functions
@ -724,16 +730,14 @@ namespace libtorrent
TORRENT_DEPRECATED_PREFIX
void load_asnum_db(wchar_t const* file) TORRENT_DEPRECATED;
#endif // TORRENT_USE_WSTRING
#endif // TORRENT_NO_DEPRECATE
#ifndef TORRENT_NO_DEPRECATE
// deprecated in 0.15
// use load_state and save_state instead
TORRENT_DEPRECATED_PREFIX
void load_state(entry const& ses_state) TORRENT_DEPRECATED;
TORRENT_DEPRECATED_PREFIX
entry state() const TORRENT_DEPRECATED;
#endif
#endif // TORRENT_NO_DEPRECATE
// Sets a filter that will be used to reject and accept incoming as well
// as outgoing connections based on their originating ip address. The

View File

@ -87,16 +87,6 @@ namespace libtorrent
// calculated lazily
mutable boost::uint32_t peer_rank;
#ifndef TORRENT_DISABLE_GEO_IP
#ifdef TORRENT_DEBUG
// only used in debug mode to assert that
// the first entry in the AS pair keeps the same
boost::uint16_t inet_as_num;
#endif
// The AS this torrent_peer belongs to
std::pair<const int, int>* inet_as;
#endif
// the time when this torrent_peer was optimistically unchoked
// the last time. in seconds since session was created
// 16 bits is enough to last for 18.2 hours

View File

@ -233,17 +233,6 @@ namespace libtorrent
TORRENT_ASSERT(pack.peerinfo == 0 || pack.peerinfo->banned == false);
#ifndef TORRENT_DISABLE_RESOLVE_COUNTRIES
std::fill(m_country, m_country + 2, 0);
#ifndef TORRENT_DISABLE_GEO_IP
if (m_ses.has_country_db())
{
char const *country = m_ses.country_for_ip(m_remote.address());
if (country != 0)
{
m_country[0] = country[0];
m_country[1] = country[1];
}
}
#endif
#endif
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
error_code ec;
@ -265,9 +254,6 @@ namespace libtorrent
, m_peer_info ? m_peer_info->seed : 0, m_peer_info
, print_endpoint(local_ep).c_str());
#endif
#ifndef TORRENT_DISABLE_GEO_IP
m_inet_as_name = m_ses.as_name_for_ip(m_remote.address());
#endif
#ifdef TORRENT_DEBUG
piece_failed = false;
#endif
@ -4279,9 +4265,6 @@ namespace libtorrent
else p.request_timeout = int(total_seconds(m_requested - now)
+ m_settings.get_int(settings_pack::request_timeout)
+ m_timeout_extend);
#ifndef TORRENT_DISABLE_GEO_IP
p.inet_as_name = m_inet_as_name;
#endif
p.download_queue_time = download_queue_time();
p.queue_bytes = m_outstanding_bytes;
@ -4354,9 +4337,7 @@ namespace libtorrent
p.num_hashfails = pi->hashfails;
p.flags |= pi->on_parole ? peer_info::on_parole : 0;
p.flags |= pi->optimistically_unchoked ? peer_info::optimistic_unchoke : 0;
#ifndef TORRENT_DISABLE_GEO_IP
p.inet_as = pi->inet_as ? pi->inet_as->first : 0xffff;
#else
#ifndef TORRENT_NO_DEPRECATE
p.inet_as = 0xffff;
#endif
}
@ -4781,14 +4762,6 @@ namespace libtorrent
if (m_statistics.download_payload_rate() > m_download_rate_peak)
{
m_download_rate_peak = m_statistics.download_payload_rate();
#ifndef TORRENT_DISABLE_GEO_IP
if (peer_info_struct())
{
std::pair<const int, int>* as_stats = peer_info_struct()->inet_as;
if (as_stats && as_stats->second < m_download_rate_peak)
as_stats->second = m_download_rate_peak;
}
#endif
}
if (is_disconnecting()) return;

View File

@ -1284,9 +1284,6 @@ namespace libtorrent
torrent_peer const& p = **i;
TORRENT_ASSERT(p.in_use);
if (is_connect_candidate(p)) ++connect_candidates;
#ifndef TORRENT_DISABLE_GEO_IP
TORRENT_ASSERT(p.inet_as == 0 || p.inet_as->first == p.inet_as_num);
#endif
++total_connections;
if (!p.connection)
{

View File

@ -490,48 +490,18 @@ namespace libtorrent
#endif
}
void session::load_asnum_db(char const* file)
{
#ifndef TORRENT_DISABLE_GEO_IP
TORRENT_ASYNC_CALL1(load_asnum_db, std::string(file));
#endif
}
void session::load_country_db(char const* file)
{
#ifndef TORRENT_DISABLE_GEO_IP
TORRENT_ASYNC_CALL1(load_country_db, std::string(file));
#endif
}
#ifndef TORRENT_NO_DEPRECATE
void session::load_asnum_db(char const* file) {}
void session::load_country_db(char const* file) {}
int session::as_for_ip(address const& addr)
{
#ifndef TORRENT_DISABLE_GEO_IP
return m_impl->as_for_ip(addr);
#else
return 0;
#endif
}
{ return 0; }
#if TORRENT_USE_WSTRING
#ifndef TORRENT_NO_DEPRECATE
void session::load_asnum_db(wchar_t const* file)
{
#ifndef TORRENT_DISABLE_GEO_IP
TORRENT_ASYNC_CALL1(load_asnum_dbw, std::wstring(file));
#endif
}
void session::load_country_db(wchar_t const* file)
{
#ifndef TORRENT_DISABLE_GEO_IP
TORRENT_ASYNC_CALL1(load_country_dbw, std::wstring(file));
#endif
}
#endif // TORRENT_NO_DEPRECATE
void session::load_asnum_db(wchar_t const* file) {}
void session::load_country_db(wchar_t const* file) {}
#endif // TORRENT_USE_WSTRING
#ifndef TORRENT_NO_DEPRECATE
void session::load_state(entry const& ses_state)
{
if (ses_state.type() == entry::undefined_t) return;
@ -557,7 +527,7 @@ namespace libtorrent
TORRENT_SYNC_CALL2(save_state, &ret, 0xffffffff);
return ret;
}
#endif
#endif // TORRENT_NO_DEPRECATE
void session::set_ip_filter(ip_filter const& f)
{

View File

@ -492,10 +492,6 @@ namespace aux {
, m_tick_residual(0)
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
, m_logpath(".")
#endif
#ifndef TORRENT_DISABLE_GEO_IP
, m_asnum_db(0)
, m_country_db(0)
#endif
, m_deferred_submit_disk_jobs(false)
, m_pending_auto_manage(false)
@ -1217,21 +1213,6 @@ namespace aux {
}
#endif
#ifndef TORRENT_DISABLE_GEO_IP
if (flags & session::save_as_map)
{
entry::dictionary_type& as_map = e["AS map"].dict();
char buf[10];
for (std::map<int, int>::const_iterator i = m_as_peak.begin()
, end(m_as_peak.end()); i != end; ++i)
{
if (i->second == 0) continue;
sprintf(buf, "%05d", i->first);
as_map[buf] = i->second;
}
}
#endif
if (flags & session::save_feeds)
{
entry::list_type& feeds = e["feeds"].list();
@ -1357,21 +1338,6 @@ namespace aux {
}
#endif
#ifndef TORRENT_DISABLE_GEO_IP
settings = e->dict_find_dict("AS map");
if (settings)
{
for (int i = 0; i < settings->dict_size(); ++i)
{
std::pair<std::string, lazy_entry const*> item = settings->dict_at(i);
int as_num = atoi(item.first.c_str());
if (item.second->type() != lazy_entry::int_t || item.second->int_value() == 0) continue;
int& peak = m_as_peak[as_num];
if (peak < item.second->int_value()) peak = item.second->int_value();
}
}
#endif
settings = e->dict_find_list("feeds");
if (settings)
{
@ -1398,110 +1364,6 @@ namespace aux {
#endif
}
#ifndef TORRENT_DISABLE_GEO_IP
namespace
{
struct free_ptr
{
void* ptr_;
free_ptr(void* p): ptr_(p) {}
~free_ptr() { free(ptr_); }
};
}
char const* session_impl::country_for_ip(address const& a)
{
TORRENT_ASSERT(is_single_thread());
if (!a.is_v4() || m_country_db == 0) return 0;
return GeoIP_country_code_by_ipnum(m_country_db, a.to_v4().to_ulong());
}
int session_impl::as_for_ip(address const& a)
{
TORRENT_ASSERT(is_single_thread());
if (!a.is_v4() || m_asnum_db == 0) return 0;
char* name = GeoIP_name_by_ipnum(m_asnum_db, a.to_v4().to_ulong());
if (name == 0) return 0;
free_ptr p(name);
// GeoIP returns the name as AS??? where ? is the AS-number
return atoi(name + 2);
}
std::string session_impl::as_name_for_ip(address const& a)
{
TORRENT_ASSERT(is_single_thread());
if (!a.is_v4() || m_asnum_db == 0) return std::string();
char* name = GeoIP_name_by_ipnum(m_asnum_db, a.to_v4().to_ulong());
if (name == 0) return std::string();
free_ptr p(name);
char* tmp = std::strchr(name, ' ');
if (tmp == 0) return std::string();
return tmp + 1;
}
std::pair<const int, int>* session_impl::lookup_as(int as)
{
TORRENT_ASSERT(is_single_thread());
std::map<int, int>::iterator i = m_as_peak.lower_bound(as);
if (i == m_as_peak.end() || i->first != as)
{
// we don't have any data for this AS, insert a new entry
i = m_as_peak.insert(i, std::pair<int, int>(as, 0));
}
return &(*i);
}
void session_impl::load_asnum_db(std::string file)
{
TORRENT_ASSERT(is_single_thread());
if (m_asnum_db) GeoIP_delete(m_asnum_db);
m_asnum_db = GeoIP_open(file.c_str(), GEOIP_STANDARD);
// return m_asnum_db;
}
#if TORRENT_USE_WSTRING
#ifndef TORRENT_NO_DEPRECATE
void session_impl::load_asnum_dbw(std::wstring file)
{
TORRENT_ASSERT(is_single_thread());
if (m_asnum_db) GeoIP_delete(m_asnum_db);
std::string utf8;
wchar_utf8(file, utf8);
m_asnum_db = GeoIP_open(utf8.c_str(), GEOIP_STANDARD);
// return m_asnum_db;
}
void session_impl::load_country_dbw(std::wstring file)
{
TORRENT_ASSERT(is_single_thread());
if (m_country_db) GeoIP_delete(m_country_db);
std::string utf8;
wchar_utf8(file, utf8);
m_country_db = GeoIP_open(utf8.c_str(), GEOIP_STANDARD);
// return m_country_db;
}
#endif // TORRENT_NO_DEPRECATE
#endif // TORRENT_USE_WSTRING
void session_impl::load_country_db(std::string file)
{
TORRENT_ASSERT(is_single_thread());
if (m_country_db) GeoIP_delete(m_country_db);
m_country_db = GeoIP_open(file.c_str(), GEOIP_STANDARD);
// return m_country_db;
}
#endif // TORRENT_DISABLE_GEO_IP
#ifndef TORRENT_DISABLE_EXTENSIONS
typedef boost::function<boost::shared_ptr<torrent_plugin>(torrent*, void*)> ext_function_t;
@ -1721,13 +1583,6 @@ namespace aux {
m_undead_peers.clear();
#ifndef TORRENT_DISABLE_GEO_IP
if (m_asnum_db) GeoIP_delete(m_asnum_db);
if (m_country_db) GeoIP_delete(m_country_db);
m_asnum_db = 0;
m_country_db = 0;
#endif
// it's OK to detach the threads here. The disk_io_thread
// has an internal counter and won't release the network
// thread until they're all dead (via m_work).

View File

@ -6004,14 +6004,6 @@ namespace libtorrent
if (m_ses.is_aborted()) return;
#ifndef TORRENT_DISABLE_GEO_IP
int as = m_ses.as_for_ip(host->endpoint().address());
#ifdef TORRENT_DEBUG
web->peer_info.inet_as_num = as;
#endif
web->peer_info.inet_as = m_ses.lookup_as(as);
#endif
if (int(m_connections.size()) >= m_max_connections
|| m_ses.num_connections() >= m_ses.settings().get_int(settings_pack::connections_limit))
return;

View File

@ -134,9 +134,6 @@ namespace libtorrent
, prev_amount_download(0)
, connection(0)
, peer_rank(0)
#ifndef TORRENT_DISABLE_GEO_IP
, inet_as(0)
#endif
, last_optimistically_unchoked(0)
, last_connected(0)
, port(port)