simplify the debug logging mechanism. There's now only one build option, logging=on or logging=off. When logging is enabled, the log level is controlled by the alert mask. All log events are delivered as alerts and it's up to the client to write them to disk in whatever way seems appropriate. removed the pointless logger plugin
This commit is contained in:
parent
4eaec6d87f
commit
09bc1550e9
|
@ -84,7 +84,6 @@ set(sources
|
||||||
upnp
|
upnp
|
||||||
utp_socket_manager
|
utp_socket_manager
|
||||||
utp_stream
|
utp_stream
|
||||||
logger
|
|
||||||
file_pool
|
file_pool
|
||||||
lsd
|
lsd
|
||||||
disk_io_job
|
disk_io_job
|
||||||
|
@ -151,7 +150,6 @@ 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)
|
||||||
option(logging "build with logging" OFF)
|
option(logging "build with logging" OFF)
|
||||||
option(verbose-logging "build with verbose logging" OFF)
|
|
||||||
option(build_tests "build tests" OFF)
|
option(build_tests "build tests" OFF)
|
||||||
|
|
||||||
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo)
|
set(CMAKE_CONFIGURATION_TYPES Debug Release RelWithDebInfo)
|
||||||
|
@ -190,9 +188,6 @@ endif (encryption)
|
||||||
if (logging)
|
if (logging)
|
||||||
add_definitions(-DTORRENT_LOGGING)
|
add_definitions(-DTORRENT_LOGGING)
|
||||||
endif()
|
endif()
|
||||||
if (verbose-logging)
|
|
||||||
add_definitions(-DTORRENT_VERBOSE_LOGGING)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(s ${sources})
|
foreach(s ${sources})
|
||||||
list(APPEND sources2 src/${s})
|
list(APPEND sources2 src/${s})
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
* greatly simplify the debug logging infrastructure. logs are now delivered
|
||||||
|
as alerts, and log level is controlled by the alert mask.
|
||||||
* removed auto_expand_choker. use rate_based_choker instead
|
* removed auto_expand_choker. use rate_based_choker instead
|
||||||
* optimize UDP tracker packet handling
|
* optimize UDP tracker packet handling
|
||||||
* support SSL over uTP connections
|
* support SSL over uTP connections
|
||||||
|
|
11
Jamfile
11
Jamfile
|
@ -399,10 +399,8 @@ feature.compose <disk-stats>on : <define>TORRENT_DISK_STATS ;
|
||||||
feature simulate-slow-read : off on : composite propagated ;
|
feature simulate-slow-read : off on : composite propagated ;
|
||||||
feature.compose <simulate-slow-read>on : <define>TORRENT_SIMULATE_SLOW_READ ;
|
feature.compose <simulate-slow-read>on : <define>TORRENT_SIMULATE_SLOW_READ ;
|
||||||
|
|
||||||
feature logging : none default errors verbose : composite propagated link-incompatible ;
|
feature logging : off on : composite propagated link-incompatible ;
|
||||||
feature.compose <logging>default : <define>TORRENT_LOGGING ;
|
feature.compose <logging>on : <define>TORRENT_LOGGING ;
|
||||||
feature.compose <logging>errors : <define>TORRENT_ERROR_LOGGING ;
|
|
||||||
feature.compose <logging>verbose : <define>TORRENT_VERBOSE_LOGGING ;
|
|
||||||
|
|
||||||
feature dht : on off logging : composite propagated link-incompatible ;
|
feature dht : on off logging : composite propagated link-incompatible ;
|
||||||
feature.compose <dht>off : <define>TORRENT_DISABLE_DHT ;
|
feature.compose <dht>off : <define>TORRENT_DISABLE_DHT ;
|
||||||
|
@ -455,13 +453,13 @@ variant test_release
|
||||||
<export-extra>on <debug-iterators>on <boost>source <threading>multi
|
<export-extra>on <debug-iterators>on <boost>source <threading>multi
|
||||||
;
|
;
|
||||||
variant test_debug : debug
|
variant test_debug : debug
|
||||||
: <encryption>openssl <logging>verbose <disk-stats>on
|
: <encryption>openssl <logging>on <disk-stats>on
|
||||||
<dht>logging <request-log>on <allocator>debug <debug-iterators>on
|
<dht>logging <request-log>on <allocator>debug <debug-iterators>on
|
||||||
<invariant-checks>full <boost-link>shared
|
<invariant-checks>full <boost-link>shared
|
||||||
<export-extra>on <debug-iterators>on <boost>source <threading>multi
|
<export-extra>on <debug-iterators>on <boost>source <threading>multi
|
||||||
;
|
;
|
||||||
variant test_barebones : debug
|
variant test_barebones : debug
|
||||||
: <ipv6>off <dht>off <extensions>off <logging>none <boost-link>shared
|
: <ipv6>off <dht>off <extensions>off <logging>off <boost-link>shared
|
||||||
<deprecated-functions>off <invariant-checks>off
|
<deprecated-functions>off <invariant-checks>off
|
||||||
<export-extra>on <debug-iterators>on <boost>source <threading>multi
|
<export-extra>on <debug-iterators>on <boost>source <threading>multi
|
||||||
;
|
;
|
||||||
|
@ -604,7 +602,6 @@ SOURCES =
|
||||||
utf8
|
utf8
|
||||||
utp_socket_manager
|
utp_socket_manager
|
||||||
utp_stream
|
utp_stream
|
||||||
logger
|
|
||||||
file_pool
|
file_pool
|
||||||
lsd
|
lsd
|
||||||
disk_buffer_pool
|
disk_buffer_pool
|
||||||
|
|
14
configure.ac
14
configure.ac
|
@ -379,24 +379,14 @@ AC_MSG_CHECKING([whether logging to disk should be enabled])
|
||||||
AS_CASE(["$ARG_ENABLE_LOGGING"],
|
AS_CASE(["$ARG_ENABLE_LOGGING"],
|
||||||
["yes"|"default"], [
|
["yes"|"default"], [
|
||||||
AC_MSG_RESULT([yes])
|
AC_MSG_RESULT([yes])
|
||||||
AC_DEFINE([TORRENT_LOGGING],[1],[Define to enable logging of the session events.])
|
AC_DEFINE([TORRENT_LOGGING],[1],[Define to enable support for logging alerts])
|
||||||
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_LOGGING "
|
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_LOGGING "
|
||||||
],
|
],
|
||||||
["no"|"none"], [
|
["no"|"none"], [
|
||||||
AC_MSG_RESULT([no])
|
AC_MSG_RESULT([no])
|
||||||
],
|
],
|
||||||
["verbose"], [
|
|
||||||
AC_MSG_RESULT([verbose])
|
|
||||||
AC_DEFINE([TORRENT_VERBOSE_LOGGING],[1],[Define to enable logging of the session events and every peer connection.])
|
|
||||||
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_VERBOSE_LOGGING "
|
|
||||||
],
|
|
||||||
["errors"], [
|
|
||||||
AC_MSG_RESULT([errors])
|
|
||||||
AC_DEFINE([TORRENT_ERROR_LOGGING],[1],[Define to enable logging of the session events and every peer connection limited to errors.])
|
|
||||||
COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DTORRENT_ERROR_LOGGING "
|
|
||||||
],
|
|
||||||
[AC_MSG_RESULT([$ARG_ENABLE_LOGGING])
|
[AC_MSG_RESULT([$ARG_ENABLE_LOGGING])
|
||||||
AC_MSG_ERROR([Unknown option "$ARG_ENABLE_LOGGING". Use either "yes", "no", "verbose" or "errors".])]
|
AC_MSG_ERROR([Unknown option "$ARG_ENABLE_LOGGING". Use either "yes" or "no"])]
|
||||||
)
|
)
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether disk activity logging should be enabled])
|
AC_MSG_CHECKING([whether disk activity logging should be enabled])
|
||||||
|
|
|
@ -249,10 +249,11 @@ Build features:
|
||||||
| | * ``shared`` - links dynamically against the boost |
|
| | * ``shared`` - links dynamically against the boost |
|
||||||
| | libraries. |
|
| | libraries. |
|
||||||
+--------------------------+----------------------------------------------------+
|
+--------------------------+----------------------------------------------------+
|
||||||
| ``logging`` | * ``none`` - no logging. |
|
| ``logging`` | * ``off`` - default. logging disabled. |
|
||||||
| | * ``default`` - basic session logging. |
|
| | * ``on`` - logging alerts available, still need to |
|
||||||
| | * ``verbose`` - verbose peer wire logging. |
|
| | be enabled by the alert mask. The reason logging |
|
||||||
| | * ``errors`` - like verbose, but limited to errors.|
|
| | is disabled by default is to keep the binary |
|
||||||
|
| | size down. |
|
||||||
+--------------------------+----------------------------------------------------+
|
+--------------------------+----------------------------------------------------+
|
||||||
| ``dht`` | * ``on`` - build with support for tracker less |
|
| ``dht`` | * ``on`` - build with support for tracker less |
|
||||||
| | torrents and DHT support. |
|
| | torrents and DHT support. |
|
||||||
|
@ -552,13 +553,10 @@ defines you can use to control the build.
|
||||||
| | compilation units having different views of |
|
| | compilation units having different views of |
|
||||||
| | structs and class layouts and sizes. |
|
| | structs and class layouts and sizes. |
|
||||||
+----------------------------------------+-------------------------------------------------+
|
+----------------------------------------+-------------------------------------------------+
|
||||||
| ``TORRENT_LOGGING`` | This macro will enable logging of the session |
|
| ``TORRENT_LOGGING`` | This macro will enable support for logging |
|
||||||
| | events, such as tracker announces and incoming |
|
| | alerts, like log_alert, torrent_log_alert and |
|
||||||
| | connections (as well as blocked connections). |
|
| | peer_log_alert. Without this build flag, you |
|
||||||
+----------------------------------------+-------------------------------------------------+
|
| | cannot enable those alerts. |
|
||||||
| ``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. |
|
|
||||||
+----------------------------------------+-------------------------------------------------+
|
+----------------------------------------+-------------------------------------------------+
|
||||||
| ``TORRENT_STORAGE_DEBUG`` | This will enable extra expensive invariant |
|
| ``TORRENT_STORAGE_DEBUG`` | This will enable extra expensive invariant |
|
||||||
| | checks in the storage, including logging of |
|
| | checks in the storage, including logging of |
|
||||||
|
|
|
@ -153,7 +153,6 @@ nobase_include_HEADERS = \
|
||||||
aux_/session_impl.hpp \
|
aux_/session_impl.hpp \
|
||||||
aux_/session_settings.hpp\
|
aux_/session_settings.hpp\
|
||||||
\
|
\
|
||||||
extensions/logger.hpp \
|
|
||||||
extensions/lt_trackers.hpp \
|
extensions/lt_trackers.hpp \
|
||||||
extensions/metadata_transfer.hpp \
|
extensions/metadata_transfer.hpp \
|
||||||
extensions/smart_ban.hpp \
|
extensions/smart_ban.hpp \
|
||||||
|
|
|
@ -165,6 +165,23 @@ namespace libtorrent {
|
||||||
// will make you receive rss_alert alerts.
|
// will make you receive rss_alert alerts.
|
||||||
rss_notification = 0x1000,
|
rss_notification = 0x1000,
|
||||||
|
|
||||||
|
// Enables debug logging alerts. These are only available when
|
||||||
|
// libtorrent is built with logging enabled (``TORRENT_LOGGING``).
|
||||||
|
// The alerts being posted are log_alert and are session wide.
|
||||||
|
session_log_notification = 0x2000,
|
||||||
|
|
||||||
|
// Enables debug logging alerts for torrents. These are only available
|
||||||
|
// when libtorrent is built with logging enabled
|
||||||
|
// (``TORRENT_LOGGING``). The alerts being posted are
|
||||||
|
// torrent_log_alert and are torrent wide debug events.
|
||||||
|
torrent_log_notification = 0x4000,
|
||||||
|
|
||||||
|
// Enables debug logging alerts for peers. These are only available
|
||||||
|
// when libtorrent is built with logging enabled
|
||||||
|
// (``TORRENT_LOGGING``). The alerts being posted are peer_log_alert
|
||||||
|
// and low-level peer events and messages.
|
||||||
|
peer_log_notification = 0x8000,
|
||||||
|
|
||||||
// The full bitmask, representing all available categories.
|
// The full bitmask, representing all available categories.
|
||||||
//
|
//
|
||||||
// since the enum is signed, make sure this isn't
|
// since the enum is signed, make sure this isn't
|
||||||
|
|
|
@ -2178,9 +2178,78 @@ namespace libtorrent
|
||||||
udp::endpoint ip;
|
udp::endpoint ip;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This alert is posted by some session wide event. Its main purpose is
|
||||||
|
// trouble shooting and debugging. It's not enabled by the default alert
|
||||||
|
// mask and is enabled by the ``alert::session_log_notification`` bit.
|
||||||
|
// Furhtermore, it's by default disabled as a build configuration. To
|
||||||
|
// enable, build libtorrent with logging support enabled (``logging=on``
|
||||||
|
// with bjam or define ``TORRENT_LOGGING``).
|
||||||
|
struct TORRENT_EXPORT log_alert : alert
|
||||||
|
{
|
||||||
|
// internal
|
||||||
|
log_alert(char const* log)
|
||||||
|
: msg(log)
|
||||||
|
{}
|
||||||
|
|
||||||
|
TORRENT_DEFINE_ALERT(log_alert, 79);
|
||||||
|
|
||||||
|
const static int static_category = alert::session_log_notification;
|
||||||
|
virtual std::string message() const;
|
||||||
|
|
||||||
|
// the log message
|
||||||
|
std::string msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
// This alert is posted by torrent wide events. It's meant to be used for
|
||||||
|
// trouble shooting and debugging. It's not enabled by the default alert
|
||||||
|
// mask and is enabled by the ``alert::torrent_log_notification`` bit. By
|
||||||
|
// default it is disabled as a build configuration. To enable, build
|
||||||
|
// libtorrent with logging support enabled (``logging=on`` with bjam or
|
||||||
|
// define ``TORRENT_LOGGING``).
|
||||||
|
struct TORRENT_EXPORT torrent_log_alert : torrent_alert
|
||||||
|
{
|
||||||
|
// internal
|
||||||
|
torrent_log_alert(torrent_handle h, char const* log)
|
||||||
|
: torrent_alert(h)
|
||||||
|
, msg(log)
|
||||||
|
{}
|
||||||
|
|
||||||
|
TORRENT_DEFINE_ALERT(torrent_log_alert, 80);
|
||||||
|
|
||||||
|
const static int static_category = alert::torrent_log_notification;
|
||||||
|
virtual std::string message() const;
|
||||||
|
|
||||||
|
// the log message
|
||||||
|
std::string msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
// This alert is posted by events specific to a peer. It's meant to be used
|
||||||
|
// for trouble shooting and debugging. It's not enabled by the default alert
|
||||||
|
// mask and is enabled by the ``alert::peer_log_notification`` bit. By
|
||||||
|
// default it is disabled as a build configuration. To enable, build
|
||||||
|
// libtorrent with logging support enabled (``logging=on`` with bjam or
|
||||||
|
// define ``TORRENT_LOGGING``).
|
||||||
|
struct TORRENT_EXPORT peer_log_alert : peer_alert
|
||||||
|
{
|
||||||
|
// internal
|
||||||
|
peer_log_alert(torrent_handle const& h, tcp::endpoint const& i
|
||||||
|
, peer_id const& pi, char const* log)
|
||||||
|
: peer_alert(h, i, pi)
|
||||||
|
, msg(log)
|
||||||
|
{}
|
||||||
|
|
||||||
|
TORRENT_DEFINE_ALERT(peer_log_alert, 81);
|
||||||
|
|
||||||
|
const static int static_category = alert::peer_log_notification;
|
||||||
|
virtual std::string message() const;
|
||||||
|
|
||||||
|
// the log message
|
||||||
|
std::string msg;
|
||||||
|
};
|
||||||
|
|
||||||
#undef TORRENT_DEFINE_ALERT
|
#undef TORRENT_DEFINE_ALERT
|
||||||
|
|
||||||
enum { num_alert_types = 79 };
|
enum { num_alert_types = 82 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ namespace libtorrent
|
||||||
struct session_impl;
|
struct session_impl;
|
||||||
struct session_settings;
|
struct session_settings;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
struct tracker_logger;
|
struct tracker_logger;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -179,13 +179,6 @@ namespace libtorrent
|
||||||
, uncork_interface
|
, uncork_interface
|
||||||
, single_threaded
|
, single_threaded
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
// this needs to be destructed last, since other components may log
|
|
||||||
// things as they are being destructed. That's why it's declared at
|
|
||||||
// the top of session_impl
|
|
||||||
boost::shared_ptr<logger> m_logger;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// the size of each allocation that is chained in the send buffer
|
// the size of each allocation that is chained in the send buffer
|
||||||
enum { send_buffer_size_impl = 128 };
|
enum { send_buffer_size_impl = 128 };
|
||||||
|
|
||||||
|
@ -206,9 +199,6 @@ namespace libtorrent
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
void start_session(settings_pack const& pack);
|
void start_session(settings_pack const& pack);
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
void set_log_path(std::string const& p) { m_logpath = p; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void set_load_function(user_load_function_t fun)
|
void set_load_function(user_load_function_t fun)
|
||||||
{ m_user_load_torrent = fun; }
|
{ m_user_load_torrent = fun; }
|
||||||
|
@ -699,7 +689,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// handles delayed alerts
|
// handles delayed alerts
|
||||||
alert_manager m_alerts;
|
mutable alert_manager m_alerts;
|
||||||
|
|
||||||
// handles disk io requests asynchronously
|
// handles disk io requests asynchronously
|
||||||
// peers have pointers into the disk buffer
|
// peers have pointers into the disk buffer
|
||||||
|
@ -1117,35 +1107,21 @@ namespace libtorrent
|
||||||
// accumulated error
|
// accumulated error
|
||||||
boost::uint16_t m_tick_residual;
|
boost::uint16_t m_tick_residual;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
virtual boost::shared_ptr<logger> create_log(std::string const& name
|
|
||||||
, int instance, bool append = true);
|
|
||||||
|
|
||||||
virtual void session_log(char const* fmt, ...) const;
|
virtual void session_log(char const* fmt, ...) const;
|
||||||
virtual void session_vlog(char const* fmt, va_list& va) const;
|
virtual void session_vlog(char const* fmt, va_list& va) const;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
|
||||||
void log_all_torrents(peer_connection* p);
|
void log_all_torrents(peer_connection* p);
|
||||||
#endif
|
|
||||||
|
|
||||||
// this list of tracker loggers serves as tracker_callbacks when
|
// this list of tracker loggers serves as tracker_callbacks when
|
||||||
// shutting down. This list is just here to keep them alive during
|
// shutting down. This list is just here to keep them alive during
|
||||||
// whe shutting down process
|
// whe shutting down process
|
||||||
std::list<boost::shared_ptr<tracker_logger> > m_tracker_loggers;
|
std::list<boost::shared_ptr<tracker_logger> > m_tracker_loggers;
|
||||||
|
|
||||||
std::string get_log_path() const
|
|
||||||
{ return m_logpath; }
|
|
||||||
|
|
||||||
std::string m_logpath;
|
|
||||||
FILE* m_request_logger;
|
FILE* m_request_logger;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
#ifdef TORRENT_UPNP_LOGGING
|
|
||||||
std::ofstream m_upnp_log;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// state for keeping track of external IPs
|
// state for keeping track of external IPs
|
||||||
external_ip m_external_ip;
|
external_ip m_external_ip;
|
||||||
|
|
||||||
|
@ -1202,7 +1178,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
struct tracker_logger : request_callback
|
struct tracker_logger : request_callback
|
||||||
{
|
{
|
||||||
tracker_logger(session_interface& ses);
|
tracker_logger(session_interface& ses);
|
||||||
|
|
|
@ -46,7 +46,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/socket.hpp"
|
#include "libtorrent/socket.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -70,9 +70,6 @@ namespace libtorrent
|
||||||
struct bandwidth_manager;
|
struct bandwidth_manager;
|
||||||
struct peer_class_pool;
|
struct peer_class_pool;
|
||||||
struct disk_observer;
|
struct disk_observer;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
struct logger;
|
|
||||||
#endif
|
|
||||||
struct torrent_peer;
|
struct torrent_peer;
|
||||||
class alert_manager;
|
class alert_manager;
|
||||||
struct disk_interface;
|
struct disk_interface;
|
||||||
|
@ -305,16 +302,11 @@ namespace libtorrent { namespace aux
|
||||||
virtual FILE* get_request_log() = 0;
|
virtual FILE* get_request_log() = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
virtual boost::shared_ptr<logger> create_log(std::string const& name
|
|
||||||
, int instance, bool append = true) = 0;
|
|
||||||
virtual void session_log(char const* fmt, ...) const = 0;
|
virtual void session_log(char const* fmt, ...) const = 0;
|
||||||
virtual void session_vlog(char const* fmt, va_list& va) const = 0;
|
virtual void session_vlog(char const* fmt, va_list& va) const = 0;
|
||||||
virtual std::string get_log_path() const = 0;
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
|
||||||
virtual void log_all_torrents(peer_connection* p) = 0;
|
virtual void log_all_torrents(peer_connection* p) = 0;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TORRENT_BUFFER_STATS
|
#ifdef TORRENT_BUFFER_STATS
|
||||||
virtual void log_buffer_usage() = 0;
|
virtual void log_buffer_usage() = 0;
|
||||||
|
|
|
@ -388,11 +388,6 @@ int snprintf(char* buf, int len, char const* fmt, ...)
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)) \
|
|
||||||
&& !defined (TORRENT_UPNP_LOGGING) && TORRENT_USE_IOSTREAM
|
|
||||||
#define TORRENT_UPNP_LOGGING
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_ICONV_ARG
|
#ifndef TORRENT_ICONV_ARG
|
||||||
#define TORRENT_ICONV_ARG (char**)
|
#define TORRENT_ICONV_ARG (char**)
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -195,116 +195,5 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include "libtorrent/config.hpp"
|
|
||||||
#include "libtorrent/file.hpp"
|
|
||||||
#include "libtorrent/thread.hpp"
|
|
||||||
|
|
||||||
#if TORRENT_USE_IOSTREAM
|
|
||||||
#include <string>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
|
||||||
// DEBUG API
|
|
||||||
|
|
||||||
// TODO: rewrite this class to use FILE* instead and
|
|
||||||
// have a printf-like interface
|
|
||||||
struct logger
|
|
||||||
{
|
|
||||||
#if TORRENT_USE_IOSTREAM
|
|
||||||
// all log streams share a single file descriptor
|
|
||||||
// and re-opens the file for each log line
|
|
||||||
// these members are defined in session_impl.cpp
|
|
||||||
static std::ofstream log_file;
|
|
||||||
static std::string open_filename;
|
|
||||||
static mutex file_mutex;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
~logger()
|
|
||||||
{
|
|
||||||
mutex::scoped_lock l(file_mutex);
|
|
||||||
log_file.close();
|
|
||||||
open_filename.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
logger(std::string const& logpath, std::string const& filename
|
|
||||||
, int instance, bool append)
|
|
||||||
{
|
|
||||||
char log_name[512];
|
|
||||||
snprintf(log_name, sizeof(log_name), "libtorrent_logs%d", instance);
|
|
||||||
std::string dir(complete(combine_path(combine_path(logpath, log_name), filename)) + ".log");
|
|
||||||
error_code ec;
|
|
||||||
if (!exists(parent_path(dir)))
|
|
||||||
create_directories(parent_path(dir), ec);
|
|
||||||
m_filename = dir;
|
|
||||||
|
|
||||||
mutex::scoped_lock l(file_mutex);
|
|
||||||
open(!append);
|
|
||||||
log_file << "\n\n\n*** starting log ***\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void move_log_file(std::string const& logpath, std::string const& new_name, int instance)
|
|
||||||
{
|
|
||||||
mutex::scoped_lock l(file_mutex);
|
|
||||||
if (open_filename == m_filename)
|
|
||||||
{
|
|
||||||
log_file.close();
|
|
||||||
open_filename.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
char log_name[512];
|
|
||||||
snprintf(log_name, sizeof(log_name), "libtorrent_logs%d", instance);
|
|
||||||
std::string dir(combine_path(combine_path(complete(logpath), log_name), new_name) + ".log");
|
|
||||||
|
|
||||||
error_code ec;
|
|
||||||
create_directories(parent_path(dir), ec);
|
|
||||||
|
|
||||||
if (ec)
|
|
||||||
fprintf(stderr, "Failed to create logfile directory %s: %s\n"
|
|
||||||
, parent_path(dir).c_str(), ec.message().c_str());
|
|
||||||
ec.clear();
|
|
||||||
rename(m_filename, dir, ec);
|
|
||||||
if (ec)
|
|
||||||
fprintf(stderr, "Failed to move logfile %s: %s\n"
|
|
||||||
, parent_path(dir).c_str(), ec.message().c_str());
|
|
||||||
|
|
||||||
m_filename = dir;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if TORRENT_USE_IOSTREAM
|
|
||||||
void open(bool truncate)
|
|
||||||
{
|
|
||||||
if (open_filename == m_filename) return;
|
|
||||||
log_file.close();
|
|
||||||
log_file.clear();
|
|
||||||
log_file.open(m_filename.c_str(), truncate ? std::ios_base::trunc : std::ios_base::app);
|
|
||||||
open_filename = m_filename;
|
|
||||||
if (!log_file.good())
|
|
||||||
fprintf(stderr, "Failed to open logfile %s: %s\n", m_filename.c_str(), strerror(errno));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
logger& operator<<(T const& v)
|
|
||||||
{
|
|
||||||
#if TORRENT_USE_IOSTREAM
|
|
||||||
mutex::scoped_lock l(file_mutex);
|
|
||||||
open(false);
|
|
||||||
log_file << v;
|
|
||||||
#endif
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string m_filename;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TORRENT_VERBOSE_LOGGING || TORRENT_LOGGING || TORRENT_ERROR_LOGGING
|
|
||||||
#endif // TORRENT_DEBUG_HPP_INCLUDED
|
#endif // TORRENT_DEBUG_HPP_INCLUDED
|
||||||
|
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright (c) 2006, Arvid Norberg
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions
|
|
||||||
are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in
|
|
||||||
the documentation and/or other materials provided with the distribution.
|
|
||||||
* Neither the name of the author nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TORRENT_LOGGER_HPP_INCLUDED
|
|
||||||
#define TORRENT_LOGGER_HPP_INCLUDED
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(push, 1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "libtorrent/config.hpp"
|
|
||||||
|
|
||||||
#if TORRENT_USE_IOSTREAM
|
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
|
||||||
struct torrent_plugin;
|
|
||||||
class torrent;
|
|
||||||
boost::shared_ptr<torrent_plugin> create_logger_plugin(torrent*);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // TORRENT_LOGGER_HPP_INCLUDED
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ private:
|
||||||
#if TORRENT_USE_IPV6
|
#if TORRENT_USE_IPV6
|
||||||
bool m_disabled6;
|
bool m_disabled6;
|
||||||
#endif
|
#endif
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
FILE* m_log;
|
FILE* m_log;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,7 +38,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
#include "libtorrent/debug.hpp"
|
#include "libtorrent/debug.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ namespace libtorrent
|
||||||
void set_holepunch_mode()
|
void set_holepunch_mode()
|
||||||
{
|
{
|
||||||
m_holepunch_mode = true;
|
m_holepunch_mode = true;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** HOLEPUNCH MODE ***");
|
peer_log("*** HOLEPUNCH MODE ***");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -553,12 +553,11 @@ namespace libtorrent
|
||||||
void decrease_est_reciprocation_rate();
|
void decrease_est_reciprocation_rate();
|
||||||
int est_reciprocation_rate() const { return m_est_reciprocation_rate; }
|
int est_reciprocation_rate() const { return m_est_reciprocation_rate; }
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
virtual void peer_log(char const* fmt, ...) const;
|
virtual void peer_log(char const* fmt, ...) const;
|
||||||
boost::shared_ptr<logger> m_logger;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
ptime m_connect_time;
|
ptime m_connect_time;
|
||||||
ptime m_bitfield_time;
|
ptime m_bitfield_time;
|
||||||
ptime m_unchoke_time;
|
ptime m_unchoke_time;
|
||||||
|
@ -654,7 +653,7 @@ namespace libtorrent
|
||||||
virtual boost::optional<piece_block_progress>
|
virtual boost::optional<piece_block_progress>
|
||||||
downloading_piece_progress() const
|
downloading_piece_progress() const
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** downloading_piece_progress() dispatched to the base class!");
|
peer_log("*** downloading_piece_progress() dispatched to the base class!");
|
||||||
#endif
|
#endif
|
||||||
return boost::optional<piece_block_progress>();
|
return boost::optional<piece_block_progress>();
|
||||||
|
|
|
@ -85,7 +85,7 @@ namespace libtorrent
|
||||||
virtual bool failed() const = 0;
|
virtual bool failed() const = 0;
|
||||||
virtual stat const& statistics() const = 0;
|
virtual stat const& statistics() const = 0;
|
||||||
virtual void get_peer_info(peer_info& p) const = 0;
|
virtual void get_peer_info(peer_info& p) const = 0;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
virtual void peer_log(char const* fmt, ...) const = 0;
|
virtual void peer_log(char const* fmt, ...) const = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
struct logger;
|
|
||||||
struct external_ip;
|
struct external_ip;
|
||||||
struct ip_filter;
|
struct ip_filter;
|
||||||
class port_filter;
|
class port_filter;
|
||||||
|
|
|
@ -70,7 +70,6 @@ namespace libtorrent
|
||||||
class torrent;
|
class torrent;
|
||||||
class peer_connection;
|
class peer_connection;
|
||||||
struct bitfield;
|
struct bitfield;
|
||||||
struct logger;
|
|
||||||
struct counters;
|
struct counters;
|
||||||
|
|
||||||
struct TORRENT_EXTRA_EXPORT piece_block
|
struct TORRENT_EXTRA_EXPORT piece_block
|
||||||
|
|
|
@ -164,12 +164,6 @@ namespace libtorrent
|
||||||
boost::shared_ptr<aux::session_impl> m_impl;
|
boost::shared_ptr<aux::session_impl> m_impl;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
#define TORRENT_LOGPATH_ARG_DEFAULT , std::string logpath = "."
|
|
||||||
#else
|
|
||||||
#define TORRENT_LOGPATH_ARG_DEFAULT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// This free function returns the list of available metrics exposed by
|
// This free function returns the list of available metrics exposed by
|
||||||
// libtorrent's statistics API. Each metric has a name and a *value index*.
|
// libtorrent's statistics API. Each metric has a name and a *value index*.
|
||||||
// The value index is the index into the array in session_stats_alert where
|
// The value index is the index into the array in session_stats_alert where
|
||||||
|
@ -221,8 +215,7 @@ namespace libtorrent
|
||||||
session(fingerprint const& print = fingerprint("LT"
|
session(fingerprint const& print = fingerprint("LT"
|
||||||
, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
|
, LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
|
||||||
, int flags = start_default_features | add_default_plugins
|
, int flags = start_default_features | add_default_plugins
|
||||||
, boost::uint32_t alert_mask = alert::error_notification
|
, boost::uint32_t alert_mask = alert::error_notification)
|
||||||
TORRENT_LOGPATH_ARG_DEFAULT)
|
|
||||||
{
|
{
|
||||||
TORRENT_CFG();
|
TORRENT_CFG();
|
||||||
settings_pack pack;
|
settings_pack pack;
|
||||||
|
@ -236,17 +229,13 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
init(print);
|
init(print);
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
set_log_path(logpath);
|
|
||||||
#endif
|
|
||||||
start(flags, pack);
|
start(flags, pack);
|
||||||
}
|
}
|
||||||
session(fingerprint const& print
|
session(fingerprint const& print
|
||||||
, std::pair<int, int> listen_port_range
|
, std::pair<int, int> listen_port_range
|
||||||
, char const* listen_interface = "0.0.0.0"
|
, char const* listen_interface = "0.0.0.0"
|
||||||
, int flags = start_default_features | add_default_plugins
|
, int flags = start_default_features | add_default_plugins
|
||||||
, int alert_mask = alert::error_notification
|
, int alert_mask = alert::error_notification)
|
||||||
TORRENT_LOGPATH_ARG_DEFAULT)
|
|
||||||
{
|
{
|
||||||
TORRENT_CFG();
|
TORRENT_CFG();
|
||||||
TORRENT_ASSERT(listen_port_range.first > 0);
|
TORRENT_ASSERT(listen_port_range.first > 0);
|
||||||
|
@ -267,9 +256,6 @@ namespace libtorrent
|
||||||
pack.set_bool(settings_pack::enable_dht, false);
|
pack.set_bool(settings_pack::enable_dht, false);
|
||||||
}
|
}
|
||||||
init(print);
|
init(print);
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
set_log_path(logpath);
|
|
||||||
#endif
|
|
||||||
start(flags, pack);
|
start(flags, pack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1233,7 +1219,6 @@ namespace libtorrent
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void init(fingerprint const& id);
|
void init(fingerprint const& id);
|
||||||
void set_log_path(std::string const& p);
|
|
||||||
void start(int flags, settings_pack const& pack);
|
void start(int flags, settings_pack const& pack);
|
||||||
|
|
||||||
// data shared between the main thread
|
// data shared between the main thread
|
||||||
|
|
|
@ -93,10 +93,6 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
class http_parser;
|
class http_parser;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
struct logger;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class piece_manager;
|
class piece_manager;
|
||||||
struct torrent_plugin;
|
struct torrent_plugin;
|
||||||
struct bitfield;
|
struct bitfield;
|
||||||
|
@ -977,11 +973,9 @@ namespace libtorrent
|
||||||
time_t last_seen_complete() const { return m_last_seen_complete; }
|
time_t last_seen_complete() const { return m_last_seen_complete; }
|
||||||
|
|
||||||
// LOGGING
|
// LOGGING
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
virtual void debug_log(const char* fmt, ...) const;
|
virtual void debug_log(const char* fmt, ...) const;
|
||||||
void log_to_all_peers(char const* message);
|
void log_to_all_peers(char const* message);
|
||||||
boost::shared_ptr<logger> m_logger;
|
|
||||||
ptime m_logger_time;
|
|
||||||
ptime m_dht_start_time;
|
ptime m_dht_start_time;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ namespace libtorrent
|
||||||
, const std::string& msg
|
, const std::string& msg
|
||||||
, int retry_interval) = 0;
|
, int retry_interval) = 0;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
virtual void debug_log(const char* fmt, ...) const = 0;
|
virtual void debug_log(const char* fmt, ...) const = 0;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
|
@ -49,11 +49,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
|
||||||
#if defined(TORRENT_UPNP_LOGGING)
|
|
||||||
#include <fstream>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ void utp_send_ack(utp_socket_impl* s);
|
||||||
void utp_socket_drained(utp_socket_impl* s);
|
void utp_socket_drained(utp_socket_impl* s);
|
||||||
void utp_writable(utp_socket_impl* s);
|
void utp_writable(utp_socket_impl* s);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
int socket_impl_size();
|
int socket_impl_size();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,6 @@ libtorrent_rasterbar_la_SOURCES = \
|
||||||
ip_filter.cpp \
|
ip_filter.cpp \
|
||||||
ip_voter.cpp \
|
ip_voter.cpp \
|
||||||
lazy_bdecode.cpp \
|
lazy_bdecode.cpp \
|
||||||
logger.cpp \
|
|
||||||
lsd.cpp \
|
lsd.cpp \
|
||||||
lt_trackers.cpp \
|
lt_trackers.cpp \
|
||||||
magnet_uri.cpp \
|
magnet_uri.cpp \
|
||||||
|
|
|
@ -715,5 +715,20 @@ namespace libtorrent {
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string log_alert::message() const
|
||||||
|
{
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string torrent_log_alert::message() const
|
||||||
|
{
|
||||||
|
return torrent_alert::message() + ": " + msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string peer_log_alert::message() const
|
||||||
|
{
|
||||||
|
return torrent_alert::message() + " [" + print_endpoint(ip) + "] " + msg;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace libtorrent
|
} // namespace libtorrent
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ namespace libtorrent
|
||||||
, m_in_constructor(true)
|
, m_in_constructor(true)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** bt_peer_connection");
|
peer_log("*** bt_peer_connection");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (t->graceful_pause())
|
if (t->graceful_pause())
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** ON_CONNECTED [ graceful-paused ]");
|
peer_log("*** ON_CONNECTED [ graceful-paused ]");
|
||||||
#endif
|
#endif
|
||||||
disconnect(error_code(errors::torrent_paused), op_bittorrent);
|
disconnect(error_code(errors::torrent_paused), op_bittorrent);
|
||||||
|
@ -193,7 +193,7 @@ namespace libtorrent
|
||||||
if (is_ssl(*get_socket()))
|
if (is_ssl(*get_socket()))
|
||||||
out_enc_policy = settings_pack::pe_disabled;
|
out_enc_policy = settings_pack::pe_disabled;
|
||||||
#endif
|
#endif
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
char const* policy_name[] = {"forced", "enabled", "disabled"};
|
char const* policy_name[] = {"forced", "enabled", "disabled"};
|
||||||
peer_log("*** outgoing encryption policy: %s", policy_name[out_enc_policy]);
|
peer_log("*** outgoing encryption policy: %s", policy_name[out_enc_policy]);
|
||||||
#endif
|
#endif
|
||||||
|
@ -254,7 +254,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void bt_peer_connection::on_metadata()
|
void bt_peer_connection::on_metadata()
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** ON_METADATA");
|
peer_log("*** ON_METADATA");
|
||||||
#endif
|
#endif
|
||||||
// connections that are still in the handshake
|
// connections that are still in the handshake
|
||||||
|
@ -278,7 +278,7 @@ namespace libtorrent
|
||||||
|
|
||||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("==> DHT_PORT [ %d ]", listen_port);
|
peer_log("==> DHT_PORT [ %d ]", listen_port);
|
||||||
#endif
|
#endif
|
||||||
char msg[] = {0,0,0,3, msg_dht_port, 0, 0};
|
char msg[] = {0,0,0,3, msg_dht_port, 0, 0};
|
||||||
|
@ -294,7 +294,7 @@ namespace libtorrent
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
TORRENT_ASSERT(m_sent_handshake);
|
TORRENT_ASSERT(m_sent_handshake);
|
||||||
m_sent_bitfield = true;
|
m_sent_bitfield = true;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("==> HAVE_ALL");
|
peer_log("==> HAVE_ALL");
|
||||||
#endif
|
#endif
|
||||||
char msg[] = {0,0,0,1, msg_have_all};
|
char msg[] = {0,0,0,1, msg_have_all};
|
||||||
|
@ -308,7 +308,7 @@ namespace libtorrent
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
TORRENT_ASSERT(m_sent_handshake);
|
TORRENT_ASSERT(m_sent_handshake);
|
||||||
m_sent_bitfield = true;
|
m_sent_bitfield = true;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("==> HAVE_NONE");
|
peer_log("==> HAVE_NONE");
|
||||||
#endif
|
#endif
|
||||||
char msg[] = {0,0,0,1, msg_have_none};
|
char msg[] = {0,0,0,1, msg_have_none};
|
||||||
|
@ -325,7 +325,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!m_supports_fast) return;
|
if (!m_supports_fast) return;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("==> REJECT_PIECE [ piece: %d | s: %d | l: %d ]"
|
peer_log("==> REJECT_PIECE [ piece: %d | s: %d | l: %d ]"
|
||||||
, r.piece, r.start, r.length);
|
, r.piece, r.start, r.length);
|
||||||
#endif
|
#endif
|
||||||
|
@ -371,7 +371,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(t);
|
TORRENT_ASSERT(t);
|
||||||
TORRENT_ASSERT(t->valid_metadata());
|
TORRENT_ASSERT(t->valid_metadata());
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("==> SUGGEST [ piece: %d num_peers: %d ]", piece
|
peer_log("==> SUGGEST [ piece: %d num_peers: %d ]", piece
|
||||||
, t->has_picker() ? t->picker().get_availability(piece) : -1);
|
, t->has_picker() ? t->picker().get_availability(piece) : -1);
|
||||||
#endif
|
#endif
|
||||||
|
@ -436,7 +436,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(!m_dh_key_exchange.get());
|
TORRENT_ASSERT(!m_dh_key_exchange.get());
|
||||||
TORRENT_ASSERT(!m_sent_handshake);
|
TORRENT_ASSERT(!m_sent_handshake);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
if (is_outgoing())
|
if (is_outgoing())
|
||||||
peer_log("*** initiating encrypted handshake");
|
peer_log("*** initiating encrypted handshake");
|
||||||
#endif
|
#endif
|
||||||
|
@ -450,7 +450,7 @@ namespace libtorrent
|
||||||
|
|
||||||
int pad_size = random() % 512;
|
int pad_size = random() % 512;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log(" pad size: %d", pad_size);
|
peer_log(" pad size: %d", pad_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ namespace libtorrent
|
||||||
std::generate(ptr, ptr + pad_size, random_byte);
|
std::generate(ptr, ptr + pad_size, random_byte);
|
||||||
send_buffer(msg, buf_size);
|
send_buffer(msg, buf_size);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log(" sent DH key");
|
peer_log(" sent DH key");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ namespace libtorrent
|
||||||
if ((crypto_provide & settings_pack::pe_both) == 0)
|
if ((crypto_provide & settings_pack::pe_both) == 0)
|
||||||
crypto_provide = settings_pack::pe_both;
|
crypto_provide = settings_pack::pe_both;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
char const* level[] = {"plaintext", "rc4", "plaintext rc4"};
|
char const* level[] = {"plaintext", "rc4", "plaintext rc4"};
|
||||||
peer_log(" crypto provide : [ %s ]"
|
peer_log(" crypto provide : [ %s ]"
|
||||||
, level[crypto_provide-1]);
|
, level[crypto_provide-1]);
|
||||||
|
@ -568,7 +568,7 @@ namespace libtorrent
|
||||||
else // 0x01
|
else // 0x01
|
||||||
m_rc4_encrypted = false;
|
m_rc4_encrypted = false;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log(" crypto select : [ %s ]"
|
peer_log(" crypto select : [ %s ]"
|
||||||
, (crypto_select == 0x01) ? "plaintext" : "rc4");
|
, (crypto_select == 0x01) ? "plaintext" : "rc4");
|
||||||
#endif
|
#endif
|
||||||
|
@ -645,7 +645,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log(" computed RC4 keys");
|
peer_log(" computed RC4 keys");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -777,7 +777,7 @@ namespace libtorrent
|
||||||
// we support FAST extension
|
// we support FAST extension
|
||||||
*(ptr + 7) |= 0x04;
|
*(ptr + 7) |= 0x04;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
std::string bitmask;
|
std::string bitmask;
|
||||||
for (int k = 0; k < 8; ++k)
|
for (int k = 0; k < 8; ++k)
|
||||||
{
|
{
|
||||||
|
@ -808,7 +808,7 @@ namespace libtorrent
|
||||||
memcpy(ptr, &m_our_peer_id[0], 20);
|
memcpy(ptr, &m_our_peer_id[0], 20);
|
||||||
ptr += 20;
|
ptr += 20;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
{
|
{
|
||||||
char hex_pid[41];
|
char hex_pid[41];
|
||||||
to_hex((char const*)&m_our_peer_id[0], 20, hex_pid);
|
to_hex((char const*)&m_our_peer_id[0], 20, hex_pid);
|
||||||
|
@ -891,7 +891,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== KEEPALIVE");
|
peer_log("<== KEEPALIVE");
|
||||||
#endif
|
#endif
|
||||||
incoming_keepalive();
|
incoming_keepalive();
|
||||||
|
@ -1231,7 +1231,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (recv_pos < header_size) return;
|
if (recv_pos < header_size) return;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
// peer_log("<== PIECE_FRAGMENT p: %d start: %d length: %d"
|
// peer_log("<== PIECE_FRAGMENT p: %d start: %d length: %d"
|
||||||
// , p.piece, p.start, p.length);
|
// , p.piece, p.start, p.length);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1251,7 +1251,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (merkle && list_size > 0)
|
if (merkle && list_size > 0)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== HASHPIECE [ piece: %d list: %d ]", p.piece, list_size);
|
peer_log("<== HASHPIECE [ piece: %d list: %d ]", p.piece, list_size);
|
||||||
#endif
|
#endif
|
||||||
lazy_entry hash_list;
|
lazy_entry hash_list;
|
||||||
|
@ -1502,7 +1502,7 @@ namespace libtorrent
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
error_code ec;
|
error_code ec;
|
||||||
static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"};
|
static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"};
|
||||||
peer_log("<== HOLEPUNCH [ msg: %s from %s to: unknown address type ]"
|
peer_log("<== HOLEPUNCH [ msg: %s from %s to: unknown address type ]"
|
||||||
|
@ -1520,7 +1520,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
case hp_rendezvous: // rendezvous
|
case hp_rendezvous: // rendezvous
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
peer_log("<== HOLEPUNCH [ msg: rendezvous to: %s ]"
|
peer_log("<== HOLEPUNCH [ msg: rendezvous to: %s ]"
|
||||||
, print_address(ep.address()).c_str());
|
, print_address(ep.address()).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1554,7 +1554,7 @@ namespace libtorrent
|
||||||
torrent_peer* p = t->add_peer(ep, peer_info::pex);
|
torrent_peer* p = t->add_peer(ep, peer_info::pex);
|
||||||
if (p == 0 || p->connection)
|
if (p == 0 || p->connection)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
peer_log("<== HOLEPUNCH [ msg:connect to: %s error: failed to add peer ]"
|
peer_log("<== HOLEPUNCH [ msg:connect to: %s error: failed to add peer ]"
|
||||||
, print_address(ep.address()).c_str());
|
, print_address(ep.address()).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1564,7 +1564,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
if (p->banned)
|
if (p->banned)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
peer_log("<== HOLEPUNCH [ msg:connect to: %s error: peer banned ]"
|
peer_log("<== HOLEPUNCH [ msg:connect to: %s error: peer banned ]"
|
||||||
, print_address(ep.address()).c_str());
|
, print_address(ep.address()).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1583,7 +1583,7 @@ namespace libtorrent
|
||||||
t->update_want_peers();
|
t->update_want_peers();
|
||||||
if (p->connection)
|
if (p->connection)
|
||||||
p->connection->set_holepunch_mode();
|
p->connection->set_holepunch_mode();
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
peer_log("<== HOLEPUNCH [ msg:connect to: %s ]"
|
peer_log("<== HOLEPUNCH [ msg:connect to: %s ]"
|
||||||
, print_address(ep.address()).c_str());
|
, print_address(ep.address()).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1591,7 +1591,7 @@ namespace libtorrent
|
||||||
case hp_failed:
|
case hp_failed:
|
||||||
{
|
{
|
||||||
boost::uint32_t error = detail::read_uint32(ptr);
|
boost::uint32_t error = detail::read_uint32(ptr);
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
error_code ec;
|
error_code ec;
|
||||||
char const* err_msg[] = {"no such peer", "not connected", "no support", "no self"};
|
char const* err_msg[] = {"no such peer", "not connected", "no support", "no self"};
|
||||||
peer_log("<== HOLEPUNCH [ msg:failed error: %d msg: %s ]", error
|
peer_log("<== HOLEPUNCH [ msg:failed error: %d msg: %s ]", error
|
||||||
|
@ -1600,7 +1600,7 @@ namespace libtorrent
|
||||||
// #error deal with holepunch errors
|
// #error deal with holepunch errors
|
||||||
(void)error;
|
(void)error;
|
||||||
} break;
|
} break;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
error_code ec;
|
error_code ec;
|
||||||
|
@ -1620,7 +1620,7 @@ namespace libtorrent
|
||||||
else detail::write_uint8(1, ptr);
|
else detail::write_uint8(1, ptr);
|
||||||
detail::write_endpoint(ep, ptr);
|
detail::write_endpoint(ep, ptr);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
error_code ec;
|
error_code ec;
|
||||||
static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"};
|
static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"};
|
||||||
static const char* hp_error_string[] = {"", "no such peer", "not connected", "no support", "no self"};
|
static const char* hp_error_string[] = {"", "no such peer", "not connected", "no support", "no self"};
|
||||||
|
@ -1691,13 +1691,13 @@ namespace libtorrent
|
||||||
if (!m_recv_buffer.packet_finished()) return;
|
if (!m_recv_buffer.packet_finished()) return;
|
||||||
if (m_recv_buffer.packet_size() != 3)
|
if (m_recv_buffer.packet_size() != 3)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== UPLOAD_ONLY [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
|
peer_log("<== UPLOAD_ONLY [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool ul = detail::read_uint8(recv_buffer.begin) != 0;
|
bool ul = detail::read_uint8(recv_buffer.begin) != 0;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== UPLOAD_ONLY [ %s ]", (ul?"true":"false"));
|
peer_log("<== UPLOAD_ONLY [ %s ]", (ul?"true":"false"));
|
||||||
#endif
|
#endif
|
||||||
set_upload_only(ul);
|
set_upload_only(ul);
|
||||||
|
@ -1709,13 +1709,13 @@ namespace libtorrent
|
||||||
if (!m_recv_buffer.packet_finished()) return;
|
if (!m_recv_buffer.packet_finished()) return;
|
||||||
if (m_recv_buffer.packet_size() != 3)
|
if (m_recv_buffer.packet_size() != 3)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== SHARE_MODE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
|
peer_log("<== SHARE_MODE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool sm = detail::read_uint8(recv_buffer.begin) != 0;
|
bool sm = detail::read_uint8(recv_buffer.begin) != 0;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== SHARE_MODE [ %s ]", (sm?"true":"false"));
|
peer_log("<== SHARE_MODE [ %s ]", (sm?"true":"false"));
|
||||||
#endif
|
#endif
|
||||||
set_share_mode(sm);
|
set_share_mode(sm);
|
||||||
|
@ -1725,7 +1725,7 @@ namespace libtorrent
|
||||||
if (extended_id == holepunch_msg)
|
if (extended_id == holepunch_msg)
|
||||||
{
|
{
|
||||||
if (!m_recv_buffer.packet_finished()) return;
|
if (!m_recv_buffer.packet_finished()) return;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== HOLEPUNCH");
|
peer_log("<== HOLEPUNCH");
|
||||||
#endif
|
#endif
|
||||||
on_holepunch();
|
on_holepunch();
|
||||||
|
@ -1737,7 +1737,7 @@ namespace libtorrent
|
||||||
if (!m_recv_buffer.packet_finished()) return;
|
if (!m_recv_buffer.packet_finished()) return;
|
||||||
if (m_recv_buffer.packet_size() != 6)
|
if (m_recv_buffer.packet_size() != 6)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== DONT_HAVE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
|
peer_log("<== DONT_HAVE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -1747,7 +1747,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
if (m_recv_buffer.packet_finished())
|
if (m_recv_buffer.packet_finished())
|
||||||
peer_log("<== EXTENSION MESSAGE [ msg: %d size: %d ]"
|
peer_log("<== EXTENSION MESSAGE [ msg: %d size: %d ]"
|
||||||
, extended_id, m_recv_buffer.packet_size());
|
, extended_id, m_recv_buffer.packet_size());
|
||||||
|
@ -1780,14 +1780,14 @@ namespace libtorrent
|
||||||
int ret = lazy_bdecode(recv_buffer.begin + 2, recv_buffer.end, root, ec, &pos);
|
int ret = lazy_bdecode(recv_buffer.begin + 2, recv_buffer.end, root, ec, &pos);
|
||||||
if (ret != 0 || ec || root.type() != lazy_entry::dict_t)
|
if (ret != 0 || ec || root.type() != lazy_entry::dict_t)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** invalid extended handshake: %s pos: %d"
|
peer_log("*** invalid extended handshake: %s pos: %d"
|
||||||
, ec.message().c_str(), pos);
|
, ec.message().c_str(), pos);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== EXTENDED HANDSHAKE: %s", print_entry(root).c_str());
|
peer_log("<== EXTENDED HANDSHAKE: %s", print_entry(root).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1972,7 +1972,7 @@ namespace libtorrent
|
||||||
// connections, don't sent upload-only
|
// connections, don't sent upload-only
|
||||||
if (!m_settings.get_bool(settings_pack::close_redundant_connections)) return;
|
if (!m_settings.get_bool(settings_pack::close_redundant_connections)) return;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("==> UPLOAD_ONLY [ %d ]"
|
peer_log("==> UPLOAD_ONLY [ %d ]"
|
||||||
, int(t->is_upload_only() && !t->super_seeding()));
|
, int(t->is_upload_only() && !t->super_seeding()));
|
||||||
#endif
|
#endif
|
||||||
|
@ -2073,7 +2073,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (t->super_seeding())
|
if (t->super_seeding())
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log(" *** NOT SENDING BITFIELD, super seeding");
|
peer_log(" *** NOT SENDING BITFIELD, super seeding");
|
||||||
#endif
|
#endif
|
||||||
if (m_supports_fast) write_have_none();
|
if (m_supports_fast) write_have_none();
|
||||||
|
@ -2104,7 +2104,7 @@ namespace libtorrent
|
||||||
else if (t->num_have() == 0)
|
else if (t->num_have() == 0)
|
||||||
{
|
{
|
||||||
// don't send a bitfield if we don't have any pieces
|
// don't send a bitfield if we don't have any pieces
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log(" *** NOT SENDING BITFIELD");
|
peer_log(" *** NOT SENDING BITFIELD");
|
||||||
#endif
|
#endif
|
||||||
m_sent_bitfield = true;
|
m_sent_bitfield = true;
|
||||||
|
@ -2175,7 +2175,7 @@ namespace libtorrent
|
||||||
, end(t->predictive_pieces().end()); i != end; ++i)
|
, end(t->predictive_pieces().end()); i != end; ++i)
|
||||||
msg[5 + *i / 8] |= (0x80 >> (*i & 7));
|
msg[5 + *i / 8] |= (0x80 >> (*i & 7));
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
|
|
||||||
std::string bitfield_string;
|
std::string bitfield_string;
|
||||||
bitfield_string.resize(num_pieces);
|
bitfield_string.resize(num_pieces);
|
||||||
|
@ -2196,7 +2196,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
for (int i = 0; i < num_lazy_pieces; ++i)
|
for (int i = 0; i < num_lazy_pieces; ++i)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("==> HAVE [ piece: %d ]", lazy_pieces[i]);
|
peer_log("==> HAVE [ piece: %d ]", lazy_pieces[i]);
|
||||||
#endif
|
#endif
|
||||||
write_have(lazy_pieces[i]);
|
write_have(lazy_pieces[i]);
|
||||||
|
@ -2312,7 +2312,7 @@ namespace libtorrent
|
||||||
|
|
||||||
stats_counters().inc_stats_counter(counters::num_outgoing_ext_handshake);
|
stats_counters().inc_stats_counter(counters::num_outgoing_ext_handshake);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
peer_log("==> EXTENDED HANDSHAKE: %s", handshake.to_string().c_str());
|
peer_log("==> EXTENDED HANDSHAKE: %s", handshake.to_string().c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2526,7 +2526,7 @@ namespace libtorrent
|
||||||
if (!m_enc_handler.is_recv_plaintext())
|
if (!m_enc_handler.is_recv_plaintext())
|
||||||
{
|
{
|
||||||
int consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred);
|
int consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred);
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
if (consumed + bytes_transferred > 0)
|
if (consumed + bytes_transferred > 0)
|
||||||
peer_log("<== decrypted block [ s = %d ]", consumed + bytes_transferred);
|
peer_log("<== decrypted block [ s = %d ]", consumed + bytes_transferred);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2598,7 +2598,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** received DH key");
|
peer_log("*** received DH key");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2697,7 +2697,7 @@ namespace libtorrent
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::size_t bytes_processed = syncoffset + 20;
|
std::size_t bytes_processed = syncoffset + 20;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** sync point (hash) found at offset %d"
|
peer_log("*** sync point (hash) found at offset %d"
|
||||||
, m_sync_bytes_read + bytes_processed - 20);
|
, m_sync_bytes_read + bytes_processed - 20);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2746,7 +2746,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
init_pe_rc4_handler(m_dh_key_exchange->get_secret(), ti->info_hash());
|
init_pe_rc4_handler(m_dh_key_exchange->get_secret(), ti->info_hash());
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** stream key found, torrent located");
|
peer_log("*** stream key found, torrent located");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2769,7 +2769,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** verification constant found");
|
peer_log("*** verification constant found");
|
||||||
#endif
|
#endif
|
||||||
m_state = read_pe_cryptofield;
|
m_state = read_pe_cryptofield;
|
||||||
|
@ -2833,7 +2833,7 @@ namespace libtorrent
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::size_t bytes_processed = syncoffset + 8;
|
std::size_t bytes_processed = syncoffset + 8;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** sync point (verification constant) found at offset %d"
|
peer_log("*** sync point (verification constant) found at offset %d"
|
||||||
, m_sync_bytes_read + bytes_processed - 8);
|
, m_sync_bytes_read + bytes_processed - 8);
|
||||||
#endif
|
#endif
|
||||||
|
@ -2868,7 +2868,7 @@ namespace libtorrent
|
||||||
|
|
||||||
boost::uint32_t crypto_field = detail::read_uint32(recv_buffer.begin);
|
boost::uint32_t crypto_field = detail::read_uint32(recv_buffer.begin);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** crypto %s : [%s%s ]"
|
peer_log("*** crypto %s : [%s%s ]"
|
||||||
, is_outgoing() ? "select" : "provide"
|
, is_outgoing() ? "select" : "provide"
|
||||||
, (crypto_field & 1) ? " plaintext" : ""
|
, (crypto_field & 1) ? " plaintext" : ""
|
||||||
|
@ -2982,7 +2982,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** len(IA) : %d", len_ia);
|
peer_log("*** len(IA) : %d", len_ia);
|
||||||
#endif
|
#endif
|
||||||
if (len_ia == 0)
|
if (len_ia == 0)
|
||||||
|
@ -3028,7 +3028,7 @@ namespace libtorrent
|
||||||
buffer::interval wr_buf = m_recv_buffer.mutable_buffer();
|
buffer::interval wr_buf = m_recv_buffer.mutable_buffer();
|
||||||
rc4_decrypt(wr_buf.begin, m_recv_buffer.packet_size());
|
rc4_decrypt(wr_buf.begin, m_recv_buffer.packet_size());
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** decrypted ia : %d bytes", m_recv_buffer.packet_size());
|
peer_log("*** decrypted ia : %d bytes", m_recv_buffer.packet_size());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3077,7 +3077,7 @@ namespace libtorrent
|
||||||
wr_buf.begin += m_recv_buffer.packet_size();
|
wr_buf.begin += m_recv_buffer.packet_size();
|
||||||
rc4_decrypt(wr_buf.begin, wr_buf.left());
|
rc4_decrypt(wr_buf.begin, wr_buf.left());
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** decrypted remaining %d bytes", wr_buf.left());
|
peer_log("*** decrypted remaining %d bytes", wr_buf.left());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -3118,14 +3118,14 @@ namespace libtorrent
|
||||||
memcmp(recv_buffer.begin, protocol_string, 20) != 0)
|
memcmp(recv_buffer.begin, protocol_string, 20) != 0)
|
||||||
{
|
{
|
||||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** unrecognized protocol header");
|
peer_log("*** unrecognized protocol header");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TORRENT_USE_OPENSSL
|
#ifdef TORRENT_USE_OPENSSL
|
||||||
if (is_ssl(*get_socket()))
|
if (is_ssl(*get_socket()))
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** SSL peers are not allowed to use any other encryption");
|
peer_log("*** SSL peers are not allowed to use any other encryption");
|
||||||
#endif
|
#endif
|
||||||
disconnect(errors::invalid_info_hash, op_bittorrent, 1);
|
disconnect(errors::invalid_info_hash, op_bittorrent, 1);
|
||||||
|
@ -3151,7 +3151,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** attempting encrypted connection");
|
peer_log("*** attempting encrypted connection");
|
||||||
#endif
|
#endif
|
||||||
m_state = read_pe_dhkey;
|
m_state = read_pe_dhkey;
|
||||||
|
@ -3179,7 +3179,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== BitTorrent protocol");
|
peer_log("<== BitTorrent protocol");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -3199,7 +3199,7 @@ namespace libtorrent
|
||||||
recv_buffer = m_recv_buffer.get();
|
recv_buffer = m_recv_buffer.get();
|
||||||
|
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
std::string extensions;
|
std::string extensions;
|
||||||
extensions.resize(8 * 8);
|
extensions.resize(8 * 8);
|
||||||
for (int i=0; i < 8; ++i)
|
for (int i=0; i < 8; ++i)
|
||||||
|
@ -3255,14 +3255,14 @@ namespace libtorrent
|
||||||
if (!std::equal(recv_buffer.begin + 8, recv_buffer.begin + 28
|
if (!std::equal(recv_buffer.begin + 8, recv_buffer.begin + 28
|
||||||
, (const char*)t->torrent_file().info_hash().begin()))
|
, (const char*)t->torrent_file().info_hash().begin()))
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** received invalid info_hash");
|
peer_log("*** received invalid info_hash");
|
||||||
#endif
|
#endif
|
||||||
disconnect(errors::invalid_info_hash, op_bittorrent, 1);
|
disconnect(errors::invalid_info_hash, op_bittorrent, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<<< info_hash received");
|
peer_log("<<< info_hash received");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -3298,7 +3298,7 @@ namespace libtorrent
|
||||||
if (!m_recv_buffer.packet_finished()) return;
|
if (!m_recv_buffer.packet_finished()) return;
|
||||||
recv_buffer = m_recv_buffer.get();
|
recv_buffer = m_recv_buffer.get();
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
{
|
{
|
||||||
char hex_pid[41];
|
char hex_pid[41];
|
||||||
to_hex(recv_buffer.begin, 20, hex_pid);
|
to_hex(recv_buffer.begin, 20, hex_pid);
|
||||||
|
@ -3380,7 +3380,7 @@ namespace libtorrent
|
||||||
if (m_supports_extensions) write_extensions();
|
if (m_supports_extensions) write_extensions();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("<== HANDSHAKE");
|
peer_log("<== HANDSHAKE");
|
||||||
#endif
|
#endif
|
||||||
// consider this a successful connection, reset the failcount
|
// consider this a successful connection, reset the failcount
|
||||||
|
@ -3496,7 +3496,7 @@ namespace libtorrent
|
||||||
int bt_peer_connection::hit_send_barrier(std::vector<asio::mutable_buffer>& iovec)
|
int bt_peer_connection::hit_send_barrier(std::vector<asio::mutable_buffer>& iovec)
|
||||||
{
|
{
|
||||||
int next_barrier = m_enc_handler.encrypt(iovec);
|
int next_barrier = m_enc_handler.encrypt(iovec);
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
if (next_barrier != 0)
|
if (next_barrier != 0)
|
||||||
peer_log("==> encrypted block [ s = %d ]", next_barrier);
|
peer_log("==> encrypted block [ s = %d ]", next_barrier);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace libtorrent
|
||||||
|
|
||||||
prefer_whole_pieces(1);
|
prefer_whole_pieces(1);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** http_seed_connection");
|
peer_log("*** http_seed_connection");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ namespace libtorrent
|
||||||
request += "\r\n\r\n";
|
request += "\r\n\r\n";
|
||||||
m_first_request = false;
|
m_first_request = false;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("==> %s", request.c_str());
|
peer_log("==> %s", request.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ namespace libtorrent
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
received_bytes(0, bytes_transferred);
|
received_bytes(0, bytes_transferred);
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** http_seed_connection error: %s", error.message().c_str());
|
peer_log("*** http_seed_connection error: %s", error.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -376,7 +376,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size);
|
peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size);
|
||||||
#endif
|
#endif
|
||||||
TORRENT_ASSERT(bytes_transferred >= size_t(header_size - m_partial_chunk_header));
|
TORRENT_ASSERT(bytes_transferred >= size_t(header_size - m_partial_chunk_header));
|
||||||
|
@ -414,7 +414,7 @@ namespace libtorrent
|
||||||
|
|
||||||
int retry_time = atol(std::string(recv_buffer.begin, recv_buffer.end).c_str());
|
int retry_time = atol(std::string(recv_buffer.begin, recv_buffer.end).c_str());
|
||||||
if (retry_time <= 0) retry_time = 60;
|
if (retry_time <= 0) retry_time = 60;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** retrying in %d seconds", retry_time);
|
peer_log("*** retrying in %d seconds", retry_time);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ namespace libtorrent
|
||||||
// the url + 100 estimated header size
|
// the url + 100 estimated header size
|
||||||
sent_bytes(url.size() + 100);
|
sent_bytes(url.size() + 100);
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
|
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
if (cb)
|
if (cb)
|
||||||
|
@ -274,7 +274,7 @@ namespace libtorrent
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
if (cb)
|
if (cb)
|
||||||
{
|
{
|
||||||
|
|
237
src/logger.cpp
237
src/logger.cpp
|
@ -1,237 +0,0 @@
|
||||||
/*
|
|
||||||
|
|
||||||
Copyright (c) 2006-2014, Arvid Norberg
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions
|
|
||||||
are met:
|
|
||||||
|
|
||||||
* Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer.
|
|
||||||
* Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions and the following disclaimer in
|
|
||||||
the documentation and/or other materials provided with the distribution.
|
|
||||||
* Neither the name of the author nor the names of its
|
|
||||||
contributors may be used to endorse or promote products derived
|
|
||||||
from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
||||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(push, 1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "libtorrent/extensions/logger.hpp"
|
|
||||||
#include "libtorrent/extensions.hpp"
|
|
||||||
#include "libtorrent/entry.hpp"
|
|
||||||
#include "libtorrent/peer_request.hpp"
|
|
||||||
|
|
||||||
#if TORRENT_USE_IOSTREAM && !defined TORRENT_DISABLE_EXTENSIONS
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include "libtorrent/file.hpp"
|
|
||||||
#include "libtorrent/time.hpp"
|
|
||||||
#include "libtorrent/lazy_entry.hpp"
|
|
||||||
#include "libtorrent/peer_connection.hpp"
|
|
||||||
|
|
||||||
namespace libtorrent {
|
|
||||||
|
|
||||||
class peer_connection;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
struct logger_peer_plugin : peer_plugin
|
|
||||||
{
|
|
||||||
logger_peer_plugin(std::string const& filename)
|
|
||||||
{
|
|
||||||
error_code ec;
|
|
||||||
std::string dir = complete("libtorrent_ext_logs");
|
|
||||||
if (!exists(dir)) create_directories(dir, ec);
|
|
||||||
m_file.open(combine_path(dir, filename).c_str(), std::ios_base::out);
|
|
||||||
m_file << "\n\n\n";
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "*** starting log ***\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void log_timestamp()
|
|
||||||
{
|
|
||||||
m_file << time_now_string() << ": ";
|
|
||||||
}
|
|
||||||
|
|
||||||
// can add entries to the extension handshake
|
|
||||||
virtual void add_handshake(entry&) {}
|
|
||||||
|
|
||||||
// called when the extension handshake from the other end is received
|
|
||||||
virtual bool on_extension_handshake(lazy_entry const& h)
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== EXTENSION_HANDSHAKE\n" << print_entry(h);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// returning true from any of the message handlers
|
|
||||||
// indicates that the plugin has handeled the message.
|
|
||||||
// it will break the plugin chain traversing and not let
|
|
||||||
// anyone else handle the message, including the default
|
|
||||||
// handler.
|
|
||||||
|
|
||||||
virtual bool on_choke()
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== CHOKE\n";
|
|
||||||
m_file.flush();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool on_unchoke()
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== UNCHOKE\n";
|
|
||||||
m_file.flush();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool on_interested()
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== INTERESTED\n";
|
|
||||||
m_file.flush();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool on_not_interested()
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== NOT_INTERESTED\n";
|
|
||||||
m_file.flush();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool on_have(int index)
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== HAVE [" << index << "]\n";
|
|
||||||
m_file.flush();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool on_bitfield(bitfield const& bitfield_)
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== BITFIELD\n";
|
|
||||||
m_file.flush();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool on_request(peer_request const& r)
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== REQUEST [ piece: " << r.piece << " | s: " << r.start
|
|
||||||
<< " | l: " << r.length << " ]\n";
|
|
||||||
m_file.flush();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool on_piece(peer_request const& r, disk_buffer_holder& data)
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== PIECE [ piece: " << r.piece << " | s: " << r.start
|
|
||||||
<< " | l: " << r.length << " ]\n";
|
|
||||||
m_file.flush();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool on_cancel(peer_request const& r)
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== CANCEL [ piece: " << r.piece << " | s: " << r.start
|
|
||||||
<< " | l: " << r.length << " ]\n";
|
|
||||||
m_file.flush();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// called when an extended message is received. If returning true,
|
|
||||||
// the message is not processed by any other plugin and if false
|
|
||||||
// is returned the next plugin in the chain will receive it to
|
|
||||||
// be able to handle it
|
|
||||||
virtual bool on_extended(int length
|
|
||||||
, int msg, buffer::const_interval body)
|
|
||||||
{ return false; }
|
|
||||||
|
|
||||||
virtual bool on_unknown_message(int length, int msg
|
|
||||||
, buffer::const_interval body)
|
|
||||||
{
|
|
||||||
if (body.left() < length) return false;
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "<== UNKNOWN [ msg: " << msg
|
|
||||||
<< " | l: " << length << " ]\n";
|
|
||||||
m_file.flush();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void on_piece_pass(int index)
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "*** HASH PASSED *** [ piece: " << index << " ]\n";
|
|
||||||
m_file.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void on_piece_failed(int index)
|
|
||||||
{
|
|
||||||
log_timestamp();
|
|
||||||
m_file << "*** HASH FAILED *** [ piece: " << index << " ]\n";
|
|
||||||
m_file.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::ofstream m_file;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct logger_plugin : torrent_plugin
|
|
||||||
{
|
|
||||||
virtual boost::shared_ptr<peer_plugin> new_connection(
|
|
||||||
peer_connection* pc)
|
|
||||||
{
|
|
||||||
error_code ec;
|
|
||||||
return boost::shared_ptr<peer_plugin>(new logger_peer_plugin(
|
|
||||||
pc->remote().address().to_string(ec) + "_"
|
|
||||||
+ to_string(pc->remote().port()).elems + ".log"));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} }
|
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
|
||||||
|
|
||||||
boost::shared_ptr<torrent_plugin> create_logger_plugin(torrent*)
|
|
||||||
{
|
|
||||||
return boost::shared_ptr<torrent_plugin>(new logger_plugin());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
27
src/lsd.cpp
27
src/lsd.cpp
|
@ -80,7 +80,8 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb)
|
||||||
, m_disabled6(false)
|
, m_disabled6(false)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
|
// TODO: instead if writing to a file, post alerts. Or call a log callback
|
||||||
m_log = fopen("lsd.log", "w+");
|
m_log = fopen("lsd.log", "w+");
|
||||||
if (m_log == NULL)
|
if (m_log == NULL)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +93,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb)
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_socket.open(ios, ec);
|
m_socket.open(ios, ec);
|
||||||
|
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
if (m_log) fprintf(m_log, "FAILED TO OPEN SOCKET: (%d) %s\n"
|
if (m_log) fprintf(m_log, "FAILED TO OPEN SOCKET: (%d) %s\n"
|
||||||
|
@ -102,7 +103,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb)
|
||||||
|
|
||||||
#if TORRENT_USE_IPV6
|
#if TORRENT_USE_IPV6
|
||||||
m_socket6.open(ios, ec);
|
m_socket6.open(ios, ec);
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
if (m_log) fprintf(m_log, "FAILED TO OPEN SOCKET6: (%d) %s\n"
|
if (m_log) fprintf(m_log, "FAILED TO OPEN SOCKET6: (%d) %s\n"
|
||||||
|
@ -114,7 +115,7 @@ lsd::lsd(io_service& ios, peer_callback_t const& cb)
|
||||||
|
|
||||||
lsd::~lsd()
|
lsd::~lsd()
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (m_log) fclose(m_log);
|
if (m_log) fclose(m_log);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -149,7 +150,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
|
||||||
to_hex((char const*)&ih[0], 20, ih_hex);
|
to_hex((char const*)&ih[0], 20, ih_hex);
|
||||||
char msg[200];
|
char msg[200];
|
||||||
|
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (m_log) fprintf(m_log, "%s ==> announce: ih: %s port: %u\n"
|
if (m_log) fprintf(m_log, "%s ==> announce: ih: %s port: %u\n"
|
||||||
, time_now_string(), ih_hex, listen_port);
|
, time_now_string(), ih_hex, listen_port);
|
||||||
#endif
|
#endif
|
||||||
|
@ -163,7 +164,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
m_disabled = true;
|
m_disabled = true;
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (m_log) fprintf(m_log, "%s failed to send message: (%d) %s"
|
if (m_log) fprintf(m_log, "%s failed to send message: (%d) %s"
|
||||||
, time_now_string(), ec.value(), ec.message().c_str());
|
, time_now_string(), ec.value(), ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -179,7 +180,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
m_disabled6 = true;
|
m_disabled6 = true;
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (m_log) fprintf(m_log, "%s failed to send message6: (%d) %s"
|
if (m_log) fprintf(m_log, "%s failed to send message6: (%d) %s"
|
||||||
, time_now_string(), ec.value(), ec.message().c_str());
|
, time_now_string(), ec.value(), ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -228,7 +229,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
|
||||||
|
|
||||||
if (!p.header_finished() || error)
|
if (!p.header_finished() || error)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (m_log) fprintf(m_log, "%s <== announce: incomplete HTTP message\n", time_now_string());
|
if (m_log) fprintf(m_log, "%s <== announce: incomplete HTTP message\n", time_now_string());
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -236,7 +237,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
|
||||||
|
|
||||||
if (p.method() != "bt-search")
|
if (p.method() != "bt-search")
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (m_log) fprintf(m_log, "%s <== announce: invalid HTTP method: %s\n"
|
if (m_log) fprintf(m_log, "%s <== announce: invalid HTTP method: %s\n"
|
||||||
, time_now_string(), p.method().c_str());
|
, time_now_string(), p.method().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -246,7 +247,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
|
||||||
std::string const& port_str = p.header("port");
|
std::string const& port_str = p.header("port");
|
||||||
if (port_str.empty())
|
if (port_str.empty())
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (m_log) fprintf(m_log, "%s <== announce: invalid BT-SEARCH, missing port\n"
|
if (m_log) fprintf(m_log, "%s <== announce: invalid BT-SEARCH, missing port\n"
|
||||||
, time_now_string());
|
, time_now_string());
|
||||||
#endif
|
#endif
|
||||||
|
@ -266,7 +267,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
|
||||||
boost::int32_t cookie = strtol(cookie_iter->second.c_str(), NULL, 16);
|
boost::int32_t cookie = strtol(cookie_iter->second.c_str(), NULL, 16);
|
||||||
if (cookie == m_cookie)
|
if (cookie == m_cookie)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (m_log) fprintf(m_log, "%s <== announce: ignoring packet (cookie matched our own): %x == %x\n"
|
if (m_log) fprintf(m_log, "%s <== announce: ignoring packet (cookie matched our own): %x == %x\n"
|
||||||
, time_now_string(), cookie, m_cookie);
|
, time_now_string(), cookie, m_cookie);
|
||||||
#endif
|
#endif
|
||||||
|
@ -282,7 +283,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
|
||||||
std::string const& ih_str = i->second;
|
std::string const& ih_str = i->second;
|
||||||
if (ih_str.size() != 40)
|
if (ih_str.size() != 40)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (m_log) fprintf(m_log, "%s <== announce: invalid BT-SEARCH, invalid infohash: %s\n"
|
if (m_log) fprintf(m_log, "%s <== announce: invalid BT-SEARCH, invalid infohash: %s\n"
|
||||||
, time_now_string(), ih_str.c_str());
|
, time_now_string(), ih_str.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -294,7 +295,7 @@ void lsd::on_announce(udp::endpoint const& from, char* buffer
|
||||||
|
|
||||||
if (!ih.is_all_zeros() && port != 0)
|
if (!ih.is_all_zeros() && port != 0)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_LOGGING) || defined(TORRENT_VERBOSE_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (m_log) fprintf(m_log, "%s *** incoming local announce %s:%d ih: %s\n"
|
if (m_log) fprintf(m_log, "%s *** incoming local announce %s:%d ih: %s\n"
|
||||||
, time_now_string(), print_address(from.address()).c_str()
|
, time_now_string(), print_address(from.address()).c_str()
|
||||||
, port, ih_str.c_str());
|
, port, ih_str.c_str());
|
||||||
|
|
|
@ -210,27 +210,23 @@ namespace libtorrent { namespace
|
||||||
// invalid tex message
|
// invalid tex message
|
||||||
if (added == 0)
|
if (added == 0)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
(*m_pc.m_logger) << time_now_string() << " <== LT_TEX [ NOT A DICTIONARY ]\n";
|
m_pc.peer_log(" <== LT_TEX [ NOT A DICTIONARY ]");
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
|
||||||
std::stringstream log_line;
|
|
||||||
#endif
|
|
||||||
if (m_tp.num_tex_trackers() >= 50)
|
if (m_tp.num_tex_trackers() >= 50)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
log_line << time_now_string() << " <== LT_TEX [ "
|
m_pc.peer_log(" <== LT_TEX [ we already have %d trackers "
|
||||||
"we already have " << m_tp.num_tex_trackers() << " trackers "
|
"from tex, don't add any more", m_tp.num_tex_trackers());
|
||||||
"from tex, don't add any more";
|
|
||||||
(*m_pc.m_logger) << log_line.str();
|
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
|
std::stringstream log_line;
|
||||||
log_line << time_now_string() << " <== LT_TEX [ "
|
log_line << time_now_string() << " <== LT_TEX [ "
|
||||||
"added: ";
|
"added: ";
|
||||||
#endif
|
#endif
|
||||||
|
@ -264,7 +260,7 @@ namespace libtorrent { namespace
|
||||||
|
|
||||||
if (m_tp.num_tex_trackers() >= 50)
|
if (m_tp.num_tex_trackers() >= 50)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
log_line << "**reached-limit** ";
|
log_line << "**reached-limit** ";
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
@ -276,13 +272,13 @@ namespace libtorrent { namespace
|
||||||
if (m_torrent.add_tracker(e))
|
if (m_torrent.add_tracker(e))
|
||||||
m_tp.increment_tracker_counter();
|
m_tp.increment_tracker_counter();
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
log_line << e.url << " ";
|
log_line << e.url << " ";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
log_line << "]\n";
|
log_line << "]\n";
|
||||||
(*m_pc.m_logger) << log_line.str();
|
m_pc.peer_log("%s", log_line.str().c_str());
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -334,7 +330,7 @@ namespace libtorrent { namespace
|
||||||
if (!m_torrent.valid_metadata() || m_torrent.torrent_file().priv())
|
if (!m_torrent.valid_metadata() || m_torrent.torrent_file().priv())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
std::stringstream log_line;
|
std::stringstream log_line;
|
||||||
log_line << time_now_string() << " ==> LT_TEX [ "
|
log_line << time_now_string() << " ==> LT_TEX [ "
|
||||||
"added: ";
|
"added: ";
|
||||||
|
@ -346,16 +342,16 @@ namespace libtorrent { namespace
|
||||||
{
|
{
|
||||||
if (!send_tracker(*i)) continue;
|
if (!send_tracker(*i)) continue;
|
||||||
added.push_back(i->url);
|
added.push_back(i->url);
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
log_line << i->url << " ";
|
log_line << i->url << " ";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
std::vector<char> tex_msg;
|
std::vector<char> tex_msg;
|
||||||
bencode(std::back_inserter(tex_msg), tex);
|
bencode(std::back_inserter(tex_msg), tex);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
log_line << "]\n";
|
log_line << "]";
|
||||||
(*m_pc.m_logger) << log_line.str();
|
m_pc.peer_log("%s", log_line.str().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char msg[6];
|
char msg[6];
|
||||||
|
|
|
@ -304,7 +304,7 @@ namespace libtorrent { namespace
|
||||||
// abort if the peer doesn't support the metadata extension
|
// abort if the peer doesn't support the metadata extension
|
||||||
if (m_message_index == 0) return;
|
if (m_message_index == 0) return;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("==> METADATA_REQUEST [ start: %d | size: %d ]\n"
|
m_pc.peer_log("==> METADATA_REQUEST [ start: %d | size: %d ]\n"
|
||||||
, start, size);
|
, start, size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -342,7 +342,7 @@ namespace libtorrent { namespace
|
||||||
char msg[15];
|
char msg[15];
|
||||||
char* ptr = msg;
|
char* ptr = msg;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("==> METADATA [ start: %d | total_size: %d | offset: %d | data_size: %d ]"
|
m_pc.peer_log("==> METADATA [ start: %d | total_size: %d | offset: %d | data_size: %d ]"
|
||||||
, req.first, req.second, offset.first, offset.second);
|
, req.first, req.second, offset.first, offset.second);
|
||||||
#endif
|
#endif
|
||||||
|
@ -363,7 +363,7 @@ namespace libtorrent { namespace
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("==> DONT HAVE METADATA\n");
|
m_pc.peer_log("==> DONT HAVE METADATA\n");
|
||||||
#endif
|
#endif
|
||||||
char msg[4+3];
|
char msg[4+3];
|
||||||
|
@ -404,7 +404,7 @@ namespace libtorrent { namespace
|
||||||
int start = detail::read_uint8(body.begin);
|
int start = detail::read_uint8(body.begin);
|
||||||
int size = detail::read_uint8(body.begin) + 1;
|
int size = detail::read_uint8(body.begin) + 1;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("<== METADATA_REQUEST [ start: %d | size: %d ]\n"
|
m_pc.peer_log("<== METADATA_REQUEST [ start: %d | size: %d ]\n"
|
||||||
, start, size);
|
, start, size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -427,7 +427,7 @@ namespace libtorrent { namespace
|
||||||
int offset = detail::read_int32(body.begin);
|
int offset = detail::read_int32(body.begin);
|
||||||
int data_size = length - 9;
|
int data_size = length - 9;
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("<== METADATA [ total_size: %d | offset: %d | data_size: %d ]"
|
m_pc.peer_log("<== METADATA [ total_size: %d | offset: %d | data_size: %d ]"
|
||||||
,total_size, offset, data_size);
|
,total_size, offset, data_size);
|
||||||
#endif
|
#endif
|
||||||
|
@ -470,7 +470,7 @@ namespace libtorrent { namespace
|
||||||
if (m_waiting_metadata_request)
|
if (m_waiting_metadata_request)
|
||||||
m_tp.cancel_metadata_request(m_last_metadata_request);
|
m_tp.cancel_metadata_request(m_last_metadata_request);
|
||||||
m_waiting_metadata_request = false;
|
m_waiting_metadata_request = false;
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("<== DONT HAVE METADATA\n");
|
m_pc.peer_log("<== DONT HAVE METADATA\n");
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -65,7 +65,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/socket_io.hpp" // for print_endpoint
|
#include "libtorrent/socket_io.hpp" // for print_endpoint
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
#include "libtorrent/socket_io.hpp" // for print_endpoint
|
#include "libtorrent/socket_io.hpp" // for print_endpoint
|
||||||
#include "libtorrent/ip_voter.hpp" // for external_ip
|
#include "libtorrent/ip_voter.hpp" // for external_ip
|
||||||
#endif
|
#endif
|
||||||
|
@ -603,7 +603,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(i->connection != &c);
|
TORRENT_ASSERT(i->connection != &c);
|
||||||
TORRENT_ASSERT(i->address() == c.remote().address());
|
TORRENT_ASSERT(i->address() == c.remote().address());
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
c.peer_log("*** DUPLICATE PEER [ this: \"%s\" that: \"%s\" ]"
|
c.peer_log("*** DUPLICATE PEER [ this: \"%s\" that: \"%s\" ]"
|
||||||
, print_address(c.remote().address()).c_str()
|
, print_address(c.remote().address()).c_str()
|
||||||
, print_address(i->address()).c_str());
|
, print_address(i->address()).c_str());
|
||||||
|
@ -660,7 +660,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (our_port < other_port)
|
if (our_port < other_port)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
c.peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" < \"%d\" ]", our_port, other_port);
|
c.peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" < \"%d\" ]", our_port, other_port);
|
||||||
i->connection->peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" < \"%d\" ]", our_port, other_port);
|
i->connection->peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" < \"%d\" ]", our_port, other_port);
|
||||||
#endif
|
#endif
|
||||||
|
@ -678,7 +678,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
c.peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" >= \"%d\" ]", our_port, other_port);
|
c.peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" >= \"%d\" ]", our_port, other_port);
|
||||||
i->connection->peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" >= \"%d\" ]", our_port, other_port);
|
i->connection->peer_log("*** DUPLICATE PEER RESOLUTION [ \"%d\" >= \"%d\" ]", our_port, other_port);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace libtorrent
|
||||||
- (int)c.download_queue().size()
|
- (int)c.download_queue().size()
|
||||||
- (int)c.request_queue().size();
|
- (int)c.request_queue().size();
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
c.peer_log("*** PIECE_PICKER [ dlq: %d rqq: %d target: %d req: %d engame: %d ]"
|
c.peer_log("*** PIECE_PICKER [ dlq: %d rqq: %d target: %d req: %d engame: %d ]"
|
||||||
, int(c.download_queue().size()), int(c.request_queue().size())
|
, int(c.download_queue().size()), int(c.request_queue().size())
|
||||||
, c.desired_queue_size(), num_requests, c.endgame());
|
, c.desired_queue_size(), num_requests, c.endgame());
|
||||||
|
@ -167,7 +167,7 @@ namespace libtorrent
|
||||||
, state, c.picker_options(), suggested, t.num_peers()
|
, state, c.picker_options(), suggested, t.num_peers()
|
||||||
, ses.stats_counters());
|
, ses.stats_counters());
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
c.peer_log("*** PIECE_PICKER [ prefer_whole: %d picked: %d ]"
|
c.peer_log("*** PIECE_PICKER [ prefer_whole: %d picked: %d ]"
|
||||||
, prefer_whole_pieces, int(interesting_pieces.size()));
|
, prefer_whole_pieces, int(interesting_pieces.size()));
|
||||||
#endif
|
#endif
|
||||||
|
@ -232,7 +232,7 @@ namespace libtorrent
|
||||||
= std::find_if(dq.begin(), dq.end(), has_block(*i));
|
= std::find_if(dq.begin(), dq.end(), has_block(*i));
|
||||||
if (j != dq.end()) TORRENT_ASSERT(j->timed_out || j->not_wanted);
|
if (j != dq.end()) TORRENT_ASSERT(j->timed_out || j->not_wanted);
|
||||||
#endif
|
#endif
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
c.peer_log("*** PIECE_PICKER [ not_picking: %d,%d already in queue ]"
|
c.peer_log("*** PIECE_PICKER [ not_picking: %d,%d already in queue ]"
|
||||||
, i->piece_index, i->block_index);
|
, i->piece_index, i->block_index);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -404,14 +404,6 @@ namespace libtorrent
|
||||||
m_impl.reset(new session_impl(id));
|
m_impl.reset(new session_impl(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
void session::set_log_path(std::string const& p)
|
|
||||||
{
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING \
|
|
||||||
|| defined TORRENT_ERROR_LOGGING
|
|
||||||
m_impl->set_log_path(p);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void session::start(int flags, settings_pack const& pack)
|
void session::start(int flags, settings_pack const& pack)
|
||||||
{
|
{
|
||||||
#ifndef TORRENT_DISABLE_EXTENSIONS
|
#ifndef TORRENT_DISABLE_EXTENSIONS
|
||||||
|
@ -419,6 +411,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
add_extension(create_ut_pex_plugin);
|
add_extension(create_ut_pex_plugin);
|
||||||
add_extension(create_ut_metadata_plugin);
|
add_extension(create_ut_metadata_plugin);
|
||||||
|
// TODO: 3 lt_trackers should not be on by default
|
||||||
add_extension(create_lt_trackers_plugin);
|
add_extension(create_lt_trackers_plugin);
|
||||||
add_extension(create_smart_ban_plugin);
|
add_extension(create_smart_ban_plugin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,15 +95,13 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/torrent_peer.hpp"
|
#include "libtorrent/torrent_peer.hpp"
|
||||||
#include "libtorrent/choker.hpp"
|
#include "libtorrent/choker.hpp"
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
|
||||||
#include "libtorrent/socket_io.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_WINDOWS
|
#ifndef TORRENT_WINDOWS
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
|
|
||||||
|
#include "libtorrent/socket_io.hpp"
|
||||||
|
|
||||||
// for logging stat layout
|
// for logging stat layout
|
||||||
#include "libtorrent/stat.hpp"
|
#include "libtorrent/stat.hpp"
|
||||||
|
@ -120,17 +118,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/http_tracker_connection.hpp"
|
#include "libtorrent/http_tracker_connection.hpp"
|
||||||
#include "libtorrent/udp_tracker_connection.hpp"
|
#include "libtorrent/udp_tracker_connection.hpp"
|
||||||
|
|
||||||
#include "libtorrent/debug.hpp"
|
#endif // TORRENT_LOGGING
|
||||||
|
|
||||||
#if TORRENT_USE_IOSTREAM
|
|
||||||
namespace libtorrent {
|
|
||||||
std::ofstream logger::log_file;
|
|
||||||
std::string logger::open_filename;
|
|
||||||
mutex logger::file_mutex;
|
|
||||||
}
|
|
||||||
#endif // TORRENT_USE_IOSTREAM
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TORRENT_USE_GCRYPT
|
#ifdef TORRENT_USE_GCRYPT
|
||||||
|
|
||||||
|
@ -415,9 +403,6 @@ namespace aux {
|
||||||
, m_host_resolver(m_io_service)
|
, m_host_resolver(m_io_service)
|
||||||
, m_download_connect_attempts(0)
|
, m_download_connect_attempts(0)
|
||||||
, m_tick_residual(0)
|
, m_tick_residual(0)
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
, m_logpath(".")
|
|
||||||
#endif
|
|
||||||
, m_deferred_submit_disk_jobs(false)
|
, m_deferred_submit_disk_jobs(false)
|
||||||
, m_pending_auto_manage(false)
|
, m_pending_auto_manage(false)
|
||||||
, m_need_auto_manage(false)
|
, m_need_auto_manage(false)
|
||||||
|
@ -475,9 +460,8 @@ namespace aux {
|
||||||
|
|
||||||
void session_impl::start_session(settings_pack const& pack)
|
void session_impl::start_session(settings_pack const& pack)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
m_logger = create_log("main_session", listen_port(), false);
|
session_log("start session");
|
||||||
session_log("log created");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
error_code ec;
|
error_code ec;
|
||||||
|
@ -533,22 +517,16 @@ namespace aux {
|
||||||
// TODO: there's no rule here to make uTP connections not have the global or
|
// TODO: there's no rule here to make uTP connections not have the global or
|
||||||
// local rate limits apply to it. This used to be the default.
|
// local rate limits apply to it. This used to be the default.
|
||||||
|
|
||||||
#ifdef TORRENT_UPNP_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
m_upnp_log.open("upnp.log", std::ios::in | std::ios::out | std::ios::trunc);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
session_log("libtorrent configuration: %s\n"
|
||||||
|
|
||||||
char tmp[300];
|
|
||||||
snprintf(tmp, sizeof(tmp), "libtorrent configuration: %s\n"
|
|
||||||
"libtorrent version: %s\n"
|
"libtorrent version: %s\n"
|
||||||
"libtorrent revision: %s\n\n"
|
"libtorrent revision: %s\n\n"
|
||||||
, TORRENT_CFG_STRING
|
, TORRENT_CFG_STRING
|
||||||
, LIBTORRENT_VERSION
|
, LIBTORRENT_VERSION
|
||||||
, LIBTORRENT_REVISION);
|
, LIBTORRENT_REVISION);
|
||||||
(*m_logger) << tmp;
|
|
||||||
|
|
||||||
#endif // TORRENT_VERBOSE_LOGGING
|
#endif // TORRENT_LOGGING
|
||||||
|
|
||||||
#if TORRENT_USE_RLIMIT
|
#if TORRENT_USE_RLIMIT
|
||||||
// ---- auto-cap max connections ----
|
// ---- auto-cap max connections ----
|
||||||
|
@ -556,7 +534,7 @@ namespace aux {
|
||||||
struct rlimit rl;
|
struct rlimit rl;
|
||||||
if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
|
if (getrlimit(RLIMIT_NOFILE, &rl) == 0)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" max number of open files: %d", rl.rlim_cur);
|
session_log(" max number of open files: %d", rl.rlim_cur);
|
||||||
#endif
|
#endif
|
||||||
// deduct some margin for epoll/kqueue, log files,
|
// deduct some margin for epoll/kqueue, log files,
|
||||||
|
@ -568,7 +546,7 @@ namespace aux {
|
||||||
m_settings.get_int(settings_pack::connections_limit)
|
m_settings.get_int(settings_pack::connections_limit)
|
||||||
, int(rl.rlim_cur * 8 / 10)));
|
, int(rl.rlim_cur * 8 / 10)));
|
||||||
// 20% goes towards regular files (see disk_io_thread)
|
// 20% goes towards regular files (see disk_io_thread)
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" max connections: %d", m_settings.get_int(settings_pack::connections_limit));
|
session_log(" max connections: %d", m_settings.get_int(settings_pack::connections_limit));
|
||||||
session_log(" max files: %d", int(rl.rlim_cur * 2 / 10));
|
session_log(" max files: %d", int(rl.rlim_cur * 2 / 10));
|
||||||
#endif
|
#endif
|
||||||
|
@ -576,7 +554,7 @@ namespace aux {
|
||||||
#endif // TORRENT_USE_RLIMIT
|
#endif // TORRENT_USE_RLIMIT
|
||||||
|
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" generated peer ID: %s", m_peer_id.to_string().c_str());
|
session_log(" generated peer ID: %s", m_peer_id.to_string().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -585,7 +563,7 @@ namespace aux {
|
||||||
// call update_* after settings set initialized
|
// call update_* after settings set initialized
|
||||||
m_io_service.post(boost::bind(&session_impl::init_settings, this));
|
m_io_service.post(boost::bind(&session_impl::init_settings, this));
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" spawning network thread");
|
session_log(" spawning network thread");
|
||||||
#endif
|
#endif
|
||||||
m_thread.reset(new thread(boost::bind(&session_impl::main_thread, this)));
|
m_thread.reset(new thread(boost::bind(&session_impl::main_thread, this)));
|
||||||
|
@ -675,7 +653,7 @@ namespace aux {
|
||||||
|
|
||||||
void session_impl::init()
|
void session_impl::init()
|
||||||
{
|
{
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" *** session thread init");
|
session_log(" *** session thread init");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -704,7 +682,7 @@ namespace aux {
|
||||||
update_dht_announce_interval();
|
update_dht_announce_interval();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" done starting session");
|
session_log(" done starting session");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -964,7 +942,7 @@ namespace aux {
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
if (m_paused) return;
|
if (m_paused) return;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" *** session paused ***");
|
session_log(" *** session paused ***");
|
||||||
#endif
|
#endif
|
||||||
m_paused = true;
|
m_paused = true;
|
||||||
|
@ -1046,7 +1024,7 @@ namespace aux {
|
||||||
m_i2p_listen_socket.reset();
|
m_i2p_listen_socket.reset();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" aborting all torrents (%d)", m_torrents.size());
|
session_log(" aborting all torrents (%d)", m_torrents.size());
|
||||||
#endif
|
#endif
|
||||||
// abort all torrents
|
// abort all torrents
|
||||||
|
@ -1057,12 +1035,12 @@ namespace aux {
|
||||||
}
|
}
|
||||||
m_torrents.clear();
|
m_torrents.clear();
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" aborting all tracker requests");
|
session_log(" aborting all tracker requests");
|
||||||
#endif
|
#endif
|
||||||
m_tracker_manager.abort_all_requests();
|
m_tracker_manager.abort_all_requests();
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" aborting all connections (%d)", m_connections.size());
|
session_log(" aborting all connections (%d)", m_connections.size());
|
||||||
#endif
|
#endif
|
||||||
// abort all connections
|
// abort all connections
|
||||||
|
@ -1587,7 +1565,7 @@ namespace aux {
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
|
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("failed to open socket: %s: %s"
|
session_log("failed to open socket: %s: %s"
|
||||||
, device.c_str(), ec.message().c_str());
|
, device.c_str(), ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1629,7 +1607,7 @@ namespace aux {
|
||||||
|
|
||||||
while (ec && retries > 0)
|
while (ec && retries > 0)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("failed to bind to interface [%s] \"%s\": %s"
|
session_log("failed to bind to interface [%s] \"%s\": %s"
|
||||||
, device.c_str(), bind_ip.to_string(ec).c_str()
|
, device.c_str(), bind_ip.to_string(ec).c_str()
|
||||||
, ec.message().c_str());
|
, ec.message().c_str());
|
||||||
|
@ -1657,7 +1635,7 @@ namespace aux {
|
||||||
// not even that worked, give up
|
// not even that worked, give up
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
|
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("cannot bind to interface \"%s\": %s"
|
session_log("cannot bind to interface \"%s\": %s"
|
||||||
, device.c_str(), ec.message().c_str());
|
, device.c_str(), ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1675,7 +1653,7 @@ namespace aux {
|
||||||
{
|
{
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
|
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("cannot listen on interface \"%s\": %s"
|
session_log("cannot listen on interface \"%s\": %s"
|
||||||
, device.c_str(), ec.message().c_str());
|
, device.c_str(), ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1692,11 +1670,9 @@ namespace aux {
|
||||||
{
|
{
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
|
m_alerts.post_alert(listen_failed_alert(device, last_op, ec, sock_type));
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
char msg[200];
|
session_log("failed to get peer name \"%s\": %s"
|
||||||
snprintf(msg, 200, "failed to get peer name \"%s\": %s"
|
|
||||||
, device.c_str(), ec.message().c_str());
|
, device.c_str(), ec.message().c_str());
|
||||||
(*m_logger) << time_now_string() << msg << "\n";
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1706,7 +1682,7 @@ namespace aux {
|
||||||
, (flags & open_ssl_socket) ? listen_succeeded_alert::tcp_ssl
|
, (flags & open_ssl_socket) ? listen_succeeded_alert::tcp_ssl
|
||||||
: listen_succeeded_alert::tcp));
|
: listen_succeeded_alert::tcp));
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" listening on: %s external port: %d"
|
session_log(" listening on: %s external port: %d"
|
||||||
, print_endpoint(tcp::endpoint(bind_ip, port)).c_str(), ret.external_port);
|
, print_endpoint(tcp::endpoint(bind_ip, port)).c_str(), ret.external_port);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1715,9 +1691,8 @@ namespace aux {
|
||||||
|
|
||||||
void session_impl::open_listen_port()
|
void session_impl::open_listen_port()
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
m_logger = create_log("main_session", listen_port(), false);
|
session_log("open listen port");
|
||||||
session_log("log created");
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
@ -1909,11 +1884,9 @@ retry:
|
||||||
|
|
||||||
if (m_listen_sockets.empty() && ec)
|
if (m_listen_sockets.empty() && ec)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
char msg[200];
|
session_log("cannot bind TCP listen socket to interface \"%s\": %s"
|
||||||
snprintf(msg, sizeof(msg), "cannot bind TCP listen socket to interface \"%s\": %s"
|
|
||||||
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
|
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
|
||||||
(*m_logger) << msg << "\n";
|
|
||||||
#endif
|
#endif
|
||||||
if (m_listen_port_retries > 0)
|
if (m_listen_port_retries > 0)
|
||||||
{
|
{
|
||||||
|
@ -1934,7 +1907,7 @@ retry:
|
||||||
m_ssl_udp_socket.bind(ssl_bind_if, ec);
|
m_ssl_udp_socket.bind(ssl_bind_if, ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("SSL: cannot bind to UDP interface \"%s\": %s"
|
session_log("SSL: cannot bind to UDP interface \"%s\": %s"
|
||||||
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
|
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1959,7 +1932,7 @@ retry:
|
||||||
m_udp_socket.bind(udp::endpoint(m_listen_interface.address(), m_listen_interface.port()), ec);
|
m_udp_socket.bind(udp::endpoint(m_listen_interface.address(), m_listen_interface.port()), ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("cannot bind to UDP interface \"%s\": %s"
|
session_log("cannot bind to UDP interface \"%s\": %s"
|
||||||
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
|
, print_endpoint(m_listen_interface).c_str(), ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -2014,10 +1987,6 @@ retry:
|
||||||
tcp::endpoint local = m_listen_sockets.front().sock->local_endpoint(ec);
|
tcp::endpoint local = m_listen_sockets.front().sock->local_endpoint(ec);
|
||||||
if (!ec) remap_tcp_ports(3, local.port(), ssl_listen_port());
|
if (!ec) remap_tcp_ports(3, local.port(), ssl_listen_port());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
m_logger = create_log("main_session", listen_port(), false);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void session_impl::remap_tcp_ports(boost::uint32_t mask, int tcp_port, int ssl_port)
|
void session_impl::remap_tcp_ports(boost::uint32_t mask, int tcp_port, int ssl_port)
|
||||||
|
@ -2109,10 +2078,8 @@ retry:
|
||||||
if (m_alerts.should_post<i2p_alert>())
|
if (m_alerts.should_post<i2p_alert>())
|
||||||
m_alerts.post_alert(i2p_alert(ec));
|
m_alerts.post_alert(i2p_alert(ec));
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
char msg[200];
|
session_log("i2p open failed (%d) %s", ec.value(), ec.message().c_str());
|
||||||
snprintf(msg, sizeof(msg), "i2p open failed (%d) %s", ec.value(), ec.message().c_str());
|
|
||||||
(*m_logger) << msg << "\n";
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// now that we have our i2p connection established
|
// now that we have our i2p connection established
|
||||||
|
@ -2156,7 +2123,7 @@ retry:
|
||||||
if (m_alerts.should_post<listen_failed_alert>())
|
if (m_alerts.should_post<listen_failed_alert>())
|
||||||
m_alerts.post_alert(listen_failed_alert("i2p", listen_failed_alert::accept
|
m_alerts.post_alert(listen_failed_alert("i2p", listen_failed_alert::accept
|
||||||
, e, listen_failed_alert::i2p));
|
, e, listen_failed_alert::i2p));
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("cannot bind to port %d: %s"
|
session_log("cannot bind to port %d: %s"
|
||||||
, m_listen_interface.port(), e.message().c_str());
|
, m_listen_interface.port(), e.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -2179,7 +2146,7 @@ retry:
|
||||||
&& m_alerts.should_post<udp_error_alert>())
|
&& m_alerts.should_post<udp_error_alert>())
|
||||||
m_alerts.post_alert(udp_error_alert(ep, ec));
|
m_alerts.post_alert(udp_error_alert(ep, ec));
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("UDP socket error: (%d) %s", ec.value(), ec.message().c_str());
|
session_log("UDP socket error: (%d) %s", ec.value(), ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2236,7 +2203,7 @@ retry:
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
tcp::endpoint ep = listener->local_endpoint(ec);
|
tcp::endpoint ep = listener->local_endpoint(ec);
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("error accepting connection on '%s': %s"
|
session_log("error accepting connection on '%s': %s"
|
||||||
, print_endpoint(ep).c_str(), e.message().c_str());
|
, print_endpoint(ep).c_str(), e.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -2333,7 +2300,7 @@ retry:
|
||||||
tcp::endpoint endp = s->remote_endpoint(e);
|
tcp::endpoint endp = s->remote_endpoint(e);
|
||||||
if (e) return;
|
if (e) return;
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" *** peer SSL handshake done [ ip: %s ec: %s socket: %s ]"
|
session_log(" *** peer SSL handshake done [ ip: %s ec: %s socket: %s ]"
|
||||||
, print_endpoint(endp).c_str(), ec.message().c_str(), s->type_name());
|
, print_endpoint(endp).c_str(), ec.message().c_str(), s->type_name());
|
||||||
#endif
|
#endif
|
||||||
|
@ -2366,7 +2333,7 @@ retry:
|
||||||
|
|
||||||
if (m_paused)
|
if (m_paused)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" <== INCOMING CONNECTION [ ignored, paused ]");
|
session_log(" <== INCOMING CONNECTION [ ignored, paused ]");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -2378,7 +2345,7 @@ retry:
|
||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("%s <== INCOMING CONNECTION FAILED, could "
|
session_log("%s <== INCOMING CONNECTION FAILED, could "
|
||||||
"not retrieve remote endpoint "
|
"not retrieve remote endpoint "
|
||||||
, print_endpoint(endp).c_str(), ec.message().c_str());
|
, print_endpoint(endp).c_str(), ec.message().c_str());
|
||||||
|
@ -2386,7 +2353,7 @@ retry:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" <== INCOMING CONNECTION %s type: %s"
|
session_log(" <== INCOMING CONNECTION %s type: %s"
|
||||||
, print_endpoint(endp).c_str(), s->type_name());
|
, print_endpoint(endp).c_str(), s->type_name());
|
||||||
#endif
|
#endif
|
||||||
|
@ -2394,7 +2361,7 @@ retry:
|
||||||
if (!m_settings.get_bool(settings_pack::enable_incoming_utp)
|
if (!m_settings.get_bool(settings_pack::enable_incoming_utp)
|
||||||
&& is_utp(*s))
|
&& is_utp(*s))
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" rejected uTP connection");
|
session_log(" rejected uTP connection");
|
||||||
#endif
|
#endif
|
||||||
if (m_alerts.should_post<peer_blocked_alert>())
|
if (m_alerts.should_post<peer_blocked_alert>())
|
||||||
|
@ -2406,7 +2373,7 @@ retry:
|
||||||
if (!m_settings.get_bool(settings_pack::enable_incoming_tcp)
|
if (!m_settings.get_bool(settings_pack::enable_incoming_tcp)
|
||||||
&& s->get<stream_socket>())
|
&& s->get<stream_socket>())
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" rejected TCP connection");
|
session_log(" rejected TCP connection");
|
||||||
#endif
|
#endif
|
||||||
if (m_alerts.should_post<peer_blocked_alert>())
|
if (m_alerts.should_post<peer_blocked_alert>())
|
||||||
|
@ -2423,7 +2390,7 @@ retry:
|
||||||
tcp::endpoint local = s->local_endpoint(ec);
|
tcp::endpoint local = s->local_endpoint(ec);
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" rejected connection: (%d) %s", ec.value()
|
session_log(" rejected connection: (%d) %s", ec.value()
|
||||||
, ec.message().c_str());
|
, ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -2434,14 +2401,14 @@ retry:
|
||||||
{
|
{
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" rejected connection, not allowed local interface: (%d) %s"
|
session_log(" rejected connection, not allowed local interface: (%d) %s"
|
||||||
, ec.value(), ec.message().c_str());
|
, ec.value(), ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" rejected connection, not allowed local interface: %s"
|
session_log(" rejected connection, not allowed local interface: %s"
|
||||||
, local.address().to_string(ec).c_str());
|
, local.address().to_string(ec).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -2465,7 +2432,7 @@ retry:
|
||||||
if (m_stats_counters[counters::non_filter_torrents] == 0
|
if (m_stats_counters[counters::non_filter_torrents] == 0
|
||||||
&& (m_ip_filter.access(endp.address()) & ip_filter::blocked))
|
&& (m_ip_filter.access(endp.address()) & ip_filter::blocked))
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("filtered blocked ip");
|
session_log("filtered blocked ip");
|
||||||
#endif
|
#endif
|
||||||
if (m_alerts.should_post<peer_blocked_alert>())
|
if (m_alerts.should_post<peer_blocked_alert>())
|
||||||
|
@ -2478,7 +2445,7 @@ retry:
|
||||||
// if we don't reject the connection
|
// if we don't reject the connection
|
||||||
if (m_torrents.empty())
|
if (m_torrents.empty())
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" There are no torrents, disconnect");
|
session_log(" There are no torrents, disconnect");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -2514,7 +2481,7 @@ retry:
|
||||||
, peer_connection::op_bittorrent
|
, peer_connection::op_bittorrent
|
||||||
, error_code(errors::too_many_connections, get_libtorrent_category())));
|
, error_code(errors::too_many_connections, get_libtorrent_category())));
|
||||||
}
|
}
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("number of connections limit exceeded (conns: %d, limit: %d, slack: %d), connection rejected"
|
session_log("number of connections limit exceeded (conns: %d, limit: %d, slack: %d), connection rejected"
|
||||||
, num_connections(), m_settings.get_int(settings_pack::connections_limit)
|
, num_connections(), m_settings.get_int(settings_pack::connections_limit)
|
||||||
, m_settings.get_int(settings_pack::connections_slack));
|
, m_settings.get_int(settings_pack::connections_slack));
|
||||||
|
@ -2541,7 +2508,7 @@ retry:
|
||||||
}
|
}
|
||||||
if (!has_active_torrent)
|
if (!has_active_torrent)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" There are no _active_ torrents, disconnect");
|
session_log(" There are no _active_ torrents, disconnect");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -2638,7 +2605,7 @@ retry:
|
||||||
// TORRENT_ASSERT(!i->second->has_peer((peer_connection*)p));
|
// TORRENT_ASSERT(!i->second->has_peer((peer_connection*)p));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" CLOSING CONNECTION %s : %s"
|
session_log(" CLOSING CONNECTION %s : %s"
|
||||||
, print_endpoint(p->remote()).c_str(), ec.message().c_str());
|
, print_endpoint(p->remote()).c_str(), ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -2818,7 +2785,7 @@ retry:
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("*** TICK TIMER FAILED %s", e.message().c_str());
|
session_log("*** TICK TIMER FAILED %s", e.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
::abort();
|
::abort();
|
||||||
|
@ -3299,7 +3266,7 @@ retry:
|
||||||
|
|
||||||
TORRENT_ASSERT(m_dht);
|
TORRENT_ASSERT(m_dht);
|
||||||
m_dht_torrents.push_back(t);
|
m_dht_torrents.push_back(t);
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<torrent> tor = t.lock();
|
boost::shared_ptr<torrent> tor = t.lock();
|
||||||
if (tor)
|
if (tor)
|
||||||
session_log("prioritizing DHT announce: \"%s\"", tor->name().c_str());
|
session_log("prioritizing DHT announce: \"%s\"", tor->name().c_str());
|
||||||
|
@ -3328,7 +3295,7 @@ retry:
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("aborting DHT announce timer (%d): %s"
|
session_log("aborting DHT announce timer (%d): %s"
|
||||||
, e.value(), e.message().c_str());
|
, e.value(), e.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -3337,7 +3304,7 @@ retry:
|
||||||
|
|
||||||
if (m_abort)
|
if (m_abort)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("aborting DHT announce timer: m_abort set");
|
session_log("aborting DHT announce timer: m_abort set");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -3471,7 +3438,7 @@ retry:
|
||||||
{
|
{
|
||||||
--hard_limit;
|
--hard_limit;
|
||||||
--type_limit;
|
--type_limit;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (!t->allows_peers())
|
if (!t->allows_peers())
|
||||||
t->log_to_all_peers("AUTO MANAGER STARTING TORRENT");
|
t->log_to_all_peers("AUTO MANAGER STARTING TORRENT");
|
||||||
#endif
|
#endif
|
||||||
|
@ -3479,7 +3446,7 @@ retry:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (t->allows_peers())
|
if (t->allows_peers())
|
||||||
t->log_to_all_peers("AUTO MANAGER PAUSING TORRENT");
|
t->log_to_all_peers("AUTO MANAGER PAUSING TORRENT");
|
||||||
#endif
|
#endif
|
||||||
|
@ -4032,7 +3999,7 @@ retry:
|
||||||
stop_loop = m_abort;
|
stop_loop = m_abort;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" locking mutex");
|
session_log(" locking mutex");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4045,7 +4012,7 @@ retry:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" cleaning up torrents");
|
session_log(" cleaning up torrents");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4250,18 +4217,10 @@ retry:
|
||||||
return i->second;
|
return i->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<logger> session_impl::create_log(std::string const& name
|
|
||||||
, int instance, bool append)
|
|
||||||
{
|
|
||||||
error_code ec;
|
|
||||||
// current options are file_logger, cout_logger and null_logger
|
|
||||||
return boost::shared_ptr<logger>(new logger(m_logpath, name, instance, append));
|
|
||||||
}
|
|
||||||
|
|
||||||
void session_impl::session_log(char const* fmt, ...) const
|
void session_impl::session_log(char const* fmt, ...) const
|
||||||
{
|
{
|
||||||
if (!m_logger) return;
|
if (!m_alerts.should_post<log_alert>()) return;
|
||||||
|
|
||||||
va_list v;
|
va_list v;
|
||||||
va_start(v, fmt);
|
va_start(v, fmt);
|
||||||
|
@ -4271,15 +4230,15 @@ retry:
|
||||||
|
|
||||||
void session_impl::session_vlog(char const* fmt, va_list& v) const
|
void session_impl::session_vlog(char const* fmt, va_list& v) const
|
||||||
{
|
{
|
||||||
char usr[400];
|
if (!m_alerts.should_post<log_alert>()) return;
|
||||||
vsnprintf(usr, sizeof(usr), fmt, v);
|
|
||||||
|
char buf[1024];
|
||||||
|
vsnprintf(buf, sizeof(buf), fmt, v);
|
||||||
va_end(v);
|
va_end(v);
|
||||||
char buf[450];
|
|
||||||
snprintf(buf, sizeof(buf), "%s: %s\n", time_now_string(), usr);
|
m_alerts.post_alert(log_alert(buf));
|
||||||
(*m_logger) << buf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
|
||||||
void session_impl::log_all_torrents(peer_connection* p)
|
void session_impl::log_all_torrents(peer_connection* p)
|
||||||
{
|
{
|
||||||
for (session_impl::torrent_map::const_iterator i = m_torrents.begin()
|
for (session_impl::torrent_map::const_iterator i = m_torrents.begin()
|
||||||
|
@ -4288,7 +4247,6 @@ retry:
|
||||||
p->peer_log(" %s", to_hex(i->second->torrent_file().info_hash().to_string()).c_str());
|
p->peer_log(" %s", to_hex(i->second->torrent_file().info_hash().to_string()).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void session_impl::get_torrent_status(std::vector<torrent_status>* ret
|
void session_impl::get_torrent_status(std::vector<torrent_status>* ret
|
||||||
|
@ -4553,7 +4511,7 @@ retry:
|
||||||
error_code ec;
|
error_code ec;
|
||||||
lazy_entry tmp;
|
lazy_entry tmp;
|
||||||
lazy_entry const* info = 0;
|
lazy_entry const* info = 0;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("adding magnet link with resume data");
|
session_log("adding magnet link with resume data");
|
||||||
#endif
|
#endif
|
||||||
if (lazy_bdecode(¶ms.resume_data[0], ¶ms.resume_data[0]
|
if (lazy_bdecode(¶ms.resume_data[0], ¶ms.resume_data[0]
|
||||||
|
@ -4561,7 +4519,7 @@ retry:
|
||||||
&& tmp.type() == lazy_entry::dict_t
|
&& tmp.type() == lazy_entry::dict_t
|
||||||
&& (info = tmp.dict_find_dict("info")))
|
&& (info = tmp.dict_find_dict("info")))
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("found metadata in resume data");
|
session_log("found metadata in resume data");
|
||||||
#endif
|
#endif
|
||||||
// verify the info-hash of the metadata stored in the resume file matches
|
// verify the info-hash of the metadata stored in the resume file matches
|
||||||
|
@ -4577,14 +4535,14 @@ retry:
|
||||||
|| !params.url.empty()
|
|| !params.url.empty()
|
||||||
|| params.info_hash.is_all_zeros())
|
|| params.info_hash.is_all_zeros())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("info-hash matched");
|
session_log("info-hash matched");
|
||||||
#endif
|
#endif
|
||||||
params.ti = boost::make_shared<torrent_info>(resume_ih);
|
params.ti = boost::make_shared<torrent_info>(resume_ih);
|
||||||
|
|
||||||
if (params.ti->parse_info_section(*info, ec, 0))
|
if (params.ti->parse_info_section(*info, ec, 0))
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("successfully loaded metadata from resume file");
|
session_log("successfully loaded metadata from resume file");
|
||||||
#endif
|
#endif
|
||||||
// make the info-hash be the one in the resume file
|
// make the info-hash be the one in the resume file
|
||||||
|
@ -4593,20 +4551,20 @@ retry:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log("failed to load metadata from resume file: %s"
|
session_log("failed to load metadata from resume file: %s"
|
||||||
, ec.message().c_str());
|
, ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
session_log("metadata info-hash failed");
|
session_log("metadata info-hash failed");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
session_log("no metadata found");
|
session_log("no metadata found");
|
||||||
|
@ -4934,7 +4892,7 @@ retry:
|
||||||
// declared in string_util.hpp
|
// declared in string_util.hpp
|
||||||
parse_comma_separated_string_port(net_interfaces, new_listen_interfaces);
|
parse_comma_separated_string_port(net_interfaces, new_listen_interfaces);
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("update listen interfaces: %s", net_interfaces.c_str());
|
session_log("update listen interfaces: %s", net_interfaces.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4962,14 +4920,14 @@ retry:
|
||||||
device_name[0] == '[' ? device_name + 1 : device_name, ec));
|
device_name[0] == '[' ? device_name + 1 : device_name, ec));
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("failed to treat %s as an IP address [ %s ]"
|
session_log("failed to treat %s as an IP address [ %s ]"
|
||||||
, device_name, ec.message().c_str());
|
, device_name, ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
// it may have been a device name.
|
// it may have been a device name.
|
||||||
std::vector<ip_interface> ifs = enum_net_interfaces(m_io_service, ec);
|
std::vector<ip_interface> ifs = enum_net_interfaces(m_io_service, ec);
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (ec)
|
if (ec)
|
||||||
session_log("failed to enumerate interfaces [ %s ]"
|
session_log("failed to enumerate interfaces [ %s ]"
|
||||||
, ec.message().c_str());
|
, ec.message().c_str());
|
||||||
|
@ -4983,7 +4941,7 @@ retry:
|
||||||
// connecting to)
|
// connecting to)
|
||||||
if (strcmp(ifs[i].name, device_name) != 0) continue;
|
if (strcmp(ifs[i].name, device_name) != 0) continue;
|
||||||
m_listen_interface.address(ifs[i].interface_address);
|
m_listen_interface.address(ifs[i].interface_address);
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("binding to %s"
|
session_log("binding to %s"
|
||||||
, m_listen_interface.address().to_string(ec).c_str());
|
, m_listen_interface.address().to_string(ec).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -4993,7 +4951,7 @@ retry:
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("failed to find device %s", device_name);
|
session_log("failed to find device %s", device_name);
|
||||||
#endif
|
#endif
|
||||||
// effectively disable whatever socket decides to bind to this
|
// effectively disable whatever socket decides to bind to this
|
||||||
|
@ -5155,7 +5113,7 @@ retry:
|
||||||
if (t->torrent_file().priv() || (t->torrent_file().is_i2p()
|
if (t->torrent_file().priv() || (t->torrent_file().is_i2p()
|
||||||
&& !m_settings.get_bool(settings_pack::allow_i2p_mixed))) return;
|
&& !m_settings.get_bool(settings_pack::allow_i2p_mixed))) return;
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("added peer from local discovery: %s", print_endpoint(peer).c_str());
|
session_log("added peer from local discovery: %s", print_endpoint(peer).c_str());
|
||||||
#endif
|
#endif
|
||||||
t->add_peer(peer, peer_info::lsd);
|
t->add_peer(peer, peer_info::lsd);
|
||||||
|
@ -5170,11 +5128,6 @@ retry:
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(map_transport >= 0 && map_transport <= 1);
|
TORRENT_ASSERT(map_transport >= 0 && map_transport <= 1);
|
||||||
// log message
|
// log message
|
||||||
#ifdef TORRENT_UPNP_LOGGING
|
|
||||||
char const* transport_names[] = {"NAT-PMP", "UPnP"};
|
|
||||||
m_upnp_log << time_now_string() << " "
|
|
||||||
<< transport_names[map_transport] << ": " << msg;
|
|
||||||
#endif
|
|
||||||
if (m_alerts.should_post<portmap_log_alert>())
|
if (m_alerts.should_post<portmap_log_alert>())
|
||||||
m_alerts.post_alert(portmap_log_alert(map_transport, msg));
|
m_alerts.post_alert(portmap_log_alert(map_transport, msg));
|
||||||
}
|
}
|
||||||
|
@ -5706,7 +5659,7 @@ retry:
|
||||||
m_ssl_udp_socket.set_option(type_of_service(m_settings.get_int(settings_pack::peer_tos)), ec);
|
m_ssl_udp_socket.set_option(type_of_service(m_settings.get_int(settings_pack::peer_tos)), ec);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(">>> SET_TOS [ udp_socket tos: %x e: %s ]"
|
session_log(">>> SET_TOS [ udp_socket tos: %x e: %s ]"
|
||||||
, m_settings.get_int(settings_pack::peer_tos)
|
, m_settings.get_int(settings_pack::peer_tos)
|
||||||
, ec.message().c_str());
|
, ec.message().c_str());
|
||||||
|
@ -5910,7 +5863,7 @@ retry:
|
||||||
#ifndef TORRENT_DISABLE_DHT
|
#ifndef TORRENT_DISABLE_DHT
|
||||||
if (!m_dht)
|
if (!m_dht)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("not starting DHT announce timer: m_dht == NULL");
|
session_log("not starting DHT announce timer: m_dht == NULL");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -5921,7 +5874,7 @@ retry:
|
||||||
// if we haven't started yet, don't actually trigger this
|
// if we haven't started yet, don't actually trigger this
|
||||||
if (!m_thread)
|
if (!m_thread)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("not starting DHT announce timer: thread not running yet");
|
session_log("not starting DHT announce timer: thread not running yet");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -5929,7 +5882,7 @@ retry:
|
||||||
|
|
||||||
if (m_abort)
|
if (m_abort)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
session_log("not starting DHT announce timer: m_abort set");
|
session_log("not starting DHT announce timer: m_abort set");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -6338,14 +6291,14 @@ retry:
|
||||||
void session_impl::set_external_address(address const& ip
|
void session_impl::set_external_address(address const& ip
|
||||||
, int source_type, address const& source)
|
, int source_type, address const& source)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(": set_external_address(%s, %d, %s)", print_address(ip).c_str()
|
session_log(": set_external_address(%s, %d, %s)", print_address(ip).c_str()
|
||||||
, source_type, print_address(source).c_str());
|
, source_type, print_address(source).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!m_external_ip.cast_vote(ip, source_type, source)) return;
|
if (!m_external_ip.cast_vote(ip, source_type, source)) return;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
session_log(" external IP updated");
|
session_log(" external IP updated");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -6616,7 +6569,7 @@ retry:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
tracker_logger::tracker_logger(session_interface& ses): m_ses(ses) {}
|
tracker_logger::tracker_logger(session_interface& ses): m_ses(ses) {}
|
||||||
void tracker_logger::tracker_warning(tracker_request const& req
|
void tracker_logger::tracker_warning(tracker_request const& req
|
||||||
, std::string const& str)
|
, std::string const& str)
|
||||||
|
@ -6629,7 +6582,7 @@ retry:
|
||||||
, std::list<address> const& ip_list
|
, std::list<address> const& ip_list
|
||||||
, struct tracker_response const& resp)
|
, struct tracker_response const& resp)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("TRACKER RESPONSE\n"
|
debug_log("TRACKER RESPONSE\n"
|
||||||
"interval: %d\n"
|
"interval: %d\n"
|
||||||
"external ip: %s\n"
|
"external ip: %s\n"
|
||||||
|
|
|
@ -61,7 +61,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
//#define TORRENT_LOG_HASH_FAILURES
|
//#define TORRENT_LOG_HASH_FAILURES
|
||||||
|
|
||||||
#ifdef TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
#include "libtorrent/socket_io.hpp"
|
#include "libtorrent/socket_io.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ namespace
|
||||||
|
|
||||||
void on_piece_pass(int p)
|
void on_piece_pass(int p)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
m_torrent.debug_log(" PIECE PASS [ p: %d | block_hash_size: %d ]"
|
m_torrent.debug_log(" PIECE PASS [ p: %d | block_hash_size: %d ]"
|
||||||
, p, int(m_block_hashes.size()));
|
, p, int(m_block_hashes.size()));
|
||||||
#endif
|
#endif
|
||||||
|
@ -274,7 +274,7 @@ namespace
|
||||||
// this time the digest of the block is different
|
// this time the digest of the block is different
|
||||||
// from the first time it sent it
|
// from the first time it sent it
|
||||||
// at least one of them must be bad
|
// at least one of them must be bad
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
char const* client = "-";
|
char const* client = "-";
|
||||||
peer_info info;
|
peer_info info;
|
||||||
if (p->connection)
|
if (p->connection)
|
||||||
|
@ -349,7 +349,7 @@ namespace
|
||||||
}
|
}
|
||||||
if (p == NULL) return;
|
if (p == NULL) return;
|
||||||
|
|
||||||
#ifdef TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
char const* client = "-";
|
char const* client = "-";
|
||||||
peer_info info;
|
peer_info info;
|
||||||
if (p->connection)
|
if (p->connection)
|
||||||
|
|
208
src/torrent.cpp
208
src/torrent.cpp
|
@ -95,7 +95,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif // BOOST_VERSION
|
#endif // BOOST_VERSION
|
||||||
#endif // TORRENT_USE_OPENSSL
|
#endif // TORRENT_USE_OPENSSL
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
#include "libtorrent/aux_/session_impl.hpp" // for tracker_logger
|
#include "libtorrent/aux_/session_impl.hpp" // for tracker_logger
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -255,16 +255,6 @@ namespace libtorrent
|
||||||
m_save_path = canonicalize_path(m_save_path);
|
m_save_path = canonicalize_path(m_save_path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
m_logger_time = time_now_hires();
|
|
||||||
error_code ec;
|
|
||||||
|
|
||||||
char buf[50];
|
|
||||||
snprintf(buf, sizeof(buf), "torrent_%p", this);
|
|
||||||
|
|
||||||
m_logger = m_ses.create_log(buf, m_ses.listen_port());
|
|
||||||
debug_log("torrent started");
|
|
||||||
#endif
|
|
||||||
if (!m_apply_ip_filter)
|
if (!m_apply_ip_filter)
|
||||||
{
|
{
|
||||||
inc_stats_counter(counters::non_filter_torrents);
|
inc_stats_counter(counters::non_filter_torrents);
|
||||||
|
@ -304,9 +294,6 @@ namespace libtorrent
|
||||||
if (!m_url.empty() && m_uuid.empty()) m_uuid = m_url;
|
if (!m_url.empty() && m_uuid.empty()) m_uuid = m_url;
|
||||||
|
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
debug_log("creating torrent: %s", torrent_file().name().c_str());
|
|
||||||
#endif
|
|
||||||
m_file_priority = p.file_priorities;
|
m_file_priority = p.file_priorities;
|
||||||
|
|
||||||
if (m_seed_mode)
|
if (m_seed_mode)
|
||||||
|
@ -703,12 +690,12 @@ namespace libtorrent
|
||||||
|
|
||||||
// TODO: 2 post alert
|
// TODO: 2 post alert
|
||||||
|
|
||||||
#if defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** FAILED SEED MODE, rechecking");
|
debug_log("*** FAILED SEED MODE, rechecking");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** LEAVING SEED MODE (%s)", seed ? "as seed" : "as non-seed");
|
debug_log("*** LEAVING SEED MODE (%s)", seed ? "as seed" : "as non-seed");
|
||||||
#endif
|
#endif
|
||||||
m_seed_mode = false;
|
m_seed_mode = false;
|
||||||
|
@ -739,7 +726,7 @@ namespace libtorrent
|
||||||
void torrent::start()
|
void torrent::start()
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("starting torrent");
|
debug_log("starting torrent");
|
||||||
#endif
|
#endif
|
||||||
std::vector<boost::uint64_t>().swap(m_file_progress);
|
std::vector<boost::uint64_t>().swap(m_file_progress);
|
||||||
|
@ -752,7 +739,7 @@ namespace libtorrent
|
||||||
+ m_resume_data->buf.size(), m_resume_data->entry, ec, &pos) != 0)
|
+ m_resume_data->buf.size(), m_resume_data->entry, ec, &pos) != 0)
|
||||||
{
|
{
|
||||||
m_resume_data.reset();
|
m_resume_data.reset();
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("resume data rejected: %s pos: %d", ec.message().c_str(), pos);
|
debug_log("resume data rejected: %s pos: %d", ec.message().c_str(), pos);
|
||||||
#endif
|
#endif
|
||||||
if (m_ses.alerts().should_post<fastresume_rejected_alert>())
|
if (m_ses.alerts().should_post<fastresume_rejected_alert>())
|
||||||
|
@ -1055,7 +1042,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
if (!j->error) return;
|
if (!j->error) return;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("disk error: (%d) %s in file: %s", j->error.ec.value(), j->error.ec.message().c_str()
|
debug_log("disk error: (%d) %s in file: %s", j->error.ec.value(), j->error.ec.message().c_str()
|
||||||
, resolve_filename(j->error.file).c_str());
|
, resolve_filename(j->error.file).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1456,7 +1443,7 @@ namespace libtorrent
|
||||||
GENERAL_NAMES* gens = static_cast<GENERAL_NAMES*>(
|
GENERAL_NAMES* gens = static_cast<GENERAL_NAMES*>(
|
||||||
X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0));
|
X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0));
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
std::string names;
|
std::string names;
|
||||||
bool match = false;
|
bool match = false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1469,14 +1456,14 @@ namespace libtorrent
|
||||||
const char* torrent_name = reinterpret_cast<const char*>(domain->data);
|
const char* torrent_name = reinterpret_cast<const char*>(domain->data);
|
||||||
std::size_t name_length = domain->length;
|
std::size_t name_length = domain->length;
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (i > 1) names += " | n: ";
|
if (i > 1) names += " | n: ";
|
||||||
names.append(torrent_name, name_length);
|
names.append(torrent_name, name_length);
|
||||||
#endif
|
#endif
|
||||||
if (strncmp(torrent_name, "*", name_length) == 0
|
if (strncmp(torrent_name, "*", name_length) == 0
|
||||||
|| strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
|
|| strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
|
||||||
{
|
{
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
match = true;
|
match = true;
|
||||||
// if we're logging, keep looping over all names,
|
// if we're logging, keep looping over all names,
|
||||||
// for completeness of the log
|
// for completeness of the log
|
||||||
|
@ -1501,7 +1488,7 @@ namespace libtorrent
|
||||||
const char* torrent_name = reinterpret_cast<const char*>(common_name->data);
|
const char* torrent_name = reinterpret_cast<const char*>(common_name->data);
|
||||||
std::size_t name_length = common_name->length;
|
std::size_t name_length = common_name->length;
|
||||||
|
|
||||||
#if defined(TORRENT_VERBOSE_LOGGING) || defined(TORRENT_LOGGING)
|
#if defined TORRENT_LOGGING
|
||||||
if (!names.empty()) names += " | n: ";
|
if (!names.empty()) names += " | n: ";
|
||||||
names.append(torrent_name, name_length);
|
names.append(torrent_name, name_length);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1509,7 +1496,7 @@ namespace libtorrent
|
||||||
if (strncmp(torrent_name, "*", name_length) == 0
|
if (strncmp(torrent_name, "*", name_length) == 0
|
||||||
|| strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
|
|| strncmp(torrent_name, m_torrent_file->name().c_str(), name_length) == 0)
|
||||||
{
|
{
|
||||||
#if !defined(TORRENT_VERBOSE_LOGGING) && !defined(TORRENT_LOGGING)
|
#if !defined TORRENT_LOGGING
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
match = true;
|
match = true;
|
||||||
|
@ -1517,7 +1504,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("<== incoming SSL CONNECTION [ n: %s | match: %s ]"
|
debug_log("<== incoming SSL CONNECTION [ n: %s | match: %s ]"
|
||||||
, names.c_str(), match?"yes":"no");
|
, names.c_str(), match?"yes":"no");
|
||||||
return match;
|
return match;
|
||||||
|
@ -1691,6 +1678,10 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
|
#if defined TORRENT_LOGGING
|
||||||
|
debug_log("init torrent: %s", torrent_file().name().c_str());
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!need_loaded()) return;
|
if (!need_loaded()) return;
|
||||||
TORRENT_ASSERT(m_torrent_file->num_files() > 0);
|
TORRENT_ASSERT(m_torrent_file->num_files() > 0);
|
||||||
TORRENT_ASSERT(m_torrent_file->is_valid());
|
TORRENT_ASSERT(m_torrent_file->is_valid());
|
||||||
|
@ -1745,7 +1736,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (ev)
|
if (ev)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("fastresume data rejected: %s"
|
debug_log("fastresume data rejected: %s"
|
||||||
, error_code(ev, get_libtorrent_category()).message().c_str());
|
, error_code(ev, get_libtorrent_category()).message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -1906,7 +1897,7 @@ namespace libtorrent
|
||||||
m_storage.get(), m_resume_data ? &m_resume_data->entry : NULL
|
m_storage.get(), m_resume_data ? &m_resume_data->entry : NULL
|
||||||
, boost::bind(&torrent::on_resume_data_checked
|
, boost::bind(&torrent::on_resume_data_checked
|
||||||
, shared_from_this(), _1));
|
, shared_from_this(), _1));
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("init, async_check_fastresume");
|
debug_log("init, async_check_fastresume");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2221,7 +2212,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (m_peer_list && m_peer_list->num_peers() > 0)
|
if (m_peer_list && m_peer_list->num_peers() > 0)
|
||||||
debug_log("resume added peers (%d)", m_peer_list->num_peers());
|
debug_log("resume added peers (%d)", m_peer_list->num_peers());
|
||||||
#endif
|
#endif
|
||||||
|
@ -2234,13 +2225,13 @@ namespace libtorrent
|
||||||
, resolve_filename(j->error.file), j->error.operation_str()));
|
, resolve_filename(j->error.file), j->error.operation_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (j->ret != 0)
|
if (j->ret != 0)
|
||||||
{
|
{
|
||||||
debug_log("fastresume data rejected: ret: %d (%d) %s"
|
debug_log("fastresume data rejected: ret: %d (%d) %s"
|
||||||
, j->ret, j->error.ec.value(), j->error.ec.message().c_str());
|
, j->ret, j->error.ec.value(), j->error.ec.message().c_str());
|
||||||
}
|
}
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
else
|
else
|
||||||
debug_log("fastresume data accepted");
|
debug_log("fastresume data accepted");
|
||||||
#endif
|
#endif
|
||||||
|
@ -2462,7 +2453,7 @@ namespace libtorrent
|
||||||
// resumed quickly, before the outstanding jobs completed
|
// resumed quickly, before the outstanding jobs completed
|
||||||
if (m_checking_piece >= m_torrent_file->num_pieces())
|
if (m_checking_piece >= m_torrent_file->num_pieces())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("start_checking, checking_piece >= num_pieces. %d >= %d"
|
debug_log("start_checking, checking_piece >= num_pieces. %d >= %d"
|
||||||
, m_checking_piece, m_torrent_file->num_pieces());
|
, m_checking_piece, m_torrent_file->num_pieces());
|
||||||
#endif
|
#endif
|
||||||
|
@ -2475,7 +2466,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!need_loaded())
|
if (!need_loaded())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("start_checking, need_loaded() failed");
|
debug_log("start_checking, need_loaded() failed");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -2490,7 +2481,7 @@ namespace libtorrent
|
||||||
, shared_from_this(), _1), (void*)1);
|
, shared_from_this(), _1), (void*)1);
|
||||||
if (m_checking_piece >= m_torrent_file->num_pieces()) break;
|
if (m_checking_piece >= m_torrent_file->num_pieces()) break;
|
||||||
}
|
}
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("start_checking, m_checking_piece: %d", m_checking_piece);
|
debug_log("start_checking, m_checking_piece: %d", m_checking_piece);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2513,7 +2504,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
m_checking_piece = 0;
|
m_checking_piece = 0;
|
||||||
m_num_checked_pieces = 0;
|
m_num_checked_pieces = 0;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("on_piece_hashed, disk_check_aborted");
|
debug_log("on_piece_hashed, disk_check_aborted");
|
||||||
#endif
|
#endif
|
||||||
pause();
|
pause();
|
||||||
|
@ -2554,7 +2545,7 @@ namespace libtorrent
|
||||||
m_ses.alerts().post_alert(file_error_alert(j->error.ec,
|
m_ses.alerts().post_alert(file_error_alert(j->error.ec,
|
||||||
resolve_filename(j->error.file), j->error.operation_str(), get_handle()));
|
resolve_filename(j->error.file), j->error.operation_str(), get_handle()));
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("on_piece_hashed, fatal disk error: (%d) %s", j->error.ec.value(), j->error.ec.message().c_str());
|
debug_log("on_piece_hashed, fatal disk error: (%d) %s", j->error.ec.value(), j->error.ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
auto_managed(false);
|
auto_managed(false);
|
||||||
|
@ -2573,7 +2564,7 @@ namespace libtorrent
|
||||||
// we're using the piece hashes here, we need the torrent to be loaded
|
// we're using the piece hashes here, we need the torrent to be loaded
|
||||||
if (!need_loaded())
|
if (!need_loaded())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("on_piece_hashed, need_loaded failed");
|
debug_log("on_piece_hashed, need_loaded failed");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -2619,7 +2610,7 @@ namespace libtorrent
|
||||||
// we paused the checking
|
// we paused the checking
|
||||||
if (!should_check_files())
|
if (!should_check_files())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("on_piece_hashed, checking paused");
|
debug_log("on_piece_hashed, checking paused");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -2627,7 +2618,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (!need_loaded())
|
if (!need_loaded())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("on_piece_hashed, need_loaded failed");
|
debug_log("on_piece_hashed, need_loaded failed");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -2638,13 +2629,13 @@ namespace libtorrent
|
||||||
, disk_io_job::sequential_access | disk_io_job::volatile_read
|
, disk_io_job::sequential_access | disk_io_job::volatile_read
|
||||||
, boost::bind(&torrent::on_piece_hashed
|
, boost::bind(&torrent::on_piece_hashed
|
||||||
, shared_from_this(), _1), (void*)1);
|
, shared_from_this(), _1), (void*)1);
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("on_piece_hashed, m_checking_piece: %d", m_checking_piece);
|
debug_log("on_piece_hashed, m_checking_piece: %d", m_checking_piece);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("on_piece_hashed, completed");
|
debug_log("on_piece_hashed, completed");
|
||||||
#endif
|
#endif
|
||||||
// we're done checking!
|
// we're done checking!
|
||||||
|
@ -2734,14 +2725,14 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
if (!m_ses.dht())
|
if (!m_ses.dht())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("DHT: no dht initialized");
|
debug_log("DHT: no dht initialized");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!should_announce_dht())
|
if (!should_announce_dht())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (!m_ses.announce_dht())
|
if (!m_ses.announce_dht())
|
||||||
debug_log("DHT: no listen sockets");
|
debug_log("DHT: no listen sockets");
|
||||||
|
|
||||||
|
@ -2782,7 +2773,7 @@ namespace libtorrent
|
||||||
int port = m_ses.listen_port();
|
int port = m_ses.listen_port();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("START DHT announce");
|
debug_log("START DHT announce");
|
||||||
m_dht_start_time = time_now_hires();
|
m_dht_start_time = time_now_hires();
|
||||||
#endif
|
#endif
|
||||||
|
@ -2814,7 +2805,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("END DHT announce (%d ms) (%d peers)"
|
debug_log("END DHT announce (%d ms) (%d peers)"
|
||||||
, int(total_milliseconds(time_now_hires() - m_dht_start_time))
|
, int(total_milliseconds(time_now_hires() - m_dht_start_time))
|
||||||
, int(peers.size()));
|
, int(peers.size()));
|
||||||
|
@ -2849,7 +2840,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (m_trackers.empty())
|
if (m_trackers.empty())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** announce_with_tracker: no trackers");
|
debug_log("*** announce_with_tracker: no trackers");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -2861,7 +2852,7 @@ namespace libtorrent
|
||||||
// stopping
|
// stopping
|
||||||
if (e != tracker_request::stopped && !m_announce_to_trackers)
|
if (e != tracker_request::stopped && !m_announce_to_trackers)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** announce_with_tracker: event != stopped && !m_announce_to_trackers");
|
debug_log("*** announce_with_tracker: event != stopped && !m_announce_to_trackers");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -2870,7 +2861,7 @@ namespace libtorrent
|
||||||
// if we're not allowing peers, there's no point in announcing
|
// if we're not allowing peers, there's no point in announcing
|
||||||
if (e != tracker_request::stopped && !m_allow_peers)
|
if (e != tracker_request::stopped && !m_allow_peers)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** announce_with_tracker: event != stopped && !m_allow_peers");
|
debug_log("*** announce_with_tracker: event != stopped && !m_allow_peers");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -2922,7 +2913,7 @@ namespace libtorrent
|
||||||
for (int i = 0; i < int(m_trackers.size()); ++i)
|
for (int i = 0; i < int(m_trackers.size()); ++i)
|
||||||
{
|
{
|
||||||
announce_entry& ae = m_trackers[i];
|
announce_entry& ae = m_trackers[i];
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** announce with tracker: considering \"%s\" "
|
debug_log("*** announce with tracker: considering \"%s\" "
|
||||||
"[ announce_to_all_tiers: %d announce_to_all_trackers: %d"
|
"[ announce_to_all_tiers: %d announce_to_all_trackers: %d"
|
||||||
" i->tier: %d tier: %d "
|
" i->tier: %d tier: %d "
|
||||||
|
@ -3003,7 +2994,7 @@ namespace libtorrent
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("==> TRACKER REQUEST \"%s\" event: %s abort: %d"
|
debug_log("==> TRACKER REQUEST \"%s\" event: %s abort: %d"
|
||||||
, req.url.c_str()
|
, req.url.c_str()
|
||||||
, (req.event==tracker_request::stopped?"stopped"
|
, (req.event==tracker_request::stopped?"stopped"
|
||||||
|
@ -3179,7 +3170,7 @@ namespace libtorrent
|
||||||
if (resp.complete >= 0 && resp.incomplete >= 0)
|
if (resp.complete >= 0 && resp.incomplete >= 0)
|
||||||
m_last_scrape = m_ses.session_time();
|
m_last_scrape = m_ses.session_time();
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("TRACKER RESPONSE\n"
|
debug_log("TRACKER RESPONSE\n"
|
||||||
"interval: %d\n"
|
"interval: %d\n"
|
||||||
"external ip: %s\n"
|
"external ip: %s\n"
|
||||||
|
@ -3319,7 +3310,7 @@ namespace libtorrent
|
||||||
?m_ses.get_ipv6_interface().address()
|
?m_ses.get_ipv6_interface().address()
|
||||||
:m_ses.get_ipv4_interface().address();
|
:m_ses.get_ipv4_interface().address();
|
||||||
announce_with_tracker(r.event, bind_interface);
|
announce_with_tracker(r.event, bind_interface);
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("announce again using %s as the bind interface"
|
debug_log("announce again using %s as the bind interface"
|
||||||
, print_address(bind_interface).c_str());
|
, print_address(bind_interface).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -3385,7 +3376,7 @@ namespace libtorrent
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
external_ip const& external = m_ses.external_address();
|
external_ip const& external = m_ses.external_address();
|
||||||
debug_log(" *** FOUND CONNECTION CANDIDATE ["
|
debug_log(" *** FOUND CONNECTION CANDIDATE ["
|
||||||
" ip: %s rank: %u external: %s t: %d ]"
|
" ip: %s rank: %u external: %s t: %d ]"
|
||||||
|
@ -3491,7 +3482,7 @@ namespace libtorrent
|
||||||
if (m_apply_ip_filter
|
if (m_apply_ip_filter
|
||||||
&& m_ses.get_ip_filter().access(host.address()) & ip_filter::blocked)
|
&& m_ses.get_ip_filter().access(host.address()) & ip_filter::blocked)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
error_code ec;
|
error_code ec;
|
||||||
debug_log("blocked ip from tracker: %s", host.address().to_string(ec).c_str());
|
debug_log("blocked ip from tracker: %s", host.address().to_string(ec).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -3852,7 +3843,7 @@ namespace libtorrent
|
||||||
// -1: disk failure
|
// -1: disk failure
|
||||||
// -2: piece failed check
|
// -2: piece failed check
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** PIECE_FINISHED [ p: %d | chk: %s | size: %d ]"
|
debug_log("*** PIECE_FINISHED [ p: %d | chk: %s | size: %d ]"
|
||||||
, j->piece, ((ret == 0)
|
, j->piece, ((ret == 0)
|
||||||
?"passed":ret == -1
|
?"passed":ret == -1
|
||||||
|
@ -4092,7 +4083,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
TORRENT_ASSERT(!m_picker->has_piece_passed(index));
|
TORRENT_ASSERT(!m_picker->has_piece_passed(index));
|
||||||
|
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("PIECE_PASSED (%d)", num_passed());
|
debug_log("PIECE_PASSED (%d)", num_passed());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -4167,7 +4158,7 @@ namespace libtorrent
|
||||||
for (peer_iterator p = m_connections.begin()
|
for (peer_iterator p = m_connections.begin()
|
||||||
, end(m_connections.end()); p != end; ++p)
|
, end(m_connections.end()); p != end; ++p)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
(*p)->peer_log(">>> PREDICTIVE_HAVE [ piece: %d expected in %d ms]"
|
(*p)->peer_log(">>> PREDICTIVE_HAVE [ piece: %d expected in %d ms]"
|
||||||
, index, milliseconds);
|
, index, milliseconds);
|
||||||
#endif
|
#endif
|
||||||
|
@ -4309,11 +4300,11 @@ namespace libtorrent
|
||||||
if (p->connection)
|
if (p->connection)
|
||||||
{
|
{
|
||||||
peer_connection* peer = static_cast<peer_connection*>(p->connection);
|
peer_connection* peer = static_cast<peer_connection*>(p->connection);
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** BANNING PEER: \"%s\" Too many corrupt pieces"
|
debug_log("*** BANNING PEER: \"%s\" Too many corrupt pieces"
|
||||||
, print_endpoint(p->ip()).c_str());
|
, print_endpoint(p->ip()).c_str());
|
||||||
#endif
|
#endif
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
peer->peer_log("*** BANNING PEER: Too many corrupt pieces");
|
peer->peer_log("*** BANNING PEER: Too many corrupt pieces");
|
||||||
#endif
|
#endif
|
||||||
peer->disconnect(errors::too_many_corrupt_pieces, peer_connection_interface::op_bittorrent);
|
peer->disconnect(errors::too_many_corrupt_pieces, peer_connection_interface::op_bittorrent);
|
||||||
|
@ -4671,7 +4662,7 @@ namespace libtorrent
|
||||||
error_code ec;
|
error_code ec;
|
||||||
m_inactivity_timer.cancel(ec);
|
m_inactivity_timer.cancel(ec);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
log_to_all_peers("ABORTING TORRENT");
|
log_to_all_peers("ABORTING TORRENT");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -5419,7 +5410,7 @@ namespace libtorrent
|
||||||
p->update_interest();
|
p->update_interest();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** UPDATE_PEER_INTEREST [ finished: %d was_finished %d ]"
|
debug_log("*** UPDATE_PEER_INTEREST [ finished: %d was_finished %d ]"
|
||||||
, is_finished(), was_finished);
|
, is_finished(), was_finished);
|
||||||
#endif
|
#endif
|
||||||
|
@ -5898,7 +5889,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("failed to parse web seed url: %s", ec.message().c_str());
|
debug_log("failed to parse web seed url: %s", ec.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
if (m_ses.alerts().should_post<url_seed_alert>())
|
if (m_ses.alerts().should_post<url_seed_alert>())
|
||||||
|
@ -5913,7 +5904,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (web->peer_info.banned)
|
if (web->peer_info.banned)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("banned web seed: %s", web->url.c_str());
|
debug_log("banned web seed: %s", web->url.c_str());
|
||||||
#endif
|
#endif
|
||||||
if (m_ses.alerts().should_post<url_seed_alert>())
|
if (m_ses.alerts().should_post<url_seed_alert>())
|
||||||
|
@ -5985,7 +5976,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("resolving web seed: %s", web->url.c_str());
|
debug_log("resolving web seed: %s", web->url.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -5993,7 +5984,7 @@ namespace libtorrent
|
||||||
if (ps.type == settings_pack::http
|
if (ps.type == settings_pack::http
|
||||||
|| ps.type == settings_pack::http_pw)
|
|| ps.type == settings_pack::http_pw)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("resolving proxy for web seed: %s", web->url.c_str());
|
debug_log("resolving proxy for web seed: %s", web->url.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -6011,7 +6002,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("resolving web seed: %s", web->url.c_str());
|
debug_log("resolving web seed: %s", web->url.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -6031,10 +6022,8 @@ namespace libtorrent
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
TORRENT_ASSERT(web->resolving == true);
|
TORRENT_ASSERT(web->resolving == true);
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("completed resolve proxy hostname for: %s", web->url.c_str());
|
debug_log("completed resolve proxy hostname for: %s", web->url.c_str());
|
||||||
#endif
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
if (e)
|
if (e)
|
||||||
debug_log("proxy name lookup error: %s", e.message().c_str());
|
debug_log("proxy name lookup error: %s", e.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -6042,7 +6031,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (web->removed)
|
if (web->removed)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("removed web seed");
|
debug_log("removed web seed");
|
||||||
#endif
|
#endif
|
||||||
remove_web_seed(web);
|
remove_web_seed(web);
|
||||||
|
@ -6118,13 +6107,13 @@ namespace libtorrent
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
TORRENT_ASSERT(web->resolving == true);
|
TORRENT_ASSERT(web->resolving == true);
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("completed resolve: %s", web->url.c_str());
|
debug_log("completed resolve: %s", web->url.c_str());
|
||||||
#endif
|
#endif
|
||||||
web->resolving = false;
|
web->resolving = false;
|
||||||
if (web->removed)
|
if (web->removed)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("removed web seed");
|
debug_log("removed web seed");
|
||||||
#endif
|
#endif
|
||||||
remove_web_seed(web);
|
remove_web_seed(web);
|
||||||
|
@ -6137,7 +6126,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
if (m_ses.alerts().should_post<url_seed_alert>())
|
if (m_ses.alerts().should_post<url_seed_alert>())
|
||||||
m_ses.alerts().post_alert(url_seed_alert(get_handle(), web->url, e));
|
m_ses.alerts().post_alert(url_seed_alert(get_handle(), web->url, e));
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** HOSTNAME LOOKUP FAILED: %s: (%d) %s"
|
debug_log("*** HOSTNAME LOOKUP FAILED: %s: (%d) %s"
|
||||||
, web->url.c_str(), e.value(), e.message().c_str());
|
, web->url.c_str(), e.value(), e.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -6153,7 +6142,7 @@ namespace libtorrent
|
||||||
// fill in the peer struct's address field
|
// fill in the peer struct's address field
|
||||||
web->endpoints.push_back(tcp::endpoint(*i, port));
|
web->endpoints.push_back(tcp::endpoint(*i, port));
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log(" -> %s", print_endpoint(tcp::endpoint(*i, port)).c_str());
|
debug_log(" -> %s", print_endpoint(tcp::endpoint(*i, port)).c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -6319,7 +6308,7 @@ namespace libtorrent
|
||||||
, boost::int64_t(web->peer_info.prev_amount_upload) << 10);
|
, boost::int64_t(web->peer_info.prev_amount_upload) << 10);
|
||||||
web->peer_info.prev_amount_download = 0;
|
web->peer_info.prev_amount_download = 0;
|
||||||
web->peer_info.prev_amount_upload = 0;
|
web->peer_info.prev_amount_upload = 0;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("web seed connection started: [%s] %s"
|
debug_log("web seed connection started: [%s] %s"
|
||||||
, print_endpoint(a).c_str(), web->url.c_str());
|
, print_endpoint(a).c_str(), web->url.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -6328,7 +6317,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (c->is_disconnecting()) return;
|
if (c->is_disconnecting()) return;
|
||||||
|
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("START queue peer [%p] (%d)", c.get(), num_peers());
|
debug_log("START queue peer [%p] (%d)", c.get(), num_peers());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -6336,7 +6325,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_DECLARE_DUMMY(std::exception, e);
|
TORRENT_DECLARE_DUMMY(std::exception, e);
|
||||||
(void)e;
|
(void)e;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** PEER_ERROR: %s", e.what());
|
debug_log("*** PEER_ERROR: %s", e.what());
|
||||||
#endif
|
#endif
|
||||||
c->disconnect(errors::no_error, peer_connection_interface::op_bittorrent, 1);
|
c->disconnect(errors::no_error, peer_connection_interface::op_bittorrent, 1);
|
||||||
|
@ -6489,7 +6478,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
// unknown country!
|
// unknown country!
|
||||||
p->set_country("!!");
|
p->set_country("!!");
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("IP \"%s\" was mapped to unknown country: %d"
|
debug_log("IP \"%s\" was mapped to unknown country: %d"
|
||||||
, print_address(p->remote().address()).c_str(), country);
|
, print_address(p->remote().address()).c_str(), country);
|
||||||
#endif
|
#endif
|
||||||
|
@ -7666,7 +7655,7 @@ namespace libtorrent
|
||||||
++m_num_seeds;
|
++m_num_seeds;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("incoming peer (%d)", int(m_connections.size()));
|
debug_log("incoming peer (%d)", int(m_connections.size()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -7819,9 +7808,6 @@ namespace libtorrent
|
||||||
peer_connection* p = *m_connections.begin();
|
peer_connection* p = *m_connections.begin();
|
||||||
TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
|
TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
|
||||||
p->peer_log("*** CLOSING CONNECTION \"%s\"", ec.message().c_str());
|
|
||||||
#endif
|
|
||||||
#if TORRENT_USE_ASSERTS
|
#if TORRENT_USE_ASSERTS
|
||||||
std::size_t size = m_connections.size();
|
std::size_t size = m_connections.size();
|
||||||
#endif
|
#endif
|
||||||
|
@ -7945,7 +7931,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
|
TORRENT_ASSERT(p->associated_torrent().lock().get() == this);
|
||||||
if (p->upload_only())
|
if (p->upload_only())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
p->peer_log("*** SEED, CLOSING CONNECTION");
|
p->peer_log("*** SEED, CLOSING CONNECTION");
|
||||||
#endif
|
#endif
|
||||||
seeds.push_back(p);
|
seeds.push_back(p);
|
||||||
|
@ -7986,7 +7972,7 @@ namespace libtorrent
|
||||||
|| m_state == torrent_status::checking_files
|
|| m_state == torrent_status::checking_files
|
||||||
|| m_state == torrent_status::allocating)
|
|| m_state == torrent_status::allocating)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** RESUME_DOWNLOAD [ skipping, state: %d ]"
|
debug_log("*** RESUME_DOWNLOAD [ skipping, state: %d ]"
|
||||||
, int(m_state));
|
, int(m_state));
|
||||||
#endif
|
#endif
|
||||||
|
@ -7999,7 +7985,7 @@ namespace libtorrent
|
||||||
|
|
||||||
m_completed_time = 0;
|
m_completed_time = 0;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** RESUME_DOWNLOAD");
|
debug_log("*** RESUME_DOWNLOAD");
|
||||||
#endif
|
#endif
|
||||||
send_upload_only();
|
send_upload_only();
|
||||||
|
@ -8095,7 +8081,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (m_abort)
|
if (m_abort)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("files_checked(), paused");
|
debug_log("files_checked(), paused");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -8186,7 +8172,7 @@ namespace libtorrent
|
||||||
pc->init();
|
pc->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
pc->peer_log("*** ON_FILES_CHECKED");
|
pc->peer_log("*** ON_FILES_CHECKED");
|
||||||
#endif
|
#endif
|
||||||
if (pc->is_interesting() && !pc->has_peer_choked())
|
if (pc->is_interesting() && !pc->has_peer_choked())
|
||||||
|
@ -8665,7 +8651,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
log_to_all_peers("DELETING FILES IN TORRENT");
|
log_to_all_peers("DELETING FILES IN TORRENT");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -8737,7 +8723,7 @@ namespace libtorrent
|
||||||
if (alerts().should_post<torrent_error_alert>())
|
if (alerts().should_post<torrent_error_alert>())
|
||||||
alerts().post_alert(torrent_error_alert(get_handle(), ec, resolve_filename(error_file)));
|
alerts().post_alert(torrent_error_alert(get_handle(), ec, resolve_filename(error_file)));
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
@ -9077,7 +9063,7 @@ namespace libtorrent
|
||||||
update_want_peers();
|
update_want_peers();
|
||||||
update_want_scrape();
|
update_want_scrape();
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
log_to_all_peers("PAUSING TORRENT");
|
log_to_all_peers("PAUSING TORRENT");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -9134,7 +9120,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (p->outstanding_bytes() > 0)
|
if (p->outstanding_bytes() > 0)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
p->peer_log("*** CHOKING PEER: torrent graceful paused");
|
p->peer_log("*** CHOKING PEER: torrent graceful paused");
|
||||||
#endif
|
#endif
|
||||||
// remove any un-sent requests from the queue
|
// remove any un-sent requests from the queue
|
||||||
|
@ -9144,7 +9130,7 @@ namespace libtorrent
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
p->peer_log("*** CLOSING CONNECTION: torrent_paused");
|
p->peer_log("*** CLOSING CONNECTION: torrent_paused");
|
||||||
#endif
|
#endif
|
||||||
p->disconnect(errors::torrent_paused, peer_connection_interface::op_bittorrent);
|
p->disconnect(errors::torrent_paused, peer_connection_interface::op_bittorrent);
|
||||||
|
@ -9166,11 +9152,11 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
void torrent::log_to_all_peers(char const* message)
|
void torrent::log_to_all_peers(char const* message)
|
||||||
{
|
{
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
for (peer_iterator i = m_connections.begin();
|
for (peer_iterator i = m_connections.begin();
|
||||||
i != m_connections.end(); ++i)
|
i != m_connections.end(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -9295,7 +9281,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
if (!m_announcing)
|
if (!m_announcing)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** update tracker timer: not announcing");
|
debug_log("*** update tracker timer: not announcing");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -9309,7 +9295,7 @@ namespace libtorrent
|
||||||
for (std::vector<announce_entry>::iterator i = m_trackers.begin()
|
for (std::vector<announce_entry>::iterator i = m_trackers.begin()
|
||||||
, end(m_trackers.end()); i != end; ++i)
|
, end(m_trackers.end()); i != end; ++i)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
char msg[1000];
|
char msg[1000];
|
||||||
snprintf(msg, sizeof(msg), "*** update tracker timer: considering \"%s\" "
|
snprintf(msg, sizeof(msg), "*** update tracker timer: considering \"%s\" "
|
||||||
"[ announce_to_all_tiers: %d announce_to_all_trackers: %d"
|
"[ announce_to_all_tiers: %d announce_to_all_trackers: %d"
|
||||||
|
@ -9347,7 +9333,7 @@ namespace libtorrent
|
||||||
&& !settings().get_bool(settings_pack::announce_to_all_tiers)) break;
|
&& !settings().get_bool(settings_pack::announce_to_all_tiers)) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
char msg[200];
|
char msg[200];
|
||||||
snprintf(msg, sizeof(msg), "*** update tracker timer: next_announce < now %d"
|
snprintf(msg, sizeof(msg), "*** update tracker timer: next_announce < now %d"
|
||||||
" m_waiting_tracker: %d next_announce_in: %d"
|
" m_waiting_tracker: %d next_announce_in: %d"
|
||||||
|
@ -9377,7 +9363,7 @@ namespace libtorrent
|
||||||
TORRENT_ASSERT(is_single_thread());
|
TORRENT_ASSERT(is_single_thread());
|
||||||
if (is_paused())
|
if (is_paused())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("start_announcing(), paused");
|
debug_log("start_announcing(), paused");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -9387,14 +9373,14 @@ namespace libtorrent
|
||||||
// request the metadata from
|
// request the metadata from
|
||||||
if (!m_files_checked && valid_metadata())
|
if (!m_files_checked && valid_metadata())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("start_announcing(), files not checked (with valid metadata)");
|
debug_log("start_announcing(), files not checked (with valid metadata)");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_torrent_file->is_valid() && !m_url.empty())
|
if (!m_torrent_file->is_valid() && !m_url.empty())
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("start_announcing(), downloading URL");
|
debug_log("start_announcing(), downloading URL");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -9626,7 +9612,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
TORRENT_DECLARE_DUMMY(std::exception, e);
|
TORRENT_DECLARE_DUMMY(std::exception, e);
|
||||||
(void)e;
|
(void)e;
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
p->peer_log("*** ERROR %s", e.what());
|
p->peer_log("*** ERROR %s", e.what());
|
||||||
#endif
|
#endif
|
||||||
p->disconnect(errors::no_error, peer_connection_interface::op_bittorrent, 1);
|
p->disconnect(errors::no_error, peer_connection_interface::op_bittorrent, 1);
|
||||||
|
@ -10558,7 +10544,7 @@ namespace libtorrent
|
||||||
|
|
||||||
TORRENT_ASSERT(i->resolving == false);
|
TORRENT_ASSERT(i->resolving == false);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("disconnect web seed: \"%s\"", i->url.c_str());
|
debug_log("disconnect web seed: \"%s\"", i->url.c_str());
|
||||||
#endif
|
#endif
|
||||||
TORRENT_ASSERT(i->peer_info.connection);
|
TORRENT_ASSERT(i->peer_info.connection);
|
||||||
|
@ -11127,7 +11113,7 @@ namespace libtorrent
|
||||||
|
|
||||||
m_state = s;
|
m_state = s;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("set_state() %d", m_state);
|
debug_log("set_state() %d", m_state);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -11466,7 +11452,7 @@ namespace libtorrent
|
||||||
|
|
||||||
INVARIANT_CHECK;
|
INVARIANT_CHECK;
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** tracker error: (%d) %s %s", ec.value(), ec.message().c_str(), msg.c_str());
|
debug_log("*** tracker error: (%d) %s %s", ec.value(), ec.message().c_str(), msg.c_str());
|
||||||
#endif
|
#endif
|
||||||
if (r.kind == tracker_request::announce_request)
|
if (r.kind == tracker_request::announce_request)
|
||||||
|
@ -11478,7 +11464,7 @@ namespace libtorrent
|
||||||
ae->last_error = ec;
|
ae->last_error = ec;
|
||||||
ae->message = msg;
|
ae->message = msg;
|
||||||
int tracker_index = ae - &m_trackers[0];
|
int tracker_index = ae - &m_trackers[0];
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
debug_log("*** increment tracker fail count [%d]", ae->fails);
|
debug_log("*** increment tracker fail count [%d]", ae->fails);
|
||||||
#endif
|
#endif
|
||||||
// never talk to this tracker again
|
// never talk to this tracker again
|
||||||
|
@ -11512,20 +11498,20 @@ namespace libtorrent
|
||||||
update_tracker_timer(time_now());
|
update_tracker_timer(time_now());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
void torrent::debug_log(char const* fmt, ...) const
|
void torrent::debug_log(char const* fmt, ...) const
|
||||||
{
|
{
|
||||||
if (!m_logger) return;
|
if (!alerts().should_post<torrent_log_alert>()) return;
|
||||||
|
|
||||||
va_list v;
|
va_list v;
|
||||||
va_start(v, fmt);
|
va_start(v, fmt);
|
||||||
|
|
||||||
char usr[400];
|
char buf[400];
|
||||||
vsnprintf(usr, sizeof(usr), fmt, v);
|
vsnprintf(buf, sizeof(buf), fmt, v);
|
||||||
va_end(v);
|
va_end(v);
|
||||||
char buf[450];
|
|
||||||
snprintf(buf, sizeof(buf), "%" PRId64 ": %s\n", total_microseconds(time_now_hires() - m_logger_time), usr);
|
alerts().post_alert(torrent_log_alert(
|
||||||
(*m_logger) << buf;
|
const_cast<torrent*>(this)->get_handle(), buf));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,7 @@ namespace libtorrent
|
||||||
|
|
||||||
close_http_connections.push_back(*i);
|
close_http_connections.push_back(*i);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<request_callback> rc = c->requester();
|
boost::shared_ptr<request_callback> rc = c->requester();
|
||||||
if (rc) rc->debug_log("aborting: %s", req.url.c_str());
|
if (rc) rc->debug_log("aborting: %s", req.url.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -374,7 +374,7 @@ namespace libtorrent
|
||||||
|
|
||||||
close_udp_connections.push_back(c);
|
close_udp_connections.push_back(c);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<request_callback> rc = c->requester();
|
boost::shared_ptr<request_callback> rc = c->requester();
|
||||||
if (rc) rc->debug_log("aborting: %s", req.url.c_str());
|
if (rc) rc->debug_log("aborting: %s", req.url.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,7 +55,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/resolver_interface.hpp"
|
#include "libtorrent/resolver_interface.hpp"
|
||||||
#include "libtorrent/ip_filter.hpp"
|
#include "libtorrent/ip_filter.hpp"
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
#include "libtorrent/socket_io.hpp"
|
#include "libtorrent/socket_io.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ namespace libtorrent
|
||||||
, boost::bind(&udp_tracker_connection::name_lookup
|
, boost::bind(&udp_tracker_connection::name_lookup
|
||||||
, shared_from_this(), _1, _2, port));
|
, shared_from_this(), _1, _2, port));
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
if (cb) cb->debug_log("*** UDP_TRACKER [ initiating name lookup: \"%s\" ]"
|
if (cb) cb->debug_log("*** UDP_TRACKER [ initiating name lookup: \"%s\" ]"
|
||||||
, hostname.c_str());
|
, hostname.c_str());
|
||||||
|
@ -153,7 +153,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
if (cb) cb->debug_log("*** UDP_TRACKER [ host: \"%s\" ip: \"%s\" | error: \"%s\" ]"
|
if (cb) cb->debug_log("*** UDP_TRACKER [ host: \"%s\" ip: \"%s\" | error: \"%s\" ]"
|
||||||
, m_hostname.c_str(), print_endpoint(m_target).c_str(), ec.message().c_str());
|
, m_hostname.c_str(), print_endpoint(m_target).c_str(), ec.message().c_str());
|
||||||
|
@ -162,7 +162,7 @@ namespace libtorrent
|
||||||
// pick another target endpoint and try again
|
// pick another target endpoint and try again
|
||||||
m_target = pick_target_endpoint();
|
m_target = pick_target_endpoint();
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (cb) cb->debug_log("*** UDP_TRACKER trying next IP [ host: \"%s\" ip: \"%s\" ]"
|
if (cb) cb->debug_log("*** UDP_TRACKER trying next IP [ host: \"%s\" ip: \"%s\" ]"
|
||||||
, m_hostname.c_str(), print_endpoint(m_target).c_str());
|
, m_hostname.c_str(), print_endpoint(m_target).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -185,7 +185,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (cb) cb->debug_log("*** UDP_TRACKER [ name lookup successful ]");
|
if (cb) cb->debug_log("*** UDP_TRACKER [ name lookup successful ]");
|
||||||
#endif
|
#endif
|
||||||
if (cancelled())
|
if (cancelled())
|
||||||
|
@ -212,7 +212,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
if (m_man.ip_filter().access(k->address()) == ip_filter::blocked)
|
if (m_man.ip_filter().access(k->address()) == ip_filter::blocked)
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (cb) cb->debug_log("*** UDP_TRACKER [ IP blocked by filter: %s ]"
|
if (cb) cb->debug_log("*** UDP_TRACKER [ IP blocked by filter: %s ]"
|
||||||
, print_address(k->address()).c_str());
|
, print_address(k->address()).c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -306,7 +306,7 @@ namespace libtorrent
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
if (cb) cb->debug_log("*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str());
|
if (cb) cb->debug_log("*** UDP_TRACKER [ timed out url: %s ]", tracker_req().url.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
@ -346,7 +346,7 @@ namespace libtorrent
|
||||||
|
|
||||||
if (e) fail(e);
|
if (e) fail(e);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
if (cb)
|
if (cb)
|
||||||
{
|
{
|
||||||
|
@ -361,7 +361,7 @@ namespace libtorrent
|
||||||
int action = detail::read_int32(ptr);
|
int action = detail::read_int32(ptr);
|
||||||
boost::uint32_t transaction = detail::read_uint32(ptr);
|
boost::uint32_t transaction = detail::read_uint32(ptr);
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (cb)
|
if (cb)
|
||||||
{
|
{
|
||||||
cb->debug_log("*** UDP_TRACKER_PACKET [ action: %d ]", action);
|
cb->debug_log("*** UDP_TRACKER_PACKET [ action: %d ]", action);
|
||||||
|
@ -382,7 +382,7 @@ namespace libtorrent
|
||||||
|
|
||||||
restart_read_timeout();
|
restart_read_timeout();
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (cb)
|
if (cb)
|
||||||
{
|
{
|
||||||
cb->debug_log("*** UDP_TRACKER_RESPONSE [ tid: %x ]"
|
cb->debug_log("*** UDP_TRACKER_RESPONSE [ tid: %x ]"
|
||||||
|
@ -443,7 +443,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void udp_tracker_connection::send_udp_connect()
|
void udp_tracker_connection::send_udp_connect()
|
||||||
{
|
{
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
if (cb)
|
if (cb)
|
||||||
{
|
{
|
||||||
|
@ -547,7 +547,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
if (cb)
|
if (cb)
|
||||||
{
|
{
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
|
@ -695,7 +695,7 @@ namespace libtorrent
|
||||||
|
|
||||||
TORRENT_ASSERT(out - buf <= int(sizeof(buf)));
|
TORRENT_ASSERT(out - buf <= int(sizeof(buf)));
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
boost::shared_ptr<request_callback> cb = requester();
|
boost::shared_ptr<request_callback> cb = requester();
|
||||||
if (cb)
|
if (cb)
|
||||||
{
|
{
|
||||||
|
|
|
@ -258,7 +258,7 @@ namespace libtorrent { namespace
|
||||||
TORRENT_ASSERT(type >= 0 && type <= 2);
|
TORRENT_ASSERT(type >= 0 && type <= 2);
|
||||||
TORRENT_ASSERT(!m_pc.associated_torrent().expired());
|
TORRENT_ASSERT(!m_pc.associated_torrent().expired());
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
char const* names[] = {"request", "data", "dont-have"};
|
char const* names[] = {"request", "data", "dont-have"};
|
||||||
char const* n = "";
|
char const* n = "";
|
||||||
if (type >= 0 && type < 3) n = names[type];
|
if (type >= 0 && type < 3) n = names[type];
|
||||||
|
@ -280,7 +280,7 @@ namespace libtorrent { namespace
|
||||||
|
|
||||||
if (piece < 0 || piece >= int(m_tp.get_metadata_size() + 16 * 1024 - 1)/(16*1024))
|
if (piece < 0 || piece >= int(m_tp.get_metadata_size() + 16 * 1024 - 1)/(16*1024))
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("*** UT_METADATA [ invalid piece %d metadata size: %d ]"
|
m_pc.peer_log("*** UT_METADATA [ invalid piece %d metadata size: %d ]"
|
||||||
, piece, int(m_tp.get_metadata_size()));
|
, piece, int(m_tp.get_metadata_size()));
|
||||||
#endif
|
#endif
|
||||||
|
@ -330,7 +330,7 @@ namespace libtorrent { namespace
|
||||||
|
|
||||||
if (length > 17 * 1024)
|
if (length > 17 * 1024)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("<== UT_METADATA [ packet too big %d ]", length);
|
m_pc.peer_log("<== UT_METADATA [ packet too big %d ]", length);
|
||||||
#endif
|
#endif
|
||||||
m_pc.disconnect(errors::invalid_metadata_message, peer_connection_interface::op_bittorrent, 2);
|
m_pc.disconnect(errors::invalid_metadata_message, peer_connection_interface::op_bittorrent, 2);
|
||||||
|
@ -343,7 +343,7 @@ namespace libtorrent { namespace
|
||||||
entry msg = bdecode(body.begin, body.end, len);
|
entry msg = bdecode(body.begin, body.end, len);
|
||||||
if (msg.type() != entry::dictionary_t)
|
if (msg.type() != entry::dictionary_t)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("<== UT_METADATA [ not a dictionary ]");
|
m_pc.peer_log("<== UT_METADATA [ not a dictionary ]");
|
||||||
#endif
|
#endif
|
||||||
m_pc.disconnect(errors::invalid_metadata_message, peer_connection_interface::op_bittorrent, 2);
|
m_pc.disconnect(errors::invalid_metadata_message, peer_connection_interface::op_bittorrent, 2);
|
||||||
|
@ -355,7 +355,7 @@ namespace libtorrent { namespace
|
||||||
if (type_ent == 0 || type_ent->type() != entry::int_t
|
if (type_ent == 0 || type_ent->type() != entry::int_t
|
||||||
|| piece_ent == 0 || piece_ent->type() != entry::int_t)
|
|| piece_ent == 0 || piece_ent->type() != entry::int_t)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("<== UT_METADATA [ missing or invalid keys ]");
|
m_pc.peer_log("<== UT_METADATA [ missing or invalid keys ]");
|
||||||
#endif
|
#endif
|
||||||
m_pc.disconnect(errors::invalid_metadata_message, peer_connection_interface::op_bittorrent, 2);
|
m_pc.disconnect(errors::invalid_metadata_message, peer_connection_interface::op_bittorrent, 2);
|
||||||
|
@ -364,7 +364,7 @@ namespace libtorrent { namespace
|
||||||
int type = type_ent->integer();
|
int type = type_ent->integer();
|
||||||
int piece = piece_ent->integer();
|
int piece = piece_ent->integer();
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("<== UT_METADATA [ type: %d | piece: %d ]", type, piece);
|
m_pc.peer_log("<== UT_METADATA [ type: %d | piece: %d ]", type, piece);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ namespace libtorrent { namespace
|
||||||
// unwanted piece?
|
// unwanted piece?
|
||||||
if (i == m_sent_requests.end())
|
if (i == m_sent_requests.end())
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("*** UT_METADATA [ UNWANTED / TIMED OUT ]");
|
m_pc.peer_log("*** UT_METADATA [ UNWANTED / TIMED OUT ]");
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
|
@ -541,7 +541,7 @@ namespace libtorrent { namespace
|
||||||
{
|
{
|
||||||
if (m_torrent.valid_metadata())
|
if (m_torrent.valid_metadata())
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
source.m_pc.peer_log("*** UT_METADATA [ ALREADY HAVE METADATA ]");
|
source.m_pc.peer_log("*** UT_METADATA [ ALREADY HAVE METADATA ]");
|
||||||
#endif
|
#endif
|
||||||
m_torrent.add_redundant_bytes(size, torrent::piece_unknown);
|
m_torrent.add_redundant_bytes(size, torrent::piece_unknown);
|
||||||
|
@ -553,7 +553,7 @@ namespace libtorrent { namespace
|
||||||
// verify the total_size
|
// verify the total_size
|
||||||
if (total_size <= 0 || total_size > m_torrent.session().settings().get_int(settings_pack::max_metadata_size))
|
if (total_size <= 0 || total_size > m_torrent.session().settings().get_int(settings_pack::max_metadata_size))
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
source.m_pc.peer_log("*** UT_METADATA [ metadata size too big: %d ]", total_size);
|
source.m_pc.peer_log("*** UT_METADATA [ metadata size too big: %d ]", total_size);
|
||||||
#endif
|
#endif
|
||||||
// #error post alert
|
// #error post alert
|
||||||
|
@ -567,7 +567,7 @@ namespace libtorrent { namespace
|
||||||
|
|
||||||
if (piece < 0 || piece >= int(m_requested_metadata.size()))
|
if (piece < 0 || piece >= int(m_requested_metadata.size()))
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
source.m_pc.peer_log("*** UT_METADATA [ piece: %d INVALID ]", piece);
|
source.m_pc.peer_log("*** UT_METADATA [ piece: %d INVALID ]", piece);
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
|
@ -575,7 +575,7 @@ namespace libtorrent { namespace
|
||||||
|
|
||||||
if (total_size != m_metadata_size)
|
if (total_size != m_metadata_size)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
source.m_pc.peer_log("*** UT_METADATA [ total_size: %d INCONSISTENT WITH: %d ]"
|
source.m_pc.peer_log("*** UT_METADATA [ total_size: %d INCONSISTENT WITH: %d ]"
|
||||||
, total_size, m_metadata_size);
|
, total_size, m_metadata_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,7 +56,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/extensions/ut_pex.hpp"
|
#include "libtorrent/extensions/ut_pex.hpp"
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
#include "libtorrent/lazy_entry.hpp"
|
#include "libtorrent/lazy_entry.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ namespace libtorrent { namespace
|
||||||
|
|
||||||
lazy_entry const* p = pex_msg.dict_find_string("dropped");
|
lazy_entry const* p = pex_msg.dict_find_string("dropped");
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
int num_dropped = 0;
|
int num_dropped = 0;
|
||||||
int num_added = 0;
|
int num_added = 0;
|
||||||
if (p) num_dropped += p->string_length()/6;
|
if (p) num_dropped += p->string_length()/6;
|
||||||
|
@ -333,7 +333,7 @@ namespace libtorrent { namespace
|
||||||
p = pex_msg.dict_find_string("added");
|
p = pex_msg.dict_find_string("added");
|
||||||
lazy_entry const* pf = pex_msg.dict_find_string("added.f");
|
lazy_entry const* pf = pex_msg.dict_find_string("added.f");
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
if (p) num_added += p->string_length() / 6;
|
if (p) num_added += p->string_length() / 6;
|
||||||
#endif
|
#endif
|
||||||
if (p != 0
|
if (p != 0
|
||||||
|
@ -367,7 +367,7 @@ namespace libtorrent { namespace
|
||||||
#if TORRENT_USE_IPV6
|
#if TORRENT_USE_IPV6
|
||||||
|
|
||||||
lazy_entry const* p6 = pex_msg.dict_find("dropped6");
|
lazy_entry const* p6 = pex_msg.dict_find("dropped6");
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
if (p6) num_dropped += p6->string_length() / 18;
|
if (p6) num_dropped += p6->string_length() / 18;
|
||||||
#endif
|
#endif
|
||||||
if (p6 != 0 && p6->type() == lazy_entry::string_t)
|
if (p6 != 0 && p6->type() == lazy_entry::string_t)
|
||||||
|
@ -385,7 +385,7 @@ namespace libtorrent { namespace
|
||||||
}
|
}
|
||||||
|
|
||||||
p6 = pex_msg.dict_find("added6");
|
p6 = pex_msg.dict_find("added6");
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
if (p6) num_added += p6->string_length() / 18;
|
if (p6) num_added += p6->string_length() / 18;
|
||||||
#endif
|
#endif
|
||||||
lazy_entry const* p6f = pex_msg.dict_find("added6.f");
|
lazy_entry const* p6f = pex_msg.dict_find("added6.f");
|
||||||
|
@ -417,7 +417,7 @@ namespace libtorrent { namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("<== PEX [ dropped: %d added: %d ]"
|
m_pc.peer_log("<== PEX [ dropped: %d added: %d ]"
|
||||||
, num_dropped, num_added);
|
, num_dropped, num_added);
|
||||||
#endif
|
#endif
|
||||||
|
@ -436,7 +436,7 @@ namespace libtorrent { namespace
|
||||||
ptime now = time_now();
|
ptime now = time_now();
|
||||||
if (now - seconds(60) < m_last_msg)
|
if (now - seconds(60) < m_last_msg)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("*** PEX [ waiting: %d seconds to next msg ]"
|
m_pc.peer_log("*** PEX [ waiting: %d seconds to next msg ]"
|
||||||
, total_seconds(seconds(60) - (now - m_last_msg)));
|
, total_seconds(seconds(60) - (now - m_last_msg)));
|
||||||
#endif
|
#endif
|
||||||
|
@ -454,7 +454,7 @@ namespace libtorrent { namespace
|
||||||
|
|
||||||
if (now - milliseconds(delay) < global_last)
|
if (now - milliseconds(delay) < global_last)
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("*** PEX [ global-wait: %d ]", total_seconds(milliseconds(delay) - (now - global_last)));
|
m_pc.peer_log("*** PEX [ global-wait: %d ]", total_seconds(milliseconds(delay) - (now - global_last)));
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
|
@ -499,7 +499,7 @@ namespace libtorrent { namespace
|
||||||
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
|
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
lazy_entry m;
|
lazy_entry m;
|
||||||
error_code ec;
|
error_code ec;
|
||||||
int ret = lazy_bdecode(&pex_msg[0], &pex_msg[0] + pex_msg.size(), m, ec);
|
int ret = lazy_bdecode(&pex_msg[0], &pex_msg[0] + pex_msg.size(), m, ec);
|
||||||
|
@ -607,7 +607,7 @@ namespace libtorrent { namespace
|
||||||
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_extended);
|
||||||
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
|
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
m_pc.peer_log("==> PEX_FULL [ added: %d msg_size: %d ]", num_added, int(pex_msg.size()));
|
m_pc.peer_log("==> PEX_FULL [ added: %d msg_size: %d ]", num_added, int(pex_msg.size()));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -654,7 +654,7 @@ struct utp_socket_impl
|
||||||
bool m_stalled:1;
|
bool m_stalled:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
int socket_impl_size() { return sizeof(utp_socket_impl); }
|
int socket_impl_size() { return sizeof(utp_socket_impl); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ web_peer_connection::web_peer_connection(peer_connection_args const& pack
|
||||||
// into single larger ones
|
// into single larger ones
|
||||||
request_large_blocks(true);
|
request_large_blocks(true);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** web_peer_connection %s", m_url.c_str());
|
peer_log("*** web_peer_connection %s", m_url.c_str());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ void web_peer_connection::write_request(peer_request const& r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("==> %s", request.c_str());
|
peer_log("==> %s", request.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ void web_peer_connection::on_receive(error_code const& error
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
received_bytes(0, bytes_transferred);
|
received_bytes(0, bytes_transferred);
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** web_peer_connection error: %s", error.message().c_str());
|
peer_log("*** web_peer_connection error: %s", error.message().c_str());
|
||||||
#endif
|
#endif
|
||||||
#ifdef TORRENT_DEBUG
|
#ifdef TORRENT_DEBUG
|
||||||
|
@ -526,7 +526,7 @@ void web_peer_connection::on_receive(error_code const& error
|
||||||
if (failed)
|
if (failed)
|
||||||
{
|
{
|
||||||
received_bytes(0, bytes_transferred);
|
received_bytes(0, bytes_transferred);
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** %s", std::string(recv_buffer.begin, recv_buffer.end).c_str());
|
peer_log("*** %s", std::string(recv_buffer.begin, recv_buffer.end).c_str());
|
||||||
#endif
|
#endif
|
||||||
disconnect(errors::http_parse_error, op_bittorrent, 2);
|
disconnect(errors::http_parse_error, op_bittorrent, 2);
|
||||||
|
@ -583,7 +583,7 @@ void web_peer_connection::on_receive(error_code const& error
|
||||||
m_web->supports_keepalive = false;
|
m_web->supports_keepalive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** STATUS: %d %s", m_parser.status_code(), m_parser.message().c_str());
|
peer_log("*** STATUS: %d %s", m_parser.status_code(), m_parser.message().c_str());
|
||||||
std::multimap<std::string, std::string> const& headers = m_parser.headers();
|
std::multimap<std::string, std::string> const& headers = m_parser.headers();
|
||||||
for (std::multimap<std::string, std::string>::const_iterator i = headers.begin()
|
for (std::multimap<std::string, std::string>::const_iterator i = headers.begin()
|
||||||
|
@ -681,7 +681,7 @@ void web_peer_connection::on_receive(error_code const& error
|
||||||
location = resolve_redirect_location(m_url, location);
|
location = resolve_redirect_location(m_url, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** LOCATION: %s", location.c_str());
|
peer_log("*** LOCATION: %s", location.c_str());
|
||||||
#endif
|
#endif
|
||||||
t->add_web_seed(location, web_seed_entry::url_seed, m_external_auth, m_extra_headers);
|
t->add_web_seed(location, web_seed_entry::url_seed, m_external_auth, m_extra_headers);
|
||||||
|
@ -790,7 +790,7 @@ void web_peer_connection::on_receive(error_code const& error
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size);
|
peer_log("*** parsed chunk: %d header_size: %d", chunk_size, header_size);
|
||||||
#endif
|
#endif
|
||||||
TORRENT_ASSERT(int(bytes_transferred) >= header_size - m_partial_chunk_header);
|
TORRENT_ASSERT(int(bytes_transferred) >= header_size - m_partial_chunk_header);
|
||||||
|
@ -840,7 +840,7 @@ void web_peer_connection::on_receive(error_code const& error
|
||||||
|
|
||||||
TORRENT_ASSERT(m_block_pos >= 0);
|
TORRENT_ASSERT(m_block_pos >= 0);
|
||||||
|
|
||||||
#ifdef TORRENT_VERBOSE_LOGGING
|
#ifdef TORRENT_LOGGING
|
||||||
peer_log("*** payload_transferred: %d [ %d:%d = %d ]"
|
peer_log("*** payload_transferred: %d [ %d:%d = %d ]"
|
||||||
, payload_transferred, front_request.piece
|
, payload_transferred, front_request.piece
|
||||||
, front_request.start, front_request.length);
|
, front_request.start, front_request.length);
|
||||||
|
|
|
@ -63,7 +63,7 @@ struct mock_peer_connection : peer_connection_interface
|
||||||
for (int i = 0; i < 20; ++i) m_id[i] = rand();
|
for (int i = 0; i < 20; ++i) m_id[i] = rand();
|
||||||
}
|
}
|
||||||
virtual ~mock_peer_connection() {}
|
virtual ~mock_peer_connection() {}
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
virtual void peer_log(char const* fmt, ...) const
|
virtual void peer_log(char const* fmt, ...) const
|
||||||
{
|
{
|
||||||
va_list v;
|
va_list v;
|
||||||
|
@ -114,7 +114,7 @@ struct mock_torrent
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined TORRENT_VERBOSE_LOGGING || defined TORRENT_LOGGING || defined TORRENT_ERROR_LOGGING
|
#if defined TORRENT_LOGGING
|
||||||
void debug_log(const char* fmt, ...) const
|
void debug_log(const char* fmt, ...) const
|
||||||
{
|
{
|
||||||
va_list v;
|
va_list v;
|
||||||
|
|
Loading…
Reference in New Issue