factor out strings of peer logs to be enums instead, in peer_log_alert
This commit is contained in:
parent
a3a59496d8
commit
4f216dece3
1
Jamfile
1
Jamfile
|
@ -257,6 +257,7 @@ rule warnings ( properties * )
|
|||
{
|
||||
result += <cflags>-Wall ;
|
||||
result += <cflags>-Wextra ;
|
||||
result += <cflags>-Wno-format-zero-length ;
|
||||
|
||||
# enable these warnings again, once the other ones are dealt with
|
||||
result += <cflags>-Wno-sign-compare ;
|
||||
|
|
|
@ -2160,16 +2160,34 @@ namespace libtorrent
|
|||
// default it is disabled as a build configuration.
|
||||
struct TORRENT_EXPORT peer_log_alert : peer_alert
|
||||
{
|
||||
// describes whether this log refers to in-flow or out-flow of the
|
||||
// peer. The exception is ``info`` which is neither incoming or outgoing.
|
||||
enum direction_t
|
||||
{
|
||||
incoming_message,
|
||||
outgoing_message,
|
||||
incoming,
|
||||
outgoing,
|
||||
info,
|
||||
};
|
||||
|
||||
// internal
|
||||
peer_log_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
||||
, tcp::endpoint const& i
|
||||
, peer_id const& pi, char const* log);
|
||||
, tcp::endpoint const& i, peer_id const& pi
|
||||
, peer_log_alert::direction_t dir
|
||||
, char const* event, char const* log);
|
||||
|
||||
TORRENT_DEFINE_ALERT(peer_log_alert, 81)
|
||||
|
||||
static const int static_category = alert::peer_log_notification;
|
||||
virtual std::string message() const;
|
||||
|
||||
// string literal indicating the kind of event. For messages, this is the
|
||||
// message name.
|
||||
char const* event_type;
|
||||
|
||||
direction_t direction;
|
||||
|
||||
// returns the log message
|
||||
char const* msg() const;
|
||||
|
||||
|
|
|
@ -413,13 +413,7 @@ namespace libtorrent
|
|||
void set_upload_only(bool u);
|
||||
bool upload_only() const { return m_upload_only; }
|
||||
|
||||
void set_holepunch_mode()
|
||||
{
|
||||
m_holepunch_mode = true;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** HOLEPUNCH MODE ***");
|
||||
#endif
|
||||
}
|
||||
void set_holepunch_mode();
|
||||
|
||||
// will send a keep-alive message to the peer
|
||||
void keep_alive();
|
||||
|
@ -553,9 +547,10 @@ namespace libtorrent
|
|||
int est_reciprocation_rate() const { return m_est_reciprocation_rate; }
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
virtual void peer_log(char const* fmt, ...) const
|
||||
void peer_log(peer_log_alert::direction_t direction
|
||||
, char const* event, char const* fmt = "", ...) const
|
||||
#if defined __GNUC__ || defined __clang__
|
||||
__attribute__((format(printf, 2, 3)))
|
||||
__attribute__((format(printf, 4, 5)))
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
@ -654,13 +649,7 @@ namespace libtorrent
|
|||
// a piece for the moment, the boost::optional
|
||||
// will be invalid.
|
||||
virtual boost::optional<piece_block_progress>
|
||||
downloading_piece_progress() const
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** downloading_piece_progress() dispatched to the base class!");
|
||||
#endif
|
||||
return boost::optional<piece_block_progress>();
|
||||
}
|
||||
downloading_piece_progress() const;
|
||||
|
||||
enum message_type_flags { message_type_request = 1 };
|
||||
void send_buffer(char const* begin, int size, int flags = 0);
|
||||
|
|
|
@ -63,7 +63,12 @@ namespace libtorrent
|
|||
virtual stat const& statistics() const = 0;
|
||||
virtual void get_peer_info(peer_info& p) const = 0;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
virtual void peer_log(char const* fmt, ...) const = 0;
|
||||
virtual void peer_log(peer_log_alert::direction_t direction
|
||||
, char const* event, char const* fmt = "", ...) const
|
||||
#if defined __GNUC__ || defined __clang__
|
||||
__attribute__((format(printf, 4, 5)))
|
||||
#endif
|
||||
= 0;
|
||||
#endif
|
||||
protected:
|
||||
~peer_connection_interface() {}
|
||||
|
|
|
@ -1028,6 +1028,7 @@ namespace libtorrent
|
|||
__attribute__((format(printf, 2, 3)))
|
||||
#endif
|
||||
;
|
||||
|
||||
void log_to_all_peers(char const* message);
|
||||
time_point m_dht_start_time;
|
||||
#endif
|
||||
|
|
|
@ -1559,10 +1559,16 @@ namespace libtorrent {
|
|||
return torrent_alert::message() + ": " + msg();
|
||||
}
|
||||
|
||||
peer_log_alert::peer_log_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
||||
peer_log_alert::peer_log_alert(aux::stack_allocator& alloc
|
||||
, torrent_handle const& h
|
||||
, tcp::endpoint const& i
|
||||
, peer_id const& pi, char const* log)
|
||||
, peer_id const& pi
|
||||
, direction_t dir
|
||||
, char const* event
|
||||
, char const* log)
|
||||
: peer_alert(alloc, h, i, pi)
|
||||
, event_type(event)
|
||||
, direction(dir)
|
||||
, m_str_idx(alloc.copy_string(log))
|
||||
{}
|
||||
|
||||
|
@ -1573,7 +1579,10 @@ namespace libtorrent {
|
|||
|
||||
std::string peer_log_alert::message() const
|
||||
{
|
||||
return torrent_alert::message() + " [" + print_endpoint(ip) + "] " + msg();
|
||||
static char const* mode[] =
|
||||
{ "<==", "==>", "<<<", ">>>", "***" };
|
||||
return torrent_alert::message() + " [" + print_endpoint(ip) + "] "
|
||||
+ mode[direction] + " " + event_type + " [ " + msg() + " ]";
|
||||
}
|
||||
|
||||
lsd_error_alert::lsd_error_alert(aux::stack_allocator&, error_code const& ec)
|
||||
|
|
|
@ -51,7 +51,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/version.hpp"
|
||||
#include "libtorrent/extensions.hpp"
|
||||
#include "libtorrent/aux_/session_interface.hpp"
|
||||
//#include "libtorrent/aux_/escape_string.hpp"
|
||||
#include "libtorrent/alert_types.hpp"
|
||||
#include "libtorrent/broadcast_socket.hpp"
|
||||
#include "libtorrent/peer_info.hpp"
|
||||
#include "libtorrent/random.hpp"
|
||||
|
@ -126,7 +126,7 @@ namespace libtorrent
|
|||
#endif
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** bt_peer_connection");
|
||||
peer_log(peer_log_alert::info, "CONSTRUCT", "bt_peer_connection");
|
||||
#endif
|
||||
|
||||
#if TORRENT_USE_ASSERTS
|
||||
|
@ -174,7 +174,7 @@ namespace libtorrent
|
|||
if (t->graceful_pause())
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** ON_CONNECTED [ graceful-paused ]");
|
||||
peer_log(peer_log_alert::info, "ON_CONNECTED", "graceful-paused");
|
||||
#endif
|
||||
disconnect(error_code(errors::torrent_paused), op_bittorrent);
|
||||
return;
|
||||
|
@ -195,7 +195,8 @@ namespace libtorrent
|
|||
#endif
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
char const* policy_name[] = {"forced", "enabled", "disabled"};
|
||||
peer_log("*** outgoing encryption policy: %s", policy_name[out_enc_policy]);
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION"
|
||||
, "outgoing encryption policy: %s", policy_name[out_enc_policy]);
|
||||
#endif
|
||||
|
||||
if (out_enc_policy == settings_pack::pe_forced)
|
||||
|
@ -255,7 +256,7 @@ namespace libtorrent
|
|||
void bt_peer_connection::on_metadata()
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** ON_METADATA");
|
||||
peer_log(peer_log_alert::info, "ON_METADATA");
|
||||
#endif
|
||||
|
||||
disconnect_if_redundant();
|
||||
|
@ -287,7 +288,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> DHT_PORT [ %d ]", listen_port);
|
||||
peer_log(peer_log_alert::outgoing_message, "DHT_PORT", "%d", listen_port);
|
||||
#endif
|
||||
char msg[] = {0,0,0,3, msg_dht_port, 0, 0};
|
||||
char* ptr = msg + 5;
|
||||
|
@ -303,7 +304,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_sent_handshake);
|
||||
m_sent_bitfield = true;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> HAVE_ALL");
|
||||
peer_log(peer_log_alert::outgoing_message, "HAVE_ALL");
|
||||
#endif
|
||||
char msg[] = {0,0,0,1, msg_have_all};
|
||||
send_buffer(msg, sizeof(msg));
|
||||
|
@ -317,7 +318,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(m_sent_handshake);
|
||||
m_sent_bitfield = true;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> HAVE_NONE");
|
||||
peer_log(peer_log_alert::outgoing_message, "HAVE_NONE");
|
||||
#endif
|
||||
char msg[] = {0,0,0,1, msg_have_none};
|
||||
send_buffer(msg, sizeof(msg));
|
||||
|
@ -334,8 +335,8 @@ namespace libtorrent
|
|||
if (!m_supports_fast) return;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> REJECT_PIECE [ piece: %d | s: %d | l: %d ]"
|
||||
, r.piece, r.start, r.length);
|
||||
peer_log(peer_log_alert::outgoing_message, "REJECT_PIECE"
|
||||
, "piece: %d | s: %d | l: %d", r.piece, r.start, r.length);
|
||||
#endif
|
||||
TORRENT_ASSERT(m_sent_handshake && m_sent_bitfield);
|
||||
TORRENT_ASSERT(associated_torrent().lock()->valid_metadata());
|
||||
|
@ -380,7 +381,8 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(t->valid_metadata());
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> SUGGEST [ piece: %d num_peers: %d ]", piece
|
||||
peer_log(peer_log_alert::outgoing_message, "SUGGEST"
|
||||
, "piece: %d num_peers: %d", piece
|
||||
, t->has_picker() ? t->picker().get_availability(piece) : -1);
|
||||
#endif
|
||||
|
||||
|
@ -448,7 +450,7 @@ namespace libtorrent
|
|||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (is_outgoing())
|
||||
peer_log("*** initiating encrypted handshake");
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", "initiating encrypted handshake");
|
||||
#endif
|
||||
|
||||
m_dh_key_exchange.reset(new (std::nothrow) dh_key_exchange);
|
||||
|
@ -461,7 +463,7 @@ namespace libtorrent
|
|||
int pad_size = random() % 512;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(" pad size: %d", pad_size);
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", "pad size: %d", pad_size);
|
||||
#endif
|
||||
|
||||
char msg[dh_key_len + 512];
|
||||
|
@ -475,7 +477,7 @@ namespace libtorrent
|
|||
send_buffer(msg, buf_size);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(" sent DH key");
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", "sent DH key");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -540,8 +542,8 @@ namespace libtorrent
|
|||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
char const* level[] = {"plaintext", "rc4", "plaintext rc4"};
|
||||
peer_log(" crypto provide : [ %s ]"
|
||||
, level[crypto_provide-1]);
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION"
|
||||
, "%s", level[crypto_provide-1]);
|
||||
#endif
|
||||
|
||||
write_pe_vc_cryptofield(ptr, encrypt_size, crypto_provide, pad_size);
|
||||
|
@ -579,7 +581,7 @@ namespace libtorrent
|
|||
m_rc4_encrypted = false;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(" crypto select : [ %s ]"
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", " crypto select: %s"
|
||||
, (crypto_select == 0x01) ? "plaintext" : "rc4");
|
||||
#endif
|
||||
}
|
||||
|
@ -657,7 +659,7 @@ namespace libtorrent
|
|||
m_rc4->set_outgoing_key(&local_key[0], 20);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(" computed RC4 keys");
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", "computed RC4 keys");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -800,7 +802,8 @@ namespace libtorrent
|
|||
else bitmask += '0';
|
||||
}
|
||||
}
|
||||
peer_log("==> EXTENSIONS [ %s ]", bitmask.c_str());
|
||||
peer_log(peer_log_alert::outgoing_message, "EXTENSIONS"
|
||||
, "%s", bitmask.c_str());
|
||||
#endif
|
||||
ptr += 8;
|
||||
|
||||
|
@ -826,10 +829,12 @@ namespace libtorrent
|
|||
char hex_pid[41];
|
||||
to_hex((char const*)&m_our_peer_id[0], 20, hex_pid);
|
||||
hex_pid[40] = 0;
|
||||
peer_log(">>> sent peer_id: %s client: %s"
|
||||
peer_log(peer_log_alert::outgoing, "HANDSHAKE"
|
||||
, "sent peer_id: %s client: %s"
|
||||
, hex_pid, identify_client(m_our_peer_id).c_str());
|
||||
}
|
||||
peer_log("==> HANDSHAKE [ ih: %s ]", to_hex(ih.to_string()).c_str());
|
||||
peer_log(peer_log_alert::outgoing_message, "HANDSHAKE"
|
||||
, "ih: %s", to_hex(ih.to_string()).c_str());
|
||||
#endif
|
||||
send_buffer(handshake, sizeof(handshake));
|
||||
|
||||
|
@ -905,7 +910,7 @@ namespace libtorrent
|
|||
INVARIANT_CHECK;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== KEEPALIVE");
|
||||
peer_log(peer_log_alert::incoming_message, "KEEPALIVE");
|
||||
#endif
|
||||
incoming_keepalive();
|
||||
}
|
||||
|
@ -1245,7 +1250,7 @@ namespace libtorrent
|
|||
if (recv_pos < header_size) return;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
// peer_log("<== PIECE_FRAGMENT p: %d start: %d length: %d"
|
||||
// peer_log(peer_log_alert::incoming_message, "PIECE_FRAGMENT", "p: %d start: %d length: %d"
|
||||
// , p.piece, p.start, p.length);
|
||||
#endif
|
||||
|
||||
|
@ -1265,7 +1270,8 @@ namespace libtorrent
|
|||
if (merkle && list_size > 0)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== HASHPIECE [ piece: %d list: %d ]", p.piece, list_size);
|
||||
peer_log(peer_log_alert::incoming_message, "HASHPIECE"
|
||||
, "piece: %d list: %d", p.piece, list_size);
|
||||
#endif
|
||||
bdecode_node hash_list;
|
||||
error_code ec;
|
||||
|
@ -1518,7 +1524,8 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
error_code ec;
|
||||
static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"};
|
||||
peer_log("<== HOLEPUNCH [ msg: %s from %s to: unknown address type ]"
|
||||
peer_log(peer_log_alert::incoming_message, "HOLEPUNCH"
|
||||
, "msg: %s from %s to: unknown address type"
|
||||
, (msg_type >= 0 && msg_type < 3 ? hp_msg_name[msg_type] : "unknown message type")
|
||||
, print_address(remote().address()).c_str());
|
||||
#endif
|
||||
|
@ -1534,8 +1541,8 @@ namespace libtorrent
|
|||
case hp_rendezvous: // rendezvous
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== HOLEPUNCH [ msg: rendezvous to: %s ]"
|
||||
, print_address(ep.address()).c_str());
|
||||
peer_log(peer_log_alert::incoming_message, "HOLEPUNCH"
|
||||
, "msg: rendezvous to: %s", print_address(ep.address()).c_str());
|
||||
#endif
|
||||
// this peer is asking us to introduce it to
|
||||
// the peer at 'ep'. We need to find which of
|
||||
|
@ -1568,7 +1575,8 @@ namespace libtorrent
|
|||
if (p == 0 || p->connection)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== HOLEPUNCH [ msg:connect to: %s error: failed to add peer ]"
|
||||
peer_log(peer_log_alert::incoming_message, "HOLEPUNCH"
|
||||
, "msg:connect to: %s error: failed to add peer"
|
||||
, print_address(ep.address()).c_str());
|
||||
#endif
|
||||
// we either couldn't add this peer, or it's
|
||||
|
@ -1578,12 +1586,11 @@ namespace libtorrent
|
|||
if (p->banned)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== HOLEPUNCH [ msg:connect to: %s error: peer banned ]"
|
||||
, print_address(ep.address()).c_str());
|
||||
peer_log(peer_log_alert::incoming_message, "HOLEPUNCH"
|
||||
, "msg:connect to: %s error: peer banned", print_address(ep.address()).c_str());
|
||||
#endif
|
||||
// this peer is banned, don't connect to it
|
||||
break;
|
||||
|
||||
}
|
||||
// to make sure we use the uTP protocol
|
||||
p->supports_utp = true;
|
||||
|
@ -1597,7 +1604,8 @@ namespace libtorrent
|
|||
if (p->connection)
|
||||
p->connection->set_holepunch_mode();
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== HOLEPUNCH [ msg:connect to: %s ]"
|
||||
peer_log(peer_log_alert::incoming_message, "HOLEPUNCH"
|
||||
, "msg:connect to: %s"
|
||||
, print_address(ep.address()).c_str());
|
||||
#endif
|
||||
} break;
|
||||
|
@ -1607,7 +1615,8 @@ namespace libtorrent
|
|||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
error_code ec;
|
||||
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(peer_log_alert::incoming_message, "HOLEPUNCH"
|
||||
, "msg:failed error: %d msg: %s", error
|
||||
, ((error > 0 && error < 5)?err_msg[error-1]:"unknown message id"));
|
||||
#endif
|
||||
// #error deal with holepunch errors
|
||||
|
@ -1617,7 +1626,8 @@ namespace libtorrent
|
|||
default:
|
||||
{
|
||||
error_code ec;
|
||||
peer_log("<== HOLEPUNCH [ msg: unknown message type (%d) to: %s ]"
|
||||
peer_log(peer_log_alert::incoming_message, "HOLEPUNCH"
|
||||
, "msg: unknown message type (%d) to: %s"
|
||||
, msg_type, print_address(ep.address()).c_str());
|
||||
}
|
||||
#endif
|
||||
|
@ -1637,7 +1647,8 @@ namespace libtorrent
|
|||
error_code ec;
|
||||
static const char* hp_msg_name[] = {"rendezvous", "connect", "failed"};
|
||||
static const char* hp_error_string[] = {"", "no such peer", "not connected", "no support", "no self"};
|
||||
peer_log("==> HOLEPUNCH [ msg: %s to: %s error: %s ]"
|
||||
peer_log(peer_log_alert::outgoing_message, "HOLEPUNCH"
|
||||
, "msg: %s to: %s error: %s"
|
||||
, (type >= 0 && type < 3 ? hp_msg_name[type] : "unknown message type")
|
||||
, print_address(ep.address()).c_str()
|
||||
, hp_error_string[error]);
|
||||
|
@ -1705,13 +1716,15 @@ namespace libtorrent
|
|||
if (m_recv_buffer.packet_size() != 3)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== UPLOAD_ONLY [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
|
||||
peer_log(peer_log_alert::incoming_message, "UPLOAD_ONLY"
|
||||
, "ERROR: unexpected packet size: %d", m_recv_buffer.packet_size());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
bool ul = detail::read_uint8(recv_buffer.begin) != 0;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== UPLOAD_ONLY [ %s ]", (ul?"true":"false"));
|
||||
peer_log(peer_log_alert::incoming_message, "UPLOAD_ONLY"
|
||||
, "%s", (ul?"true":"false"));
|
||||
#endif
|
||||
set_upload_only(ul);
|
||||
return;
|
||||
|
@ -1723,13 +1736,15 @@ namespace libtorrent
|
|||
if (m_recv_buffer.packet_size() != 3)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== SHARE_MODE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
|
||||
peer_log(peer_log_alert::incoming_message, "SHARE_MODE"
|
||||
, "ERROR: unexpected packet size: %d", m_recv_buffer.packet_size());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
bool sm = detail::read_uint8(recv_buffer.begin) != 0;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== SHARE_MODE [ %s ]", (sm?"true":"false"));
|
||||
peer_log(peer_log_alert::incoming_message, "SHARE_MODE"
|
||||
, "%s", (sm?"true":"false"));
|
||||
#endif
|
||||
set_share_mode(sm);
|
||||
return;
|
||||
|
@ -1739,7 +1754,7 @@ namespace libtorrent
|
|||
{
|
||||
if (!m_recv_buffer.packet_finished()) return;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== HOLEPUNCH");
|
||||
peer_log(peer_log_alert::incoming_message, "HOLEPUNCH");
|
||||
#endif
|
||||
on_holepunch();
|
||||
return;
|
||||
|
@ -1751,7 +1766,8 @@ namespace libtorrent
|
|||
if (m_recv_buffer.packet_size() != 6)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== DONT_HAVE [ ERROR: unexpected packet size: %d ]", m_recv_buffer.packet_size());
|
||||
peer_log(peer_log_alert::incoming_message, "DONT_HAVE"
|
||||
, "ERROR: unexpected packet size: %d", m_recv_buffer.packet_size());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -1762,8 +1778,8 @@ namespace libtorrent
|
|||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (m_recv_buffer.packet_finished())
|
||||
peer_log("<== EXTENSION MESSAGE [ msg: %d size: %d ]"
|
||||
, extended_id, m_recv_buffer.packet_size());
|
||||
peer_log(peer_log_alert::incoming_message, "EXTENSION_MESSAGE"
|
||||
, "msg: %d size: %d", extended_id, m_recv_buffer.packet_size());
|
||||
#endif
|
||||
|
||||
for (extension_list_t::iterator i = m_extensions.begin()
|
||||
|
@ -1794,14 +1810,16 @@ namespace libtorrent
|
|||
if (ret != 0 || ec || root.type() != bdecode_node::dict_t)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** invalid extended handshake: %s pos: %d"
|
||||
peer_log(peer_log_alert::info, "EXTENSION_MESSAGE"
|
||||
, "invalid extended handshake: %s pos: %d"
|
||||
, ec.message().c_str(), pos);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== EXTENDED HANDSHAKE: %s", print_entry(root).c_str());
|
||||
peer_log(peer_log_alert::incoming_message, "EXTENDED_HANDSHAKE"
|
||||
, "%s", print_entry(root).c_str());
|
||||
#endif
|
||||
|
||||
for (extension_list_t::iterator i = m_extensions.begin();
|
||||
|
@ -1843,13 +1861,7 @@ namespace libtorrent
|
|||
if (!client_info.empty()) m_client_version = client_info;
|
||||
|
||||
int reqq = int(root.dict_find_int_value("reqq"));
|
||||
if (reqq > 0)
|
||||
{
|
||||
max_out_request_queue(reqq);
|
||||
#ifdef TORRENT_VERBOSE_LOGGING
|
||||
peer_log("*** MAX OUT REQUEST QUEUE [ %d ]", reqq);
|
||||
#endif
|
||||
}
|
||||
if (reqq > 0) max_out_request_queue(reqq);
|
||||
|
||||
if (root.dict_find_int_value("upload_only", 0))
|
||||
set_upload_only(true);
|
||||
|
@ -1992,7 +2004,7 @@ namespace libtorrent
|
|||
if (!m_settings.get_bool(settings_pack::close_redundant_connections)) return;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> UPLOAD_ONLY [ %d ]"
|
||||
peer_log(peer_log_alert::outgoing_message, "UPLOAD_ONLY", "%d"
|
||||
, int(t->is_upload_only() && !t->super_seeding()));
|
||||
#endif
|
||||
|
||||
|
@ -2093,7 +2105,7 @@ namespace libtorrent
|
|||
if (t->super_seeding())
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(" *** NOT SENDING BITFIELD, super seeding");
|
||||
peer_log(peer_log_alert::info, "BITFIELD", "not sending bitfield, super seeding");
|
||||
#endif
|
||||
if (m_supports_fast) write_have_none();
|
||||
|
||||
|
@ -2124,7 +2136,7 @@ namespace libtorrent
|
|||
{
|
||||
// don't send a bitfield if we don't have any pieces
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log(" *** NOT SENDING BITFIELD");
|
||||
peer_log(peer_log_alert::info, "BITFIELD", "not sending bitfield, have none");
|
||||
#endif
|
||||
m_sent_bitfield = true;
|
||||
return;
|
||||
|
@ -2203,7 +2215,8 @@ namespace libtorrent
|
|||
if (msg[5 + k / 8] & (0x80 >> (k % 8))) bitfield_string[k] = '1';
|
||||
else bitfield_string[k] = '0';
|
||||
}
|
||||
peer_log("==> BITFIELD [ %s ]", bitfield_string.c_str());
|
||||
peer_log(peer_log_alert::outgoing_message, "BITFIELD"
|
||||
, "%s", bitfield_string.c_str());
|
||||
#endif
|
||||
m_sent_bitfield = true;
|
||||
|
||||
|
@ -2216,7 +2229,8 @@ namespace libtorrent
|
|||
for (int i = 0; i < num_lazy_pieces; ++i)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> HAVE [ piece: %d ]", lazy_pieces[i]);
|
||||
peer_log(peer_log_alert::outgoing_message, "HAVE"
|
||||
, "piece: %d", lazy_pieces[i]);
|
||||
#endif
|
||||
write_have(lazy_pieces[i]);
|
||||
}
|
||||
|
@ -2335,7 +2349,8 @@ namespace libtorrent
|
|||
stats_counters().inc_stats_counter(counters::num_outgoing_ext_handshake);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> EXTENDED HANDSHAKE: %s", handshake.to_string().c_str());
|
||||
peer_log(peer_log_alert::outgoing_message, "EXTENDED_HANDSHAKE"
|
||||
, "%s", handshake.to_string().c_str());
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -2556,7 +2571,8 @@ namespace libtorrent
|
|||
int consumed = m_enc_handler.decrypt(m_recv_buffer, bytes_transferred);
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (consumed + bytes_transferred > 0)
|
||||
peer_log("<== decrypted block [ s = %d ]", int(consumed + bytes_transferred));
|
||||
peer_log(peer_log_alert::incoming_message, "ENCRYPTION"
|
||||
, "decrypted block s = %d", int(consumed + bytes_transferred));
|
||||
#endif
|
||||
if (bytes_transferred == SIZE_MAX)
|
||||
{
|
||||
|
@ -2627,7 +2643,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** received DH key");
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", "received DH key");
|
||||
#endif
|
||||
|
||||
// PadA/B can be a max of 512 bytes, and 20 bytes more for
|
||||
|
@ -2726,7 +2742,8 @@ namespace libtorrent
|
|||
{
|
||||
std::size_t bytes_processed = syncoffset + 20;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** sync point (hash) found at offset %d"
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION"
|
||||
, "sync point (hash) found at offset %d"
|
||||
, int(m_sync_bytes_read + bytes_processed - 20));
|
||||
#endif
|
||||
m_state = read_pe_skey_vc;
|
||||
|
@ -2775,7 +2792,7 @@ namespace libtorrent
|
|||
|
||||
init_pe_rc4_handler(m_dh_key_exchange->get_secret(), ti->info_hash());
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** stream key found, torrent located");
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", "stream key found, torrent located");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2798,7 +2815,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** verification constant found");
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", "verification constant found");
|
||||
#endif
|
||||
m_state = read_pe_cryptofield;
|
||||
m_recv_buffer.reset(4 + 2);
|
||||
|
@ -2862,7 +2879,8 @@ namespace libtorrent
|
|||
{
|
||||
std::size_t bytes_processed = syncoffset + 8;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** sync point (verification constant) found at offset %d"
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION"
|
||||
, "sync point (verification constant) found at offset %d"
|
||||
, int(m_sync_bytes_read + bytes_processed - 8));
|
||||
#endif
|
||||
int transferred_used = bytes_processed - recv_buffer.left() + bytes_transferred;
|
||||
|
@ -2897,7 +2915,7 @@ namespace libtorrent
|
|||
boost::uint32_t crypto_field = detail::read_uint32(recv_buffer.begin);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** crypto %s : [%s%s ]"
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", "crypto %s : [%s%s ]"
|
||||
, is_outgoing() ? "select" : "provide"
|
||||
, (crypto_field & 1) ? " plaintext" : ""
|
||||
, (crypto_field & 2) ? " rc4" : "");
|
||||
|
@ -3011,7 +3029,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** len(IA) : %d", len_ia);
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", "len(IA) : %d", len_ia);
|
||||
#endif
|
||||
if (len_ia == 0)
|
||||
{
|
||||
|
@ -3057,7 +3075,8 @@ namespace libtorrent
|
|||
rc4_decrypt(wr_buf.begin, m_recv_buffer.packet_size());
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** decrypted ia : %d bytes", m_recv_buffer.packet_size());
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION"
|
||||
, "decrypted ia : %d bytes", m_recv_buffer.packet_size());
|
||||
#endif
|
||||
|
||||
// everything that arrives after this is encrypted
|
||||
|
@ -3106,7 +3125,8 @@ namespace libtorrent
|
|||
rc4_decrypt(wr_buf.begin, wr_buf.left());
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** decrypted remaining %d bytes", wr_buf.left());
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION"
|
||||
, "decrypted remaining %d bytes", wr_buf.left());
|
||||
#endif
|
||||
}
|
||||
m_rc4.reset();
|
||||
|
@ -3147,14 +3167,16 @@ namespace libtorrent
|
|||
{
|
||||
#if !defined(TORRENT_DISABLE_ENCRYPTION) && !defined(TORRENT_DISABLE_EXTENSIONS)
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** unrecognized protocol header");
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION"
|
||||
, "unrecognized protocol header");
|
||||
#endif
|
||||
|
||||
#ifdef TORRENT_USE_OPENSSL
|
||||
if (is_ssl(*get_socket()))
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** SSL peers are not allowed to use any other encryption");
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION"
|
||||
, "SSL peers are not allowed to use any other encryption");
|
||||
#endif
|
||||
disconnect(errors::invalid_info_hash, op_bittorrent, 1);
|
||||
return;
|
||||
|
@ -3180,7 +3202,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** attempting encrypted connection");
|
||||
peer_log(peer_log_alert::info, "ENCRYPTION", "attempting encrypted connection");
|
||||
#endif
|
||||
m_state = read_pe_dhkey;
|
||||
m_recv_buffer.cut(0, dh_key_len);
|
||||
|
@ -3208,7 +3230,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== BitTorrent protocol");
|
||||
peer_log(peer_log_alert::incoming_message, "HANDSHAKE", "BitTorrent protocol");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -3238,7 +3260,7 @@ namespace libtorrent
|
|||
else extensions[i*8+j] = '0';
|
||||
}
|
||||
}
|
||||
peer_log("<== EXTENSIONS [ %s ext: %s%s%s]"
|
||||
peer_log(peer_log_alert::incoming_message, "EXTENSIONS", "%s ext: %s%s%s"
|
||||
, extensions.c_str()
|
||||
, (recv_buffer[7] & 0x01) ? "DHT " : ""
|
||||
, (recv_buffer[7] & 0x04) ? "FAST " : ""
|
||||
|
@ -3278,14 +3300,14 @@ namespace libtorrent
|
|||
, (const char*)t->torrent_file().info_hash().begin()))
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** received invalid info_hash");
|
||||
peer_log(peer_log_alert::info, "ERROR", "received invalid info_hash");
|
||||
#endif
|
||||
disconnect(errors::invalid_info_hash, op_bittorrent, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<<< info_hash received");
|
||||
peer_log(peer_log_alert::incoming, "HANDSHAKE", "info_hash received");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -3332,7 +3354,7 @@ namespace libtorrent
|
|||
if (is_print(recv_buffer.begin[i])) ascii_pid[i] = recv_buffer.begin[i];
|
||||
else ascii_pid[i] = '.';
|
||||
}
|
||||
peer_log("<<< received peer_id: %s client: %s ascii: \"%s\""
|
||||
peer_log(peer_log_alert::incoming, "HANDSHAKE", "received peer_id: %s client: %s ascii: \"%s\""
|
||||
, hex_pid, identify_client(peer_id(recv_buffer.begin)).c_str(), ascii_pid);
|
||||
}
|
||||
#endif
|
||||
|
@ -3403,7 +3425,7 @@ namespace libtorrent
|
|||
#endif
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== HANDSHAKE");
|
||||
peer_log(peer_log_alert::incoming_message, "HANDSHAKE");
|
||||
#endif
|
||||
// consider this a successful connection, reset the failcount
|
||||
if (peer_info_struct())
|
||||
|
@ -3520,7 +3542,8 @@ namespace libtorrent
|
|||
int next_barrier = m_enc_handler.encrypt(iovec);
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (next_barrier != 0)
|
||||
peer_log("==> encrypted block [ s = %d ]", next_barrier);
|
||||
peer_log(peer_log_alert::outgoing_message, "SEND_BARRIER"
|
||||
, "encrypted block s = %d", next_barrier);
|
||||
#endif
|
||||
return next_barrier;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace libtorrent
|
|||
prefer_contiguous_blocks(blocks_per_piece);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** http_seed_connection");
|
||||
peer_log(peer_log_alert::info, "CONNECT", "http_seed_connection");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ namespace libtorrent
|
|||
m_first_request = false;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> %s", request.c_str());
|
||||
peer_log(peer_log_alert::outgoing_message, "REQUEST", "%s", request.c_str());
|
||||
#endif
|
||||
|
||||
send_buffer(request.c_str(), request.size(), message_type_request);
|
||||
|
@ -214,7 +214,8 @@ namespace libtorrent
|
|||
{
|
||||
received_bytes(0, bytes_transferred);
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** http_seed_connection error: %s", error.message().c_str());
|
||||
peer_log(peer_log_alert::info, "ERROR"
|
||||
, "http_seed_connection error: %s", error.message().c_str());
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
@ -377,7 +378,8 @@ namespace libtorrent
|
|||
else
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** parsed chunk: %" PRId64 " header_size: %d"
|
||||
peer_log(peer_log_alert::info, "CHUNKED_ENCODING"
|
||||
, "parsed chunk: %" PRId64 " header_size: %d"
|
||||
, chunk_size, header_size);
|
||||
#endif
|
||||
TORRENT_ASSERT(bytes_transferred >= size_t(header_size - m_partial_chunk_header));
|
||||
|
@ -416,7 +418,7 @@ namespace libtorrent
|
|||
int retry_time = atol(std::string(recv_buffer.begin, recv_buffer.end).c_str());
|
||||
if (retry_time <= 0) retry_time = 60;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** retrying in %d seconds", retry_time);
|
||||
peer_log(peer_log_alert::info, "CONNECT", "retrying in %d seconds", retry_time);
|
||||
#endif
|
||||
|
||||
received_bytes(0, bytes_transferred);
|
||||
|
|
|
@ -206,7 +206,8 @@ namespace libtorrent { namespace
|
|||
if (added == 0)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log(" <== LT_TEX [ NOT A DICTIONARY ]");
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "LT_TEX"
|
||||
, "NOT A DICTIONARY");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
@ -214,16 +215,15 @@ namespace libtorrent { namespace
|
|||
if (m_tp.num_tex_trackers() >= 50)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log(" <== LT_TEX [ we already have %d trackers "
|
||||
"from tex, don't add any more", m_tp.num_tex_trackers());
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "LT_TEX"
|
||||
, "we already have %d trackers from tex, don't add any more"
|
||||
, m_tp.num_tex_trackers());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
std::stringstream log_line;
|
||||
log_line << " <== LT_TEX [ "
|
||||
"added: ";
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "LT_TEX");
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < added.list_size(); ++i)
|
||||
|
@ -254,12 +254,7 @@ namespace libtorrent { namespace
|
|||
continue;
|
||||
|
||||
if (m_tp.num_tex_trackers() >= 50)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
log_line << "**reached-limit** ";
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
e.fail_limit = 1;
|
||||
e.send_stats = false;
|
||||
|
@ -268,13 +263,9 @@ namespace libtorrent { namespace
|
|||
m_tp.increment_tracker_counter();
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
log_line << e.url << " ";
|
||||
m_pc.peer_log(peer_log_alert::info, "LT_TEX", "added: %s", e.url.c_str());
|
||||
#endif
|
||||
}
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
log_line << "]\n";
|
||||
m_pc.peer_log("%s", log_line.str().c_str());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -326,9 +317,7 @@ namespace libtorrent { namespace
|
|||
return false;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
std::stringstream log_line;
|
||||
log_line << " ==> LT_TEX [ "
|
||||
"added: ";
|
||||
m_pc.peer_log(peer_log_alert::outgoing_message, "LT_TEX");
|
||||
#endif
|
||||
entry tex;
|
||||
entry::list_type& added = tex["added"].list();
|
||||
|
@ -338,17 +327,13 @@ namespace libtorrent { namespace
|
|||
if (!send_tracker(*i)) continue;
|
||||
added.push_back(i->url);
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
log_line << i->url << " ";
|
||||
m_pc.peer_log(peer_log_alert::info, "LT_TEX"
|
||||
, "sending: %s", i->url.c_str());
|
||||
#endif
|
||||
}
|
||||
std::vector<char> tex_msg;
|
||||
bencode(std::back_inserter(tex_msg), tex);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
log_line << "]";
|
||||
m_pc.peer_log("%s", log_line.str().c_str());
|
||||
#endif
|
||||
|
||||
char msg[6];
|
||||
char* ptr = msg;
|
||||
|
||||
|
|
|
@ -301,8 +301,8 @@ namespace libtorrent { namespace
|
|||
if (m_message_index == 0) return;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("==> METADATA_REQUEST [ start: %d | size: %d ]\n"
|
||||
, start, size);
|
||||
m_pc.peer_log(peer_log_alert::outgoing_message, "METADATA_REQUEST"
|
||||
, "start: %d size: %d", start, size);
|
||||
#endif
|
||||
|
||||
char msg[9];
|
||||
|
@ -339,7 +339,8 @@ namespace libtorrent { namespace
|
|||
char* ptr = msg;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("==> METADATA [ start: %d | total_size: %d | offset: %d | data_size: %d ]"
|
||||
m_pc.peer_log(peer_log_alert::outgoing_message, "METADATA"
|
||||
, "start: %d total_size: %d offset: %d data_size: %d"
|
||||
, req.first, req.second, offset.first, offset.second);
|
||||
#endif
|
||||
// yes, we have metadata, send it
|
||||
|
@ -360,7 +361,8 @@ namespace libtorrent { namespace
|
|||
else
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("==> DONT HAVE METADATA\n");
|
||||
m_pc.peer_log(peer_log_alert::outgoing_message, "METADATA"
|
||||
, "don't have metadata");
|
||||
#endif
|
||||
char msg[4+3];
|
||||
char* ptr = msg;
|
||||
|
@ -401,8 +403,8 @@ namespace libtorrent { namespace
|
|||
int size = detail::read_uint8(body.begin) + 1;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("<== METADATA_REQUEST [ start: %d | size: %d ]\n"
|
||||
, start, size);
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "METADATA_REQUEST"
|
||||
, "start: %d size: %d", start, size);
|
||||
#endif
|
||||
|
||||
if (length != 3)
|
||||
|
@ -424,7 +426,8 @@ namespace libtorrent { namespace
|
|||
int data_size = length - 9;
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("<== METADATA [ total_size: %d | offset: %d | data_size: %d ]"
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "METADATA"
|
||||
, "total_size: %d | offset: %d | data_size: %d"
|
||||
,total_size, offset, data_size);
|
||||
#endif
|
||||
|
||||
|
@ -467,7 +470,8 @@ namespace libtorrent { namespace
|
|||
m_tp.cancel_metadata_request(m_last_metadata_request);
|
||||
m_waiting_metadata_request = false;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("<== DONT HAVE METADATA\n");
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "METADATA"
|
||||
, "don't have metadata");
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -617,7 +617,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(i->address() == c.remote().address());
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
c.peer_log("*** DUPLICATE PEER [ this: \"%s\" that: \"%s\" ]"
|
||||
c.peer_log(peer_log_alert::info, "DUPLICATE PEER [ this: \"%s\" that: \"%s\" ]"
|
||||
, print_address(c.remote().address()).c_str()
|
||||
, print_address(i->address()).c_str());
|
||||
#endif
|
||||
|
@ -675,8 +675,10 @@ namespace libtorrent
|
|||
if (our_port < other_port)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
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);
|
||||
c.peer_log(peer_log_alert::info, "DUPLICATE_PEER_RESOLUTION"
|
||||
, "\"%d\" < \"%d\"", our_port, other_port);
|
||||
i->connection->peer_log(peer_log_alert::info, "DUPLICATE_PEER_RESOLUTION"
|
||||
, "\"%d\" < \"%d\"", our_port, other_port);
|
||||
#endif
|
||||
|
||||
// we should keep our outgoing connection
|
||||
|
@ -693,8 +695,10 @@ namespace libtorrent
|
|||
else
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
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);
|
||||
c.peer_log(peer_log_alert::info, "DUPLICATE_PEER_RESOLUTION"
|
||||
, "\"%d\" >= \"%d\"", our_port, other_port);
|
||||
i->connection->peer_log(peer_log_alert::info, "DUPLICATE_PEER_RESOLUTION"
|
||||
, "\"%d\" >= \"%d\"", our_port, other_port);
|
||||
#endif
|
||||
// they should keep their outgoing connection
|
||||
if (outgoing1)
|
||||
|
|
|
@ -88,7 +88,8 @@ namespace libtorrent
|
|||
- (int)c.request_queue().size();
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
c.peer_log("*** PIECE_PICKER [ dlq: %d rqq: %d target: %d req: %d engame: %d ]"
|
||||
c.peer_log(peer_log_alert::info, "PIECE_PICKER"
|
||||
, "dlq: %d rqq: %d target: %d req: %d engame: %d"
|
||||
, int(c.download_queue().size()), int(c.request_queue().size())
|
||||
, c.desired_queue_size(), num_requests, c.endgame());
|
||||
#endif
|
||||
|
@ -160,7 +161,8 @@ namespace libtorrent
|
|||
, ses.stats_counters());
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
c.peer_log("*** PIECE_PICKER [ prefer_contiguous: %d picked: %d ]"
|
||||
c.peer_log(peer_log_alert::info, "PIECE_PICKER"
|
||||
, "prefer_contiguous: %d picked: %d"
|
||||
, prefer_contiguous_blocks, int(interesting_pieces.size()));
|
||||
#endif
|
||||
|
||||
|
@ -225,7 +227,8 @@ namespace libtorrent
|
|||
if (j != dq.end()) TORRENT_ASSERT(j->timed_out || j->not_wanted);
|
||||
#endif
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
c.peer_log("*** PIECE_PICKER [ not_picking: %d,%d already in queue ]"
|
||||
c.peer_log(peer_log_alert::info, "PIECE_PICKER"
|
||||
, "not_picking: %d,%d already in queue"
|
||||
, i->piece_index, i->block_index);
|
||||
#endif
|
||||
continue;
|
||||
|
|
|
@ -3476,7 +3476,7 @@ retry:
|
|||
--type_limit;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (!t->allows_peers())
|
||||
t->log_to_all_peers("AUTO MANAGER STARTING TORRENT");
|
||||
t->log_to_all_peers("auto manager starting torrent");
|
||||
#endif
|
||||
t->set_allow_peers(true);
|
||||
}
|
||||
|
@ -3484,7 +3484,7 @@ retry:
|
|||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
if (t->allows_peers())
|
||||
t->log_to_all_peers("AUTO MANAGER PAUSING TORRENT");
|
||||
t->log_to_all_peers("auto manager pausing torrent");
|
||||
#endif
|
||||
// use graceful pause for auto-managed torrents
|
||||
t->set_allow_peers(false, true);
|
||||
|
|
|
@ -4264,7 +4264,7 @@ namespace libtorrent
|
|||
, end(m_connections.end()); p != end; ++p)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
(*p)->peer_log(">>> PREDICTIVE_HAVE [ piece: %d expected in %d ms]"
|
||||
(*p)->peer_log(peer_log_alert::outgoing, "PREDICTIVE_HAVE", "piece: %d expected in %d ms"
|
||||
, index, milliseconds);
|
||||
#endif
|
||||
(*p)->announce_piece(index);
|
||||
|
@ -4410,7 +4410,7 @@ namespace libtorrent
|
|||
, print_endpoint(p->ip()).c_str());
|
||||
#endif
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer->peer_log("*** BANNING PEER: Too many corrupt pieces");
|
||||
peer->peer_log(peer_log_alert::info, "BANNING_PEER", "Too many corrupt pieces");
|
||||
#endif
|
||||
peer->disconnect(errors::too_many_corrupt_pieces, op_bittorrent);
|
||||
}
|
||||
|
@ -4768,7 +4768,7 @@ namespace libtorrent
|
|||
m_inactivity_timer.cancel(ec);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
log_to_all_peers("ABORTING TORRENT");
|
||||
log_to_all_peers("aborting");
|
||||
#endif
|
||||
|
||||
// disconnect all peers and close all
|
||||
|
@ -8054,7 +8054,7 @@ namespace libtorrent
|
|||
if (p->upload_only())
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
p->peer_log("*** SEED, CLOSING CONNECTION");
|
||||
p->peer_log(peer_log_alert::info, "SEED", "CLOSING CONNECTION");
|
||||
#endif
|
||||
seeds.push_back(p);
|
||||
}
|
||||
|
@ -8295,7 +8295,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
pc->peer_log("*** ON_FILES_CHECKED");
|
||||
pc->peer_log(peer_log_alert::info, "ON_FILES_CHECKED");
|
||||
#endif
|
||||
if (pc->is_interesting() && !pc->has_peer_choked())
|
||||
{
|
||||
|
@ -8781,7 +8781,7 @@ namespace libtorrent
|
|||
TORRENT_ASSERT(is_single_thread());
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
log_to_all_peers("DELETING FILES IN TORRENT");
|
||||
log_to_all_peers("deleting files");
|
||||
#endif
|
||||
|
||||
disconnect_all(errors::torrent_removed, op_bittorrent);
|
||||
|
@ -8857,7 +8857,7 @@ namespace libtorrent
|
|||
if (ec)
|
||||
{
|
||||
char buf[1024];
|
||||
snprintf(buf, sizeof(buf), "TORRENT ERROR: %s: %s", ec.message().c_str()
|
||||
snprintf(buf, sizeof(buf), "error %s: %s", ec.message().c_str()
|
||||
, resolve_filename(error_file).c_str());
|
||||
log_to_all_peers(buf);
|
||||
}
|
||||
|
@ -9199,7 +9199,7 @@ namespace libtorrent
|
|||
update_want_scrape();
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
log_to_all_peers("PAUSING TORRENT");
|
||||
log_to_all_peers("pausing");
|
||||
#endif
|
||||
|
||||
// when checking and being paused in graceful pause mode, we
|
||||
|
@ -9256,7 +9256,7 @@ namespace libtorrent
|
|||
if (p->outstanding_bytes() > 0)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
p->peer_log("*** CHOKING PEER: torrent graceful paused");
|
||||
p->peer_log(peer_log_alert::info, "CHOKING_PEER", "torrent graceful paused");
|
||||
#endif
|
||||
// remove any un-sent requests from the queue
|
||||
p->clear_request_queue();
|
||||
|
@ -9266,7 +9266,7 @@ namespace libtorrent
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
p->peer_log("*** CLOSING CONNECTION: torrent_paused");
|
||||
p->peer_log(peer_log_alert::info, "CLOSING_CONNECTION", "torrent_paused");
|
||||
#endif
|
||||
p->disconnect(errors::torrent_paused, op_bittorrent);
|
||||
i = j;
|
||||
|
@ -9291,13 +9291,11 @@ namespace libtorrent
|
|||
void torrent::log_to_all_peers(char const* message)
|
||||
{
|
||||
TORRENT_ASSERT(is_single_thread());
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
for (peer_iterator i = m_connections.begin();
|
||||
i != m_connections.end(); ++i)
|
||||
{
|
||||
(*i)->peer_log("*** %s", message);
|
||||
(*i)->peer_log(peer_log_alert::info, "TORRENT", "%s", message);
|
||||
}
|
||||
#endif
|
||||
|
||||
debug_log("%s", message);
|
||||
}
|
||||
|
@ -9748,7 +9746,7 @@ namespace libtorrent
|
|||
TORRENT_DECLARE_DUMMY(std::exception, e);
|
||||
(void)e;
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
p->peer_log("*** ERROR %s", e.what());
|
||||
p->peer_log(peer_log_alert::info, "ERROR", "%s", e.what());
|
||||
#endif
|
||||
p->disconnect(errors::no_error, op_bittorrent, 1);
|
||||
}
|
||||
|
|
|
@ -264,7 +264,8 @@ namespace libtorrent { namespace
|
|||
char const* names[] = {"request", "data", "dont-have"};
|
||||
char const* n = "";
|
||||
if (type >= 0 && type < 3) n = names[type];
|
||||
m_pc.peer_log("==> UT_METADATA [ type: %d (%s) | piece: %d ]", type, n, piece);
|
||||
m_pc.peer_log(peer_log_alert::outgoing_message, "UT_METADATA"
|
||||
, "type: %d (%s) piece: %d", type, n, piece);
|
||||
#endif
|
||||
|
||||
// abort if the peer doesn't support the metadata extension
|
||||
|
@ -327,7 +328,8 @@ namespace libtorrent { namespace
|
|||
if (length > 17 * 1024)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("<== UT_METADATA [ packet too big %d ]", length);
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "UT_METADATA"
|
||||
, "packet too big %d", length);
|
||||
#endif
|
||||
m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2);
|
||||
return true;
|
||||
|
@ -340,7 +342,8 @@ namespace libtorrent { namespace
|
|||
if (msg.type() != entry::dictionary_t)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("<== UT_METADATA [ not a dictionary ]");
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "UT_METADATA"
|
||||
, "not a dictionary");
|
||||
#endif
|
||||
m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2);
|
||||
return true;
|
||||
|
@ -352,7 +355,8 @@ namespace libtorrent { namespace
|
|||
|| piece_ent == 0 || piece_ent->type() != entry::int_t)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("<== UT_METADATA [ missing or invalid keys ]");
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "UT_METADATA"
|
||||
, "missing or invalid keys");
|
||||
#endif
|
||||
m_pc.disconnect(errors::invalid_metadata_message, op_bittorrent, 2);
|
||||
return true;
|
||||
|
@ -361,7 +365,8 @@ namespace libtorrent { namespace
|
|||
int piece = piece_ent->integer();
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("<== UT_METADATA [ type: %d | piece: %d ]", type, piece);
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "UT_METADATA"
|
||||
, "type: %d piece: %d", type, piece);
|
||||
#endif
|
||||
|
||||
switch (type)
|
||||
|
@ -372,7 +377,8 @@ namespace libtorrent { namespace
|
|||
|| piece < 0 || piece >= int(m_tp.get_metadata_size() + 16 * 1024 - 1)/(16*1024))
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("*** UT_METADATA [ have: %d invalid piece %d metadata size: %d ]"
|
||||
m_pc.peer_log(peer_log_alert::info, "UT_METADATA"
|
||||
, "have: %d invalid piece %d metadata size: %d"
|
||||
, int(m_torrent.valid_metadata()), piece
|
||||
, int(m_tp.get_metadata_size()));
|
||||
#endif
|
||||
|
@ -396,7 +402,8 @@ namespace libtorrent { namespace
|
|||
if (i == m_sent_requests.end())
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("*** UT_METADATA [ UNWANTED / TIMED OUT ]");
|
||||
m_pc.peer_log(peer_log_alert::info, "UT_METADATA"
|
||||
, "UNWANTED / TIMED OUT");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
@ -544,7 +551,8 @@ namespace libtorrent { namespace
|
|||
if (m_torrent.valid_metadata())
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
source.m_pc.peer_log("*** UT_METADATA [ ALREADY HAVE METADATA ]");
|
||||
source.m_pc.peer_log(peer_log_alert::info, "UT_METADATA"
|
||||
, "already have metadata");
|
||||
#endif
|
||||
m_torrent.add_redundant_bytes(size, torrent::piece_unknown);
|
||||
return false;
|
||||
|
@ -556,7 +564,8 @@ namespace libtorrent { namespace
|
|||
if (total_size <= 0 || total_size > m_torrent.session().settings().get_int(settings_pack::max_metadata_size))
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
source.m_pc.peer_log("*** UT_METADATA [ metadata size too big: %d ]", total_size);
|
||||
source.m_pc.peer_log(peer_log_alert::info, "UT_METADATA"
|
||||
, "metadata size too big: %d", total_size);
|
||||
#endif
|
||||
// #error post alert
|
||||
return false;
|
||||
|
@ -570,7 +579,8 @@ namespace libtorrent { namespace
|
|||
if (piece < 0 || piece >= int(m_requested_metadata.size()))
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
source.m_pc.peer_log("*** UT_METADATA [ piece: %d INVALID ]", piece);
|
||||
source.m_pc.peer_log(peer_log_alert::info, "UT_METADATA"
|
||||
, "piece: %d INVALID", piece);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
@ -578,7 +588,8 @@ namespace libtorrent { namespace
|
|||
if (total_size != m_metadata_size)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
source.m_pc.peer_log("*** UT_METADATA [ total_size: %d INCONSISTENT WITH: %d ]"
|
||||
source.m_pc.peer_log(peer_log_alert::info, "UT_METADATA"
|
||||
, "total_size: %d INCONSISTENT WITH: %d"
|
||||
, total_size, m_metadata_size);
|
||||
#endif
|
||||
// they disagree about the size!
|
||||
|
|
|
@ -413,7 +413,7 @@ namespace libtorrent { namespace
|
|||
}
|
||||
#endif
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("<== PEX [ dropped: %d added: %d ]"
|
||||
m_pc.peer_log(peer_log_alert::incoming_message, "PEX", "dropped: %d added: %d"
|
||||
, num_dropped, num_added);
|
||||
#endif
|
||||
|
||||
|
@ -432,7 +432,7 @@ namespace libtorrent { namespace
|
|||
if (now - seconds(60) < m_last_msg)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("*** PEX [ waiting: %d seconds to next msg ]"
|
||||
m_pc.peer_log(peer_log_alert::info, "PEX", "waiting: %d seconds to next msg"
|
||||
, int(total_seconds(seconds(60) - (now - m_last_msg))));
|
||||
#endif
|
||||
return;
|
||||
|
@ -450,7 +450,7 @@ namespace libtorrent { namespace
|
|||
if (now - milliseconds(delay) < global_last)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("*** PEX [ global-wait: %d ]"
|
||||
m_pc.peer_log(peer_log_alert::info, "PEX", "global-wait: %d"
|
||||
, int(total_seconds(milliseconds(delay) - (now - global_last))));
|
||||
#endif
|
||||
return;
|
||||
|
@ -511,7 +511,7 @@ namespace libtorrent { namespace
|
|||
if (e) num_added += e.string_length() / 18;
|
||||
e = m.dict_find_string("dropped6");
|
||||
if (e) num_dropped += e.string_length() / 18;
|
||||
m_pc.peer_log("==> PEX_DIFF [ dropped: %d added: %d msg_size: %d ]"
|
||||
m_pc.peer_log(peer_log_alert::outgoing_message, "PEX_DIFF", "dropped: %d added: %d msg_size: %d"
|
||||
, num_dropped, num_added, int(pex_msg.size()));
|
||||
#endif
|
||||
}
|
||||
|
@ -604,7 +604,8 @@ namespace libtorrent { namespace
|
|||
m_pc.stats_counters().inc_stats_counter(counters::num_outgoing_pex);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
m_pc.peer_log("==> PEX_FULL [ added: %d msg_size: %d ]", num_added, int(pex_msg.size()));
|
||||
m_pc.peer_log(peer_log_alert::outgoing_message, "PEX_FULL"
|
||||
, "added: %d msg_size: %d", num_added, int(pex_msg.size()));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ web_peer_connection::web_peer_connection(peer_connection_args const& pack
|
|||
request_large_blocks(true);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** web_peer_connection %s", m_url.c_str());
|
||||
peer_log(peer_log_alert::info, "URL", "web_peer_connection %s", m_url.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ void web_peer_connection::disconnect(error_code const& ec
|
|||
// us bailing out and failing the entire request just because our
|
||||
// write-end was closed, ignore it and keep reading until the read-end
|
||||
// also is closed.
|
||||
peer_log("*** WRITE-DIRECTION CLOSED");
|
||||
peer_log(peer_log_alert::info, "WRITE_DIRECTION", "CLOSED");
|
||||
#endif
|
||||
|
||||
// prevent the peer from trying to send anything more
|
||||
|
@ -158,7 +158,8 @@ void web_peer_connection::disconnect(error_code const& ec
|
|||
&& !m_piece.empty() && m_web)
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** SAVE-RESTART-DATA: [ data: %d req: %d off: %d ]"
|
||||
peer_log(peer_log_alert::info, "SAVE_RESTART_DATA"
|
||||
, "data: %d req: %d off: %d"
|
||||
, int(m_piece.size()), int(m_requests.front().piece)
|
||||
, int(m_requests.front().start));
|
||||
#endif
|
||||
|
@ -278,7 +279,7 @@ void web_peer_connection::write_request(peer_request const& r)
|
|||
m_requests.push_back(pr);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> REQUESTING [ piece: %d start: %d len: %d ]"
|
||||
peer_log(peer_log_alert::outgoing_message, "REQUESTING", "piece: %d start: %d len: %d"
|
||||
, pr.piece, pr.start, pr.length);
|
||||
#endif
|
||||
|
||||
|
@ -290,7 +291,7 @@ void web_peer_connection::write_request(peer_request const& r)
|
|||
TORRENT_ASSERT(front.length > int(m_piece.size()));
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** RESTART-DATA: [ data: %d req: (%d, %d) size: %d ]"
|
||||
peer_log(peer_log_alert::info, "RESTART_DATA", "data: %d req: (%d, %d) size: %d"
|
||||
, int(m_piece.size()), int(front.piece), int(front.start)
|
||||
, int (front.start + front.length - 1));
|
||||
#endif
|
||||
|
@ -397,7 +398,7 @@ void web_peer_connection::write_request(peer_request const& r)
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("==> %s", request.c_str());
|
||||
peer_log(peer_log_alert::outgoing_message, "REQUEST", "%s", request.c_str());
|
||||
#endif
|
||||
|
||||
// in case the first file on this series of requests is a padfile
|
||||
|
@ -443,7 +444,8 @@ bool web_peer_connection::maybe_harvest_block()
|
|||
|
||||
incoming_piece(front_request, &m_piece[0]);
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== POP REQUEST [ piece: %d start: %d len: %d ]"
|
||||
peer_log(peer_log_alert::incoming_message, "POP_REQUEST"
|
||||
, "piece: %d start: %d len: %d"
|
||||
, front_request.piece, front_request.start, front_request.length);
|
||||
#endif
|
||||
m_requests.pop_front();
|
||||
|
@ -520,7 +522,8 @@ void web_peer_connection::on_receive(error_code const& error
|
|||
{
|
||||
received_bytes(0, bytes_transferred);
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** web_peer_connection error: %s", error.message().c_str());
|
||||
peer_log(peer_log_alert::info, "ERROR"
|
||||
, "web_peer_connection error: %s", error.message().c_str());
|
||||
#endif
|
||||
#ifdef TORRENT_DEBUG
|
||||
TORRENT_ASSERT(statistics().last_payload_downloaded()
|
||||
|
@ -558,7 +561,8 @@ void web_peer_connection::on_receive(error_code const& error
|
|||
{
|
||||
received_bytes(0, bytes_transferred);
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** %s", std::string(recv_buffer.begin, recv_buffer.end).c_str());
|
||||
peer_log(peer_log_alert::info, "RECEIVE_BYTES"
|
||||
, "%s", std::string(recv_buffer.begin, recv_buffer.end).c_str());
|
||||
#endif
|
||||
disconnect(errors::http_parse_error, op_bittorrent, 2);
|
||||
#ifdef TORRENT_DEBUG
|
||||
|
@ -615,11 +619,12 @@ void web_peer_connection::on_receive(error_code const& error
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** STATUS: %d %s", m_parser.status_code(), m_parser.message().c_str());
|
||||
peer_log(peer_log_alert::info, "STATUS"
|
||||
, "%d %s", m_parser.status_code(), m_parser.message().c_str());
|
||||
std::multimap<std::string, std::string> const& headers = m_parser.headers();
|
||||
for (std::multimap<std::string, std::string>::const_iterator i = headers.begin()
|
||||
, end(headers.end()); i != end; ++i)
|
||||
peer_log(" %s: %s", i->first.c_str(), i->second.c_str());
|
||||
peer_log(peer_log_alert::info, "STATUS", " %s: %s", i->first.c_str(), i->second.c_str());
|
||||
#endif
|
||||
// if the status code is not one of the accepted ones, abort
|
||||
if (!is_ok_status(m_parser.status_code()))
|
||||
|
@ -713,7 +718,7 @@ void web_peer_connection::on_receive(error_code const& error
|
|||
}
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** LOCATION: %s", location.c_str());
|
||||
peer_log(peer_log_alert::info, "LOCATION", "%s", location.c_str());
|
||||
#endif
|
||||
t->add_web_seed(location, web_seed_entry::url_seed, m_external_auth, m_extra_headers);
|
||||
t->remove_web_seed(this, errors::redirecting, op_bittorrent, 2);
|
||||
|
@ -823,7 +828,8 @@ void web_peer_connection::on_receive(error_code const& error
|
|||
else
|
||||
{
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** parsed chunk: %" PRId64 " header_size: %d"
|
||||
peer_log(peer_log_alert::info, "PARSE"
|
||||
, "parsed chunk: %" PRId64 " header_size: %d"
|
||||
, chunk_size, header_size);
|
||||
#endif
|
||||
TORRENT_ASSERT(int(bytes_transferred) >= header_size - m_partial_chunk_header);
|
||||
|
@ -874,7 +880,8 @@ void web_peer_connection::on_receive(error_code const& error
|
|||
TORRENT_ASSERT(m_block_pos >= 0);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("*** payload_transferred: %d [ %d:%d = %d ]"
|
||||
peer_log(peer_log_alert::info, "TRAMSFER"
|
||||
, "payload_transferred: %d [ %d:%d = %d ]"
|
||||
, payload_transferred, front_request.piece
|
||||
, front_request.start, front_request.length);
|
||||
#endif
|
||||
|
@ -922,8 +929,8 @@ void web_peer_connection::on_receive(error_code const& error
|
|||
std::vector<file_slice> sl = info.orig_files().map_block(
|
||||
front_request.piece, front_request.start, front_request.start
|
||||
+ front_request.length);
|
||||
peer_log("INVALID HTTP RESPONSE [ in=(%d, %" PRId64 "-%" PRId64 ") "
|
||||
"expected=(%d, %" PRId64 "-%" PRId64 ") piece: %d ]"
|
||||
peer_log(peer_log_alert::incoming, "INVALID HTTP RESPONSE"
|
||||
, "in=(%d, %" PRId64 "-%" PRId64 ") expected=(%d, %" PRId64 "-%" PRId64 ") piece: %d ]"
|
||||
, file_index, range_start, range_end, sl[0].file_index
|
||||
, sl[0].offset, sl[0].offset + sl[0].size, front_request.piece);
|
||||
#endif
|
||||
|
@ -985,7 +992,8 @@ void web_peer_connection::on_receive(error_code const& error
|
|||
incoming_piece(r, recv_buffer.begin);
|
||||
|
||||
#ifndef TORRENT_DISABLE_LOGGING
|
||||
peer_log("<== POP REQUEST [ piece: %d start: %d len: %d ]"
|
||||
peer_log(peer_log_alert::incoming_message, "POP_REQUEST"
|
||||
, "piece: %d start: %d len: %d"
|
||||
, r.piece, r.start, r.length);
|
||||
#endif
|
||||
m_requests.pop_front();
|
||||
|
|
|
@ -72,7 +72,8 @@ struct mock_peer_connection : peer_connection_interface
|
|||
virtual ~mock_peer_connection() {}
|
||||
|
||||
#if !defined TORRENT_DISABLE_LOGGING
|
||||
virtual void peer_log(char const* fmt, ...) const
|
||||
virtual void peer_log(peer_log_alert::direction_t dir, char const* event
|
||||
, char const* fmt, ...) const
|
||||
{
|
||||
va_list v;
|
||||
va_start(v, fmt);
|
||||
|
|
Loading…
Reference in New Issue