2003-11-29 17:34:07 +01:00
|
|
|
/*
|
|
|
|
|
2014-02-23 20:12:25 +01:00
|
|
|
Copyright (c) 2003-2014, Arvid Norberg, Daniel Wallin
|
2003-11-29 17:34:07 +01:00
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2011-06-05 08:32:00 +02:00
|
|
|
#include <string>
|
|
|
|
|
2011-02-25 18:00:36 +01:00
|
|
|
#include "libtorrent/config.hpp"
|
2003-11-29 17:34:07 +01:00
|
|
|
#include "libtorrent/alert.hpp"
|
2009-11-26 22:40:10 +01:00
|
|
|
#include "libtorrent/alert_types.hpp"
|
2009-11-23 09:38:50 +01:00
|
|
|
#include "libtorrent/io_service.hpp"
|
2009-11-26 22:40:10 +01:00
|
|
|
#include "libtorrent/socket_io.hpp"
|
2009-11-25 07:55:34 +01:00
|
|
|
#include "libtorrent/time.hpp"
|
2009-11-27 08:08:47 +01:00
|
|
|
#include "libtorrent/error_code.hpp"
|
2011-01-29 11:37:21 +01:00
|
|
|
#include "libtorrent/extensions.hpp"
|
2014-07-06 21:18:00 +02:00
|
|
|
#include "libtorrent/torrent.hpp"
|
2015-03-12 05:34:54 +01:00
|
|
|
#include "libtorrent/aux_/time.hpp"
|
2015-04-03 22:15:48 +02:00
|
|
|
#include "libtorrent/performance_counters.hpp"
|
|
|
|
#include "libtorrent/stack_allocator.hpp"
|
2015-03-15 00:10:20 +01:00
|
|
|
|
|
|
|
#include "libtorrent/aux_/escape_string.hpp" // for convert_from_native
|
|
|
|
|
2009-05-23 23:36:09 +02:00
|
|
|
#include <boost/bind.hpp>
|
2003-11-29 17:34:07 +01:00
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
namespace libtorrent {
|
2004-01-23 01:39:05 +01:00
|
|
|
|
2015-03-12 05:34:54 +01:00
|
|
|
alert::alert() : m_timestamp(aux::time_now()) {}
|
2008-07-06 14:22:56 +02:00
|
|
|
alert::~alert() {}
|
2015-03-12 05:34:54 +01:00
|
|
|
time_point alert::timestamp() const { return m_timestamp; }
|
2004-01-23 01:39:05 +01:00
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
torrent_alert::torrent_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h)
|
2014-07-06 21:18:00 +02:00
|
|
|
: handle(h)
|
2015-04-03 22:15:48 +02:00
|
|
|
, m_alloc(alloc)
|
2009-11-26 22:40:10 +01:00
|
|
|
{
|
2015-04-03 22:15:48 +02:00
|
|
|
std::string name_str;
|
|
|
|
if (h.native_handle())
|
|
|
|
{
|
|
|
|
m_name_idx = alloc.copy_string(h.native_handle()->name());
|
|
|
|
}
|
|
|
|
else if (h.is_valid())
|
2009-11-26 22:40:10 +01:00
|
|
|
{
|
|
|
|
char msg[41];
|
2014-07-06 21:18:00 +02:00
|
|
|
to_hex((char const*)&h.native_handle()->info_hash()[0], 20, msg);
|
2015-04-03 22:15:48 +02:00
|
|
|
m_name_idx = alloc.copy_string(msg);
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
2015-04-03 22:15:48 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_name_idx = alloc.copy_string("");
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
name = torrent_name();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* torrent_alert::torrent_name() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_name_idx);
|
2014-07-06 21:18:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string torrent_alert::message() const
|
|
|
|
{
|
|
|
|
if (!handle.is_valid()) return " - ";
|
2015-04-03 22:15:48 +02:00
|
|
|
return torrent_name();
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
peer_alert::peer_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, tcp::endpoint const& i
|
|
|
|
, peer_id const& pi)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, ip(i)
|
|
|
|
, pid(pi)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string peer_alert::message() const
|
|
|
|
{
|
|
|
|
error_code ec;
|
2013-11-05 02:30:29 +01:00
|
|
|
return torrent_alert::message() + " peer (" + print_endpoint(ip)
|
2009-11-26 22:40:10 +01:00
|
|
|
+ ", " + identify_client(pid) + ")";
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
tracker_alert::tracker_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
2015-04-03 22:15:48 +02:00
|
|
|
, std::string const& u)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, url(u)
|
|
|
|
#endif
|
|
|
|
, m_url_idx(alloc.copy_string(u))
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* tracker_alert::tracker_url() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_url_idx);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string tracker_alert::message() const
|
|
|
|
{
|
2015-04-03 22:15:48 +02:00
|
|
|
return torrent_alert::message() + " (" + tracker_url() + ")";
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
read_piece_alert::read_piece_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, int p, boost::shared_array<char> d, int s)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, buffer(d)
|
|
|
|
, piece(p)
|
|
|
|
, size(s)
|
|
|
|
{}
|
|
|
|
|
|
|
|
read_piece_alert::read_piece_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle h, int p, error_code e)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, ec(e)
|
|
|
|
, piece(p)
|
|
|
|
, size(0)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string read_piece_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
2013-01-29 03:18:32 +01:00
|
|
|
if (ec)
|
|
|
|
{
|
|
|
|
snprintf(msg, sizeof(msg), "%s: read_piece %u failed: %s"
|
|
|
|
, torrent_alert::message().c_str() , piece, ec.message().c_str());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(msg, sizeof(msg), "%s: read_piece %u successful"
|
|
|
|
, torrent_alert::message().c_str() , piece);
|
|
|
|
}
|
2009-11-26 22:40:10 +01:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
file_completed_alert::file_completed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, int idx)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, index(idx)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string file_completed_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200 + TORRENT_MAX_PATH];
|
|
|
|
snprintf(msg, sizeof(msg), "%s: file %d finished downloading"
|
|
|
|
, torrent_alert::message().c_str(), index);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
file_renamed_alert::file_renamed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, std::string const& n
|
|
|
|
, int idx)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, name(n)
|
|
|
|
#endif
|
|
|
|
, index(idx)
|
|
|
|
, m_name_idx(alloc.copy_string(n))
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* file_renamed_alert::new_name() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_name_idx);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string file_renamed_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200 + TORRENT_MAX_PATH * 2];
|
2015-04-03 22:15:48 +02:00
|
|
|
snprintf(msg, sizeof(msg), "%s: file %d renamed to %s"
|
|
|
|
, torrent_alert::message().c_str(), index, new_name());
|
2009-11-26 22:40:10 +01:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
file_rename_failed_alert::file_rename_failed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, int idx
|
|
|
|
, error_code ec)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, index(idx)
|
|
|
|
, error(ec)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string file_rename_failed_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200 + TORRENT_MAX_PATH * 2];
|
|
|
|
snprintf(ret, sizeof(ret), "%s: failed to rename file %d: %s"
|
2013-01-19 07:39:32 +01:00
|
|
|
, torrent_alert::message().c_str(), index, convert_from_native(error.message()).c_str());
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
performance_alert::performance_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, performance_warning_t w)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, warning_code(w)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string performance_alert::message() const
|
|
|
|
{
|
|
|
|
static char const* warning_str[] =
|
|
|
|
{
|
|
|
|
"max outstanding disk writes reached",
|
|
|
|
"max outstanding piece requests reached",
|
|
|
|
"upload limit too low (download rate will suffer)",
|
|
|
|
"download limit too low (upload rate will suffer)",
|
2010-02-06 08:39:45 +01:00
|
|
|
"send buffer watermark too low (upload rate will suffer)",
|
2010-02-09 04:04:41 +01:00
|
|
|
"too many optimistic unchoke slots",
|
2011-03-16 08:45:51 +01:00
|
|
|
"using bittyrant unchoker with no upload rate limit set",
|
2012-03-03 03:29:37 +01:00
|
|
|
"the disk queue limit is too high compared to the cache size. The disk queue eats into the cache size",
|
2014-07-06 21:18:00 +02:00
|
|
|
"outstanding AIO operations limit reached",
|
2012-03-04 12:18:27 +01:00
|
|
|
"too few ports allowed for outgoing connections",
|
|
|
|
"too few file descriptors are allowed for this process. connection limit lowered"
|
2009-11-26 22:40:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
return torrent_alert::message() + ": performance warning: "
|
|
|
|
+ warning_str[warning_code];
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
state_changed_alert::state_changed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, torrent_status::state_t st
|
|
|
|
, torrent_status::state_t prev_st)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, state(st)
|
|
|
|
, prev_state(prev_st)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string state_changed_alert::message() const
|
|
|
|
{
|
|
|
|
static char const* state_str[] =
|
|
|
|
{"checking (q)", "checking", "dl metadata"
|
|
|
|
, "downloading", "finished", "seeding", "allocating"
|
|
|
|
, "checking (r)"};
|
|
|
|
|
|
|
|
return torrent_alert::message() + ": state changed to: "
|
|
|
|
+ state_str[state];
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
tracker_error_alert::tracker_error_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, int times
|
|
|
|
, int status
|
|
|
|
, std::string const& u
|
|
|
|
, error_code const& e
|
|
|
|
, std::string const& m)
|
|
|
|
: tracker_alert(alloc, h, u)
|
|
|
|
, times_in_row(times)
|
|
|
|
, status_code(status)
|
|
|
|
, error(e)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, msg(m)
|
|
|
|
#endif
|
|
|
|
, m_msg_idx(alloc.copy_string(m))
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(!u.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* tracker_error_alert::error_message() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_msg_idx);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string tracker_error_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
2015-02-21 23:45:45 +01:00
|
|
|
snprintf(ret, sizeof(ret), "%s (%d) %s \"%s\" (%d)"
|
2010-02-18 04:49:22 +01:00
|
|
|
, tracker_alert::message().c_str(), status_code
|
2015-04-03 22:15:48 +02:00
|
|
|
, error.message().c_str(), error_message(), times_in_row);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
tracker_warning_alert::tracker_warning_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, std::string const& u
|
|
|
|
, std::string const& m)
|
|
|
|
: tracker_alert(alloc, h, u)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, msg(m)
|
|
|
|
#endif
|
|
|
|
, m_msg_idx(alloc.copy_string(m))
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(!u.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* tracker_warning_alert::warning_message() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_msg_idx);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string tracker_warning_alert::message() const
|
|
|
|
{
|
2015-04-03 22:15:48 +02:00
|
|
|
return tracker_alert::message() + " warning: " + warning_message();
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
scrape_reply_alert::scrape_reply_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, int incomp
|
|
|
|
, int comp
|
|
|
|
, std::string const& u)
|
|
|
|
: tracker_alert(alloc, h, u)
|
|
|
|
, incomplete(incomp)
|
|
|
|
, complete(comp)
|
|
|
|
{
|
2015-04-11 17:31:36 +02:00
|
|
|
TORRENT_ASSERT(!u.empty());
|
2015-04-11 16:17:33 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string scrape_reply_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
|
|
|
snprintf(ret, sizeof(ret), "%s scrape reply: %u %u"
|
2010-02-18 04:49:22 +01:00
|
|
|
, tracker_alert::message().c_str(), incomplete, complete);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
scrape_failed_alert::scrape_failed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, std::string const& u
|
|
|
|
, error_code const& e)
|
|
|
|
: tracker_alert(alloc, h, u)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, msg(convert_from_native(e.message()))
|
|
|
|
#endif
|
|
|
|
, error(e)
|
|
|
|
, m_msg_idx(-1)
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(!u.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
scrape_failed_alert::scrape_failed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, std::string const& u
|
|
|
|
, std::string const& m)
|
|
|
|
: tracker_alert(alloc, h, u)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, msg(m)
|
|
|
|
#endif
|
|
|
|
, error(errors::tracker_failure)
|
|
|
|
, m_msg_idx(alloc.copy_string(m))
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(!u.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* scrape_failed_alert::error_message() const
|
|
|
|
{
|
|
|
|
if (m_msg_idx == -1) return "";
|
|
|
|
else return m_alloc.ptr(m_msg_idx);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string scrape_failed_alert::message() const
|
|
|
|
{
|
2015-04-03 22:15:48 +02:00
|
|
|
return tracker_alert::message() + " scrape failed: " + error_message();
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
tracker_reply_alert::tracker_reply_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, int np
|
|
|
|
, std::string const& u)
|
|
|
|
: tracker_alert(alloc, h, u)
|
|
|
|
, num_peers(np)
|
|
|
|
{
|
2015-04-11 17:31:36 +02:00
|
|
|
TORRENT_ASSERT(!u.empty());
|
2015-04-11 16:17:33 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string tracker_reply_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
|
|
|
snprintf(ret, sizeof(ret), "%s received peers: %u"
|
2010-02-18 04:49:22 +01:00
|
|
|
, tracker_alert::message().c_str(), num_peers);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
dht_reply_alert::dht_reply_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, int np)
|
|
|
|
: tracker_alert(alloc, h, "")
|
|
|
|
, num_peers(np)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string dht_reply_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
|
|
|
snprintf(ret, sizeof(ret), "%s received DHT peers: %u"
|
2010-02-18 04:49:22 +01:00
|
|
|
, tracker_alert::message().c_str(), num_peers);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
tracker_announce_alert::tracker_announce_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, std::string const& u, int e)
|
|
|
|
: tracker_alert(alloc, h, u)
|
|
|
|
, event(e)
|
|
|
|
{
|
2015-04-11 17:31:36 +02:00
|
|
|
TORRENT_ASSERT(!u.empty());
|
2015-04-11 16:17:33 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string tracker_announce_alert::message() const
|
|
|
|
{
|
2015-03-14 01:42:27 +01:00
|
|
|
static const char* event_str[] = {"none", "completed", "started", "stopped", "paused"};
|
2011-02-14 02:59:01 +01:00
|
|
|
TORRENT_ASSERT_VAL(event < int(sizeof(event_str)/sizeof(event_str[0])), event);
|
2009-11-26 22:40:10 +01:00
|
|
|
return tracker_alert::message() + " sending announce (" + event_str[event] + ")";
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
hash_failed_alert::hash_failed_alert(
|
|
|
|
aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, int index)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, piece_index(index)
|
|
|
|
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(index >= 0);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string hash_failed_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
|
|
|
snprintf(ret, sizeof(ret), "%s hash for piece %u failed"
|
|
|
|
, torrent_alert::message().c_str(), piece_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
peer_ban_alert::peer_ban_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle h, tcp::endpoint const& ep
|
|
|
|
, peer_id const& peer_id)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string peer_ban_alert::message() const
|
|
|
|
{
|
|
|
|
return peer_alert::message() + " banned peer";
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
peer_unsnubbed_alert::peer_unsnubbed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle h, tcp::endpoint const& ep
|
|
|
|
, peer_id const& peer_id)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string peer_unsnubbed_alert::message() const
|
|
|
|
{
|
|
|
|
return peer_alert::message() + " peer unsnubbed";
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
peer_snubbed_alert::peer_snubbed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle h, tcp::endpoint const& ep
|
|
|
|
, peer_id const& peer_id)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string peer_snubbed_alert::message() const
|
|
|
|
{
|
|
|
|
return peer_alert::message() + " peer snubbed";
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
invalid_request_alert::invalid_request_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep
|
2015-04-13 03:34:19 +02:00
|
|
|
, peer_id const& peer_id, peer_request const& r
|
|
|
|
, bool we_have, bool peer_interested, bool withheld)
|
2015-04-03 22:15:48 +02:00
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, request(r)
|
2015-04-13 03:34:19 +02:00
|
|
|
, we_have(we_have)
|
|
|
|
, peer_interested(peer_interested)
|
|
|
|
, withheld(withheld)
|
2015-04-03 22:15:48 +02:00
|
|
|
{}
|
2009-11-26 22:40:10 +01:00
|
|
|
|
|
|
|
std::string invalid_request_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2015-04-13 03:34:19 +02:00
|
|
|
snprintf(ret, sizeof(ret), "%s peer sent an invalid piece request "
|
|
|
|
"(piece: %u start: %u len: %u)%s"
|
|
|
|
, peer_alert::message().c_str(), request.piece, request.start
|
|
|
|
, request.length
|
|
|
|
, withheld ? ": super seeding withheld piece"
|
|
|
|
: !we_have ? ": we don't have piece"
|
|
|
|
: !peer_interested ? ": peer is not interested"
|
|
|
|
: "");
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
torrent_finished_alert::torrent_finished_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle h)
|
2015-04-03 22:15:48 +02:00
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string torrent_finished_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " torrent finished downloading";
|
|
|
|
}
|
2009-11-26 22:40:10 +01:00
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
piece_finished_alert::piece_finished_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, int piece_num)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(piece_index >= 0);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string piece_finished_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s piece: %u finished downloading"
|
|
|
|
, torrent_alert::message().c_str(), piece_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
request_dropped_alert::request_dropped_alert(aux::stack_allocator& alloc, torrent_handle h
|
|
|
|
, tcp::endpoint const& ep, peer_id const& peer_id, int block_num
|
|
|
|
, int piece_num)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);
|
|
|
|
}
|
2009-11-26 22:40:10 +01:00
|
|
|
|
|
|
|
std::string request_dropped_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s peer dropped block ( piece: %u block: %u)"
|
|
|
|
, torrent_alert::message().c_str(), piece_index, block_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
block_timeout_alert::block_timeout_alert(aux::stack_allocator& alloc, torrent_handle h
|
|
|
|
, tcp::endpoint const& ep, peer_id const& peer_id, int block_num
|
|
|
|
, int piece_num)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string block_timeout_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s peer timed out request ( piece: %u block: %u)"
|
|
|
|
, torrent_alert::message().c_str(), piece_index, block_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
block_finished_alert::block_finished_alert(aux::stack_allocator& alloc, torrent_handle h
|
|
|
|
, tcp::endpoint const& ep, peer_id const& peer_id, int block_num
|
|
|
|
, int piece_num)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string block_finished_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s block finished downloading (piece: %u block: %u)"
|
|
|
|
, torrent_alert::message().c_str(), piece_index, block_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
block_downloading_alert::block_downloading_alert(aux::stack_allocator& alloc, torrent_handle h
|
|
|
|
, tcp::endpoint const& ep
|
|
|
|
, peer_id const& peer_id, int block_num, int piece_num)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, peer_speedmsg("")
|
|
|
|
#endif
|
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string block_downloading_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2015-02-10 05:37:10 +01:00
|
|
|
snprintf(ret, sizeof(ret), "%s requested block (piece: %u block: %u)"
|
|
|
|
, torrent_alert::message().c_str(), piece_index, block_index);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
unwanted_block_alert::unwanted_block_alert(aux::stack_allocator& alloc, torrent_handle h
|
|
|
|
, tcp::endpoint const& ep
|
|
|
|
, peer_id const& peer_id, int block_num, int piece_num)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string unwanted_block_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s received block not in download queue (piece: %u block: %u)"
|
|
|
|
, torrent_alert::message().c_str(), piece_index, block_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
storage_moved_alert::storage_moved_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, std::string const& p)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, path(p)
|
|
|
|
#endif
|
|
|
|
, m_path_idx(alloc.copy_string(p))
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string storage_moved_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " moved storage to: "
|
|
|
|
+ storage_path();
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* storage_moved_alert::storage_path() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_path_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
storage_moved_failed_alert::storage_moved_failed_alert(
|
|
|
|
aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, error_code const& e
|
|
|
|
, std::string const& file
|
|
|
|
, char const* op)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, error(e)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, file(file)
|
|
|
|
#endif
|
|
|
|
, operation(op)
|
|
|
|
, m_file_idx(alloc.copy_string(file))
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* storage_moved_failed_alert::file_path() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_file_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string storage_moved_failed_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " storage move failed. "
|
|
|
|
+ (operation?operation:"") + " (" + file_path() + "): "
|
|
|
|
+ convert_from_native(error.message());
|
|
|
|
}
|
|
|
|
|
|
|
|
torrent_deleted_alert::torrent_deleted_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, sha1_hash const& ih)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, info_hash(ih)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string torrent_deleted_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " deleted";
|
|
|
|
}
|
|
|
|
|
|
|
|
torrent_delete_failed_alert::torrent_delete_failed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, error_code const& e, sha1_hash const& ih)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, error(e)
|
|
|
|
, info_hash(ih)
|
|
|
|
{
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
msg = convert_from_native(error.message());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string torrent_delete_failed_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " torrent deletion failed: "
|
|
|
|
+convert_from_native(error.message());
|
|
|
|
}
|
|
|
|
|
|
|
|
save_resume_data_alert::save_resume_data_alert(aux::stack_allocator& alloc
|
|
|
|
, boost::shared_ptr<entry> const& rd
|
|
|
|
, torrent_handle const& h)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, resume_data(rd)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string save_resume_data_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " resume data generated";
|
|
|
|
}
|
|
|
|
|
|
|
|
save_resume_data_failed_alert::save_resume_data_failed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, error_code const& e)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, error(e)
|
|
|
|
{
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
msg = convert_from_native(error.message());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string save_resume_data_failed_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " resume data was not generated: "
|
|
|
|
+ convert_from_native(error.message());
|
|
|
|
}
|
|
|
|
|
|
|
|
torrent_paused_alert::torrent_paused_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string torrent_paused_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " paused";
|
|
|
|
}
|
|
|
|
|
|
|
|
torrent_resumed_alert::torrent_resumed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string torrent_resumed_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " resumed";
|
|
|
|
}
|
|
|
|
|
|
|
|
torrent_checked_alert::torrent_checked_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string torrent_checked_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " checked";
|
|
|
|
}
|
|
|
|
|
2015-02-15 06:17:09 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
static char const* const sock_type_str[] =
|
|
|
|
{
|
|
|
|
"TCP", "TCP/SSL", "UDP", "I2P", "Socks5", "uTP/SSL"
|
|
|
|
};
|
|
|
|
|
|
|
|
static char const* const nat_type_str[] = {"NAT-PMP", "UPnP"};
|
|
|
|
|
|
|
|
static char const* const socket_type_str[] = {
|
|
|
|
"null",
|
|
|
|
"TCP",
|
|
|
|
"Socks5/TCP",
|
|
|
|
"HTTP",
|
|
|
|
"uTP",
|
|
|
|
"i2p",
|
|
|
|
"SSL/TCP",
|
|
|
|
"SSL/Socks5",
|
|
|
|
"HTTPS",
|
|
|
|
"SSL/uTP"
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
listen_failed_alert::listen_failed_alert(
|
|
|
|
aux::stack_allocator& alloc
|
|
|
|
, std::string iface
|
|
|
|
, int op
|
|
|
|
, error_code const& ec
|
|
|
|
, socket_type_t t)
|
|
|
|
:
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
interface(iface),
|
|
|
|
#endif
|
|
|
|
error(ec)
|
|
|
|
, operation(op)
|
|
|
|
, sock_type(t)
|
|
|
|
, m_alloc(alloc)
|
|
|
|
, m_interface_idx(alloc.copy_string(iface))
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* listen_failed_alert::listen_interface() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_interface_idx);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string listen_failed_alert::message() const
|
|
|
|
{
|
2013-10-06 08:32:33 +02:00
|
|
|
static char const* op_str[] =
|
2013-06-04 02:35:42 +02:00
|
|
|
{
|
|
|
|
"parse_addr",
|
|
|
|
"open",
|
|
|
|
"bind",
|
|
|
|
"listen",
|
|
|
|
"get_peer_name",
|
|
|
|
"accept"
|
|
|
|
};
|
2014-07-06 21:18:00 +02:00
|
|
|
char ret[300];
|
2013-10-06 08:32:33 +02:00
|
|
|
snprintf(ret, sizeof(ret), "listening on %s failed: [%s] [%s] %s"
|
2015-04-03 22:15:48 +02:00
|
|
|
, listen_interface()
|
2013-06-04 02:35:42 +02:00
|
|
|
, op_str[operation]
|
2015-02-15 06:17:09 +01:00
|
|
|
, sock_type_str[sock_type]
|
2013-06-04 02:35:42 +02:00
|
|
|
, convert_from_native(error.message()).c_str());
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
metadata_failed_alert::metadata_failed_alert(aux::stack_allocator& alloc
|
|
|
|
, const torrent_handle& h, error_code const& e)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, error(e)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string metadata_failed_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " invalid metadata received";
|
|
|
|
}
|
|
|
|
|
|
|
|
metadata_received_alert::metadata_received_alert(aux::stack_allocator& alloc
|
|
|
|
, const torrent_handle& h)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string metadata_received_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " metadata successfully received";
|
|
|
|
}
|
|
|
|
|
|
|
|
udp_error_alert::udp_error_alert(
|
2015-04-19 00:00:27 +02:00
|
|
|
aux::stack_allocator&
|
2015-04-11 16:17:33 +02:00
|
|
|
, udp::endpoint const& ep
|
|
|
|
, error_code const& ec)
|
|
|
|
: endpoint(ep)
|
|
|
|
, error(ec)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string udp_error_alert::message() const
|
|
|
|
{
|
|
|
|
error_code ec;
|
|
|
|
return "UDP error: " + convert_from_native(error.message()) + " from: " + endpoint.address().to_string(ec);
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
external_ip_alert::external_ip_alert(aux::stack_allocator&
|
2015-04-11 16:17:33 +02:00
|
|
|
, address const& ip)
|
|
|
|
: external_address(ip)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string external_ip_alert::message() const
|
|
|
|
{
|
|
|
|
error_code ec;
|
|
|
|
return "external IP received: " + external_address.to_string(ec);
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
listen_succeeded_alert::listen_succeeded_alert(aux::stack_allocator&
|
2015-04-11 16:17:33 +02:00
|
|
|
, tcp::endpoint const& ep, socket_type_t t)
|
|
|
|
: endpoint(ep)
|
|
|
|
, sock_type(t)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string listen_succeeded_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2013-10-06 08:32:33 +02:00
|
|
|
snprintf(ret, sizeof(ret), "successfully listening on [%s] %s"
|
2015-02-15 06:17:09 +01:00
|
|
|
, sock_type_str[sock_type], print_endpoint(endpoint).c_str());
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
portmap_error_alert::portmap_error_alert(aux::stack_allocator&
|
2015-04-11 16:17:33 +02:00
|
|
|
, int i, int t, error_code const& e)
|
|
|
|
: mapping(i), map_type(t), error(e)
|
|
|
|
{
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
msg = convert_from_native(error.message());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string portmap_error_alert::message() const
|
|
|
|
{
|
2015-02-15 06:17:09 +01:00
|
|
|
return std::string("could not map port using ") + nat_type_str[map_type]
|
2013-01-19 07:39:32 +01:00
|
|
|
+ ": " + convert_from_native(error.message());
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
portmap_alert::portmap_alert(aux::stack_allocator&, int i, int port, int t)
|
2015-04-11 16:17:33 +02:00
|
|
|
: mapping(i), external_port(port), map_type(t)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string portmap_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "successfully mapped port using %s. external port: %u"
|
2015-02-15 06:17:09 +01:00
|
|
|
, nat_type_str[map_type], external_port);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
portmap_log_alert::portmap_log_alert(aux::stack_allocator& alloc, int t, const char* m)
|
|
|
|
: map_type(t)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, msg(m)
|
|
|
|
#endif
|
|
|
|
, m_alloc(alloc)
|
|
|
|
, m_log_idx(alloc.copy_string(m))
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* portmap_log_alert::log_message() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_log_idx);
|
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string portmap_log_alert::message() const
|
|
|
|
{
|
2009-12-25 23:30:18 +01:00
|
|
|
char ret[600];
|
2015-04-03 22:15:48 +02:00
|
|
|
snprintf(ret, sizeof(ret), "%s: %s", nat_type_str[map_type]
|
|
|
|
, log_message());
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
fastresume_rejected_alert::fastresume_rejected_alert(
|
|
|
|
aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, error_code const& ec
|
|
|
|
, std::string const& file
|
|
|
|
, char const* op)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, error(ec)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, file(file)
|
|
|
|
#endif
|
|
|
|
, operation(op)
|
|
|
|
, m_path_idx(alloc.copy_string(file))
|
|
|
|
{
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
msg = convert_from_native(error.message());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string fastresume_rejected_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " fast resume rejected. "
|
|
|
|
+ (operation?operation:"") + "(" + file_path() + "): "
|
|
|
|
+ convert_from_native(error.message());
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* fastresume_rejected_alert::file_path() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_path_idx);
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
peer_blocked_alert::peer_blocked_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, address const& i
|
|
|
|
, int r)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, ip(i)
|
|
|
|
, reason(r)
|
|
|
|
{}
|
|
|
|
|
2014-02-07 18:35:56 +01:00
|
|
|
std::string peer_blocked_alert::message() const
|
|
|
|
{
|
|
|
|
error_code ec;
|
|
|
|
char ret[600];
|
|
|
|
char const* reason_str[] =
|
|
|
|
{
|
|
|
|
"ip_filter",
|
|
|
|
"port_filter",
|
|
|
|
"i2p_mixed",
|
|
|
|
"privileged_ports",
|
|
|
|
"utp_disabled",
|
2014-07-06 21:18:00 +02:00
|
|
|
"tcp_disabled",
|
|
|
|
"invalid_local_interface"
|
2014-02-07 18:35:56 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
snprintf(ret, sizeof(ret), "%s: blocked peer: %s [%s]"
|
|
|
|
, torrent_alert::message().c_str(), ip.to_string(ec).c_str()
|
|
|
|
, reason_str[reason]);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_announce_alert::dht_announce_alert(aux::stack_allocator&
|
2015-04-11 16:17:33 +02:00
|
|
|
, address const& i, int p
|
|
|
|
, sha1_hash const& ih)
|
|
|
|
: ip(i)
|
|
|
|
, port(p)
|
|
|
|
, info_hash(ih)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string dht_announce_alert::message() const
|
|
|
|
{
|
|
|
|
error_code ec;
|
|
|
|
char ih_hex[41];
|
|
|
|
to_hex((const char*)&info_hash[0], 20, ih_hex);
|
|
|
|
char msg[200];
|
|
|
|
snprintf(msg, sizeof(msg), "incoming dht announce: %s:%u (%s)"
|
|
|
|
, ip.to_string(ec).c_str(), port, ih_hex);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_get_peers_alert::dht_get_peers_alert(aux::stack_allocator&
|
2015-04-11 16:17:33 +02:00
|
|
|
, sha1_hash const& ih)
|
|
|
|
: info_hash(ih)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string dht_get_peers_alert::message() const
|
|
|
|
{
|
|
|
|
char ih_hex[41];
|
|
|
|
to_hex((const char*)&info_hash[0], 20, ih_hex);
|
|
|
|
char msg[200];
|
|
|
|
snprintf(msg, sizeof(msg), "incoming dht get_peers: %s", ih_hex);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
stats_alert::stats_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, int in, stat const& s)
|
|
|
|
: torrent_alert(alloc, h)
|
2010-01-02 15:16:35 +01:00
|
|
|
, interval(in)
|
|
|
|
{
|
2014-11-29 09:17:25 +01:00
|
|
|
transferred[upload_payload] = s[stat::upload_payload].counter();
|
|
|
|
transferred[upload_protocol] = s[stat::upload_protocol].counter();
|
|
|
|
transferred[download_payload] = s[stat::download_payload].counter();
|
|
|
|
transferred[download_protocol] = s[stat::download_protocol].counter();
|
|
|
|
transferred[upload_ip_protocol] = s[stat::upload_ip_protocol].counter();
|
|
|
|
transferred[download_ip_protocol] = s[stat::download_ip_protocol].counter();
|
2014-11-26 11:17:44 +01:00
|
|
|
|
2014-10-26 01:10:07 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
transferred[upload_dht_protocol] = 0;
|
|
|
|
transferred[upload_tracker_protocol] = 0;
|
|
|
|
transferred[download_dht_protocol] = 0;
|
|
|
|
transferred[download_tracker_protocol] = 0;
|
2014-11-26 11:17:44 +01:00
|
|
|
#else
|
|
|
|
transferred[deprecated1] = 0;
|
|
|
|
transferred[deprecated2] = 0;
|
|
|
|
transferred[deprecated3] = 0;
|
|
|
|
transferred[deprecated4] = 0;
|
2014-10-26 01:10:07 +02:00
|
|
|
#endif
|
2010-01-02 15:16:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string stats_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
2014-10-26 01:10:07 +02:00
|
|
|
snprintf(msg, sizeof(msg), "%s: [%d] %d %d %d %d %d %d"
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
" %d %d %d %d"
|
|
|
|
#endif
|
2010-01-02 15:16:35 +01:00
|
|
|
, torrent_alert::message().c_str()
|
|
|
|
, interval
|
|
|
|
, transferred[0]
|
|
|
|
, transferred[1]
|
|
|
|
, transferred[2]
|
|
|
|
, transferred[3]
|
|
|
|
, transferred[4]
|
|
|
|
, transferred[5]
|
2014-10-26 01:10:07 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2010-01-02 15:16:35 +01:00
|
|
|
, transferred[6]
|
|
|
|
, transferred[7]
|
|
|
|
, transferred[8]
|
2014-10-26 01:10:07 +02:00
|
|
|
, transferred[9]
|
|
|
|
#endif
|
|
|
|
);
|
2010-01-02 15:16:35 +01:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
cache_flushed_alert::cache_flushed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h)
|
|
|
|
: torrent_alert(alloc, h) {}
|
2010-01-09 22:17:52 +01:00
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
anonymous_mode_alert::anonymous_mode_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, int k, std::string const& s)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, kind(k)
|
|
|
|
, str(s)
|
|
|
|
{}
|
|
|
|
|
2010-04-13 06:30:34 +02:00
|
|
|
std::string anonymous_mode_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
|
|
|
char const* msgs[] = {
|
|
|
|
"tracker is not anonymous, set a proxy"
|
|
|
|
};
|
|
|
|
snprintf(msg, sizeof(msg), "%s: %s: %s"
|
|
|
|
, torrent_alert::message().c_str()
|
|
|
|
, msgs[kind], str.c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
lsd_peer_alert::lsd_peer_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
|
|
|
, tcp::endpoint const& i)
|
|
|
|
: peer_alert(alloc, h, i, peer_id(0))
|
|
|
|
{}
|
|
|
|
|
2010-07-15 07:56:29 +02:00
|
|
|
std::string lsd_peer_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
|
|
|
snprintf(msg, sizeof(msg), "%s: received peer from local service discovery"
|
|
|
|
, peer_alert::message().c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
trackerid_alert::trackerid_alert(
|
|
|
|
aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, std::string const& u
|
|
|
|
, const std::string& id)
|
|
|
|
: tracker_alert(alloc, h, u)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, trackerid(id)
|
|
|
|
#endif
|
|
|
|
, m_tracker_idx(alloc.copy_string(id))
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* trackerid_alert::tracker_id() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_tracker_idx);
|
|
|
|
}
|
|
|
|
|
2010-11-18 06:51:52 +01:00
|
|
|
std::string trackerid_alert::message() const
|
|
|
|
{
|
2015-04-03 22:15:48 +02:00
|
|
|
return std::string("trackerid received: ") + tracker_id();
|
2010-11-18 06:51:52 +01:00
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_bootstrap_alert::dht_bootstrap_alert(aux::stack_allocator&)
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
|
|
|
|
2010-12-12 04:17:08 +01:00
|
|
|
std::string dht_bootstrap_alert::message() const
|
|
|
|
{
|
|
|
|
return "DHT bootstrap complete";
|
|
|
|
}
|
|
|
|
|
2015-03-28 18:31:27 +01:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2015-04-19 00:00:27 +02:00
|
|
|
rss_alert::rss_alert(aux::stack_allocator&, feed_handle h
|
2015-04-11 16:17:33 +02:00
|
|
|
, std::string const& u, int s, error_code const& ec)
|
|
|
|
: handle(h), url(u), state(s), error(ec)
|
|
|
|
{}
|
|
|
|
|
2011-01-18 04:41:54 +01:00
|
|
|
std::string rss_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
char const* state_msg[] = {"updating", "updated", "error"};
|
|
|
|
snprintf(msg, sizeof(msg), "RSS feed %s: %s (%s)"
|
2013-01-19 07:39:32 +01:00
|
|
|
, url.c_str(), state_msg[state], convert_from_native(error.message()).c_str());
|
2011-01-18 04:41:54 +01:00
|
|
|
return msg;
|
|
|
|
}
|
2015-03-28 18:31:27 +01:00
|
|
|
#endif
|
2011-01-18 04:41:54 +01:00
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
torrent_error_alert::torrent_error_alert(
|
|
|
|
aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, error_code const& e, std::string const& f)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, error(e)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, error_file(f)
|
|
|
|
#endif
|
|
|
|
, m_file_idx(alloc.copy_string(f))
|
|
|
|
{}
|
|
|
|
|
2011-01-22 20:06:43 +01:00
|
|
|
std::string torrent_error_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
2013-01-19 07:39:32 +01:00
|
|
|
snprintf(msg, sizeof(msg), " ERROR: %s", convert_from_native(error.message()).c_str());
|
2011-01-22 20:06:43 +01:00
|
|
|
return torrent_alert::message() + msg;
|
|
|
|
}
|
2015-05-17 04:00:43 +02:00
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
torrent_added_alert::torrent_added_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
{}
|
|
|
|
|
2011-02-01 04:25:40 +01:00
|
|
|
std::string torrent_added_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " added";
|
|
|
|
}
|
2011-01-22 20:06:43 +01:00
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
torrent_removed_alert::torrent_removed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, sha1_hash const& ih)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, info_hash(ih)
|
|
|
|
{}
|
|
|
|
|
2011-02-01 04:25:40 +01:00
|
|
|
std::string torrent_removed_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " removed";
|
|
|
|
}
|
2011-01-22 20:06:43 +01:00
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
torrent_need_cert_alert::torrent_need_cert_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
{}
|
|
|
|
|
2011-09-12 05:51:49 +02:00
|
|
|
std::string torrent_need_cert_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " needs SSL certificate";
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
incoming_connection_alert::incoming_connection_alert(aux::stack_allocator&, int t
|
2015-04-11 16:17:33 +02:00
|
|
|
, tcp::endpoint const& i)
|
|
|
|
: socket_type(t)
|
|
|
|
, ip(i)
|
|
|
|
{}
|
2015-05-17 04:00:43 +02:00
|
|
|
|
2011-09-17 03:44:05 +02:00
|
|
|
std::string incoming_connection_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
error_code ec;
|
|
|
|
snprintf(msg, sizeof(msg), "incoming connection from %s (%s)"
|
2015-02-15 06:17:09 +01:00
|
|
|
, print_endpoint(ip).c_str(), socket_type_str[socket_type]);
|
2011-09-17 03:44:05 +02:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
peer_connect_alert::peer_connect_alert(aux::stack_allocator& alloc, torrent_handle h
|
|
|
|
, tcp::endpoint const& ep, peer_id const& peer_id, int type)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, socket_type(type)
|
|
|
|
{}
|
|
|
|
|
2013-08-01 02:44:14 +02:00
|
|
|
std::string peer_connect_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
error_code ec;
|
|
|
|
snprintf(msg, sizeof(msg), "%s connecting to peer (%s)"
|
2015-02-15 06:17:09 +01:00
|
|
|
, peer_alert::message().c_str(), socket_type_str[socket_type]);
|
2013-08-01 02:44:14 +02:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
add_torrent_alert::add_torrent_alert(aux::stack_allocator& alloc, torrent_handle h
|
|
|
|
, add_torrent_params const& p, error_code ec)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, params(p)
|
|
|
|
, error(ec)
|
|
|
|
{}
|
2015-05-17 04:00:43 +02:00
|
|
|
|
2011-10-12 12:27:17 +02:00
|
|
|
std::string add_torrent_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
2014-08-20 09:02:03 +02:00
|
|
|
char info_hash[41];
|
|
|
|
char const* torrent_name = info_hash;
|
|
|
|
if (params.ti) torrent_name = params.ti->name().c_str();
|
|
|
|
else if (!params.name.empty()) torrent_name = params.name.c_str();
|
|
|
|
else if (!params.url.empty()) torrent_name = params.url.c_str();
|
|
|
|
else to_hex((const char*)¶ms.info_hash[0], 20, info_hash);
|
|
|
|
|
2011-10-12 12:27:17 +02:00
|
|
|
if (error)
|
|
|
|
{
|
2014-08-20 09:02:03 +02:00
|
|
|
snprintf(msg, sizeof(msg), "failed to add torrent \"%s\": [%s] %s"
|
|
|
|
, torrent_name, error.category().name()
|
2013-01-19 07:39:32 +01:00
|
|
|
, convert_from_native(error.message()).c_str());
|
2011-10-12 12:27:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-20 09:02:03 +02:00
|
|
|
snprintf(msg, sizeof(msg), "added torrent: %s", torrent_name);
|
2011-10-12 12:27:17 +02:00
|
|
|
}
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
state_update_alert::state_update_alert(aux::stack_allocator&
|
|
|
|
, std::vector<torrent_status> st)
|
|
|
|
: status(st)
|
|
|
|
{}
|
|
|
|
|
2011-11-15 03:34:00 +01:00
|
|
|
std::string state_update_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
snprintf(msg, sizeof(msg), "state updates for %d torrents", int(status.size()));
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
mmap_cache_alert::mmap_cache_alert(aux::stack_allocator&
|
|
|
|
, error_code const& ec): error(ec)
|
|
|
|
{}
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
std::string mmap_cache_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
snprintf(msg, sizeof(msg), "mmap cache failed: (%d) %s", error.value(), error.message().c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
peer_error_alert::peer_error_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
|
|
|
, tcp::endpoint const& ep, peer_id const& peer_id, int op
|
|
|
|
, error_code const& e)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, operation(op)
|
|
|
|
, error(e)
|
|
|
|
{
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
msg = convert_from_native(error.message());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-07-06 21:18:00 +02:00
|
|
|
std::string peer_error_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
2015-02-28 20:51:15 +01:00
|
|
|
snprintf(msg, sizeof(msg), "%s peer error [%s] [%s]: %s"
|
|
|
|
, peer_alert::message().c_str()
|
|
|
|
, operation_name(operation), error.category().name()
|
|
|
|
, convert_from_native(error.message()).c_str());
|
2014-07-06 21:18:00 +02:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* operation_name(int op)
|
|
|
|
{
|
|
|
|
static char const* names[] = {
|
|
|
|
"bittorrent",
|
|
|
|
"iocontrol",
|
|
|
|
"getpeername",
|
|
|
|
"getname",
|
|
|
|
"alloc_recvbuf",
|
|
|
|
"alloc_sndbuf",
|
|
|
|
"file_write",
|
|
|
|
"file_read",
|
|
|
|
"file",
|
|
|
|
"sock_write",
|
|
|
|
"sock_read",
|
|
|
|
"sock_open",
|
|
|
|
"sock_bind",
|
|
|
|
"available",
|
|
|
|
"encryption",
|
|
|
|
"connect",
|
|
|
|
"ssl_handshake",
|
|
|
|
"get_interface",
|
|
|
|
};
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
if (op < 0 || op >= int(sizeof(names)/sizeof(names[0])))
|
2014-07-06 21:18:00 +02:00
|
|
|
return "unknown operation";
|
|
|
|
|
|
|
|
return names[op];
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
torrent_update_alert::torrent_update_alert(aux::stack_allocator& alloc, torrent_handle h
|
|
|
|
, sha1_hash const& old_hash, sha1_hash const& new_hash)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, old_ih(old_hash)
|
|
|
|
, new_ih(new_hash)
|
|
|
|
{}
|
2015-05-17 04:00:43 +02:00
|
|
|
|
2013-05-17 05:19:23 +02:00
|
|
|
std::string torrent_update_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
|
|
|
snprintf(msg, sizeof(msg), " torrent changed info-hash from: %s to %s"
|
|
|
|
, to_hex(old_ih.to_string()).c_str()
|
|
|
|
, to_hex(new_ih.to_string()).c_str());
|
|
|
|
return torrent_alert::message() + msg;
|
|
|
|
}
|
|
|
|
|
2015-03-28 18:31:27 +01:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2015-04-19 00:00:27 +02:00
|
|
|
rss_item_alert::rss_item_alert(aux::stack_allocator&, feed_handle h
|
2015-04-11 16:17:33 +02:00
|
|
|
, feed_item const& item)
|
|
|
|
: handle(h)
|
|
|
|
, item(item)
|
|
|
|
{}
|
2015-05-17 04:00:43 +02:00
|
|
|
|
2013-06-02 04:48:57 +02:00
|
|
|
std::string rss_item_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[500];
|
|
|
|
snprintf(msg, sizeof(msg), "feed [%s] has new RSS item %s"
|
|
|
|
, handle.get_feed_status().title.c_str()
|
|
|
|
, item.title.empty() ? item.url.c_str() : item.title.c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
2015-03-28 18:31:27 +01:00
|
|
|
#endif
|
2013-06-02 04:48:57 +02:00
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
peer_disconnected_alert::peer_disconnected_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep
|
|
|
|
, peer_id const& peer_id, operation_t op, int type, error_code const& e
|
|
|
|
, close_reason_t r)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, socket_type(type)
|
|
|
|
, operation(op)
|
|
|
|
, error(e)
|
|
|
|
, reason(r)
|
|
|
|
{
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
msg = convert_from_native(error.message());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-07-28 17:06:28 +02:00
|
|
|
std::string peer_disconnected_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
2015-02-28 20:51:15 +01:00
|
|
|
snprintf(msg, sizeof(msg), "%s disconnecting (%s) [%s] [%s]: %s (reason: %d)"
|
2015-02-15 06:17:09 +01:00
|
|
|
, peer_alert::message().c_str()
|
|
|
|
, socket_type_str[socket_type]
|
|
|
|
, operation_name(operation), error.category().name()
|
2015-02-28 20:51:15 +01:00
|
|
|
, convert_from_native(error.message()).c_str()
|
|
|
|
, int(reason));
|
2013-07-28 17:06:28 +02:00
|
|
|
return msg;
|
|
|
|
}
|
2014-01-20 10:20:47 +01:00
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_error_alert::dht_error_alert(aux::stack_allocator&, int op
|
|
|
|
, error_code const& ec)
|
2015-04-11 16:17:33 +02:00
|
|
|
: error(ec), operation(op_t(op))
|
|
|
|
{}
|
2015-05-17 04:00:43 +02:00
|
|
|
|
2014-01-20 10:20:47 +01:00
|
|
|
std::string dht_error_alert::message() const
|
|
|
|
{
|
2015-03-14 01:42:27 +01:00
|
|
|
static const char* const operation_names[] =
|
2014-01-20 10:20:47 +01:00
|
|
|
{
|
2014-01-31 07:01:29 +01:00
|
|
|
"unknown",
|
2014-01-20 10:20:47 +01:00
|
|
|
"hostname lookup"
|
|
|
|
};
|
|
|
|
|
|
|
|
int op = operation;
|
2015-04-29 06:05:29 +02:00
|
|
|
if (op < 0 || op >= int(sizeof(operation_names)/sizeof(operation_names[0])))
|
2014-01-20 10:20:47 +01:00
|
|
|
op = 0;
|
|
|
|
|
|
|
|
char msg[600];
|
|
|
|
snprintf(msg, sizeof(msg), "DHT error [%s] (%d) %s"
|
|
|
|
, operation_names[op]
|
|
|
|
, error.value()
|
|
|
|
, convert_from_native(error.message()).c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_immutable_item_alert::dht_immutable_item_alert(aux::stack_allocator&
|
2015-04-11 16:17:33 +02:00
|
|
|
, sha1_hash const& t, entry const& i)
|
|
|
|
: target(t), item(i)
|
|
|
|
{}
|
2015-05-17 04:00:43 +02:00
|
|
|
|
2014-02-24 01:31:13 +01:00
|
|
|
std::string dht_immutable_item_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[1050];
|
|
|
|
snprintf(msg, sizeof(msg), "DHT immutable item %s [ %s ]"
|
|
|
|
, to_hex(target.to_string()).c_str()
|
|
|
|
, item.to_string().c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
// TODO: 2 the salt here is allocated on the heap. It would be nice to
|
|
|
|
// allocate in in the stack_allocator
|
|
|
|
dht_mutable_item_alert::dht_mutable_item_alert(aux::stack_allocator&
|
2015-04-11 16:17:33 +02:00
|
|
|
, boost::array<char, 32> k
|
|
|
|
, boost::array<char, 64> sig
|
|
|
|
, boost::uint64_t sequence
|
|
|
|
, std::string const& s
|
|
|
|
, entry const& i)
|
|
|
|
: key(k), signature(sig), seq(sequence), salt(s), item(i)
|
|
|
|
{}
|
|
|
|
|
2014-02-24 01:31:13 +01:00
|
|
|
std::string dht_mutable_item_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[1050];
|
|
|
|
snprintf(msg, sizeof(msg), "DHT mutable item (key=%s salt=%s seq=%" PRId64 ") [ %s ]"
|
|
|
|
, to_hex(std::string(&key[0], 32)).c_str()
|
|
|
|
, salt.c_str()
|
|
|
|
, seq
|
|
|
|
, item.to_string().c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_put_alert::dht_put_alert(aux::stack_allocator&, sha1_hash const& t)
|
2015-04-11 16:17:33 +02:00
|
|
|
: target(t)
|
|
|
|
, seq(0)
|
|
|
|
{}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_put_alert::dht_put_alert(aux::stack_allocator&
|
2015-04-11 16:17:33 +02:00
|
|
|
, boost::array<char, 32> key
|
|
|
|
, boost::array<char, 64> sig
|
|
|
|
, std::string s
|
|
|
|
, boost::uint64_t sequence_number)
|
|
|
|
: target(0)
|
|
|
|
, public_key(key)
|
|
|
|
, signature(sig)
|
|
|
|
, salt(s)
|
|
|
|
, seq(sequence_number)
|
|
|
|
{}
|
|
|
|
|
2014-02-28 05:02:48 +01:00
|
|
|
std::string dht_put_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[1050];
|
|
|
|
snprintf(msg, sizeof(msg), "DHT put complete (key=%s sig=%s salt=%s seq=%" PRId64 ")"
|
|
|
|
, to_hex(std::string(&public_key[0], 32)).c_str()
|
|
|
|
, to_hex(std::string(&signature[0], 64)).c_str()
|
|
|
|
, salt.c_str()
|
|
|
|
, seq);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
i2p_alert::i2p_alert(aux::stack_allocator&, error_code const& ec)
|
2015-04-11 16:17:33 +02:00
|
|
|
: error(ec)
|
|
|
|
{}
|
|
|
|
|
2014-03-15 23:20:19 +01:00
|
|
|
std::string i2p_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
snprintf(msg, sizeof(msg), "i2p_error: [%s] %s"
|
|
|
|
, error.category().name(), convert_from_native(error.message()).c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
2014-02-24 01:31:13 +01:00
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_outgoing_get_peers_alert::dht_outgoing_get_peers_alert(aux::stack_allocator&
|
|
|
|
, sha1_hash const& ih, sha1_hash const& obfih
|
|
|
|
, udp::endpoint ep)
|
|
|
|
: info_hash(ih)
|
|
|
|
, obfuscated_info_hash(obfih)
|
|
|
|
, ip(ep)
|
|
|
|
{}
|
|
|
|
|
2014-09-22 21:49:32 +02:00
|
|
|
std::string dht_outgoing_get_peers_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
char obf[70];
|
|
|
|
obf[0] = '\0';
|
|
|
|
if (obfuscated_info_hash != info_hash)
|
|
|
|
{
|
|
|
|
snprintf(obf, sizeof(obf), " [obfuscated: %s]"
|
|
|
|
, to_hex(obfuscated_info_hash.to_string()).c_str());
|
|
|
|
}
|
|
|
|
snprintf(msg, sizeof(msg), "outgoing dht get_peers : %s%s -> %s"
|
|
|
|
, to_hex(info_hash.to_string()).c_str()
|
|
|
|
, obf
|
|
|
|
, print_endpoint(ip).c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
log_alert::log_alert(aux::stack_allocator& alloc, char const* log)
|
|
|
|
: m_alloc(alloc)
|
|
|
|
, m_str_idx(alloc.copy_string(log))
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* log_alert::msg() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_str_idx);
|
|
|
|
}
|
|
|
|
|
2014-12-09 10:08:26 +01:00
|
|
|
std::string log_alert::message() const
|
|
|
|
{
|
2015-04-03 22:15:48 +02:00
|
|
|
return msg();
|
|
|
|
}
|
|
|
|
|
|
|
|
torrent_log_alert::torrent_log_alert(aux::stack_allocator& alloc, torrent_handle h
|
|
|
|
, char const* log)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, m_str_idx(alloc.copy_string(log))
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* torrent_log_alert::msg() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_str_idx);
|
2014-12-09 10:08:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string torrent_log_alert::message() const
|
|
|
|
{
|
2015-04-03 22:15:48 +02:00
|
|
|
return torrent_alert::message() + ": " + msg();
|
|
|
|
}
|
|
|
|
|
2015-05-03 04:53:54 +02:00
|
|
|
peer_log_alert::peer_log_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
2015-04-03 22:15:48 +02:00
|
|
|
, tcp::endpoint const& i
|
2015-05-03 04:53:54 +02:00
|
|
|
, peer_id const& pi
|
|
|
|
, direction_t dir
|
|
|
|
, char const* event
|
|
|
|
, char const* log)
|
2015-04-03 22:15:48 +02:00
|
|
|
: peer_alert(alloc, h, i, pi)
|
2015-05-03 04:53:54 +02:00
|
|
|
, event_type(event)
|
|
|
|
, direction(dir)
|
2015-04-03 22:15:48 +02:00
|
|
|
, m_str_idx(alloc.copy_string(log))
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* peer_log_alert::msg() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_str_idx);
|
2014-12-09 10:08:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string peer_log_alert::message() const
|
|
|
|
{
|
2015-05-03 04:53:54 +02:00
|
|
|
static char const* mode[] =
|
|
|
|
{ "<==", "==>", "<<<", ">>>", "***" };
|
|
|
|
return torrent_alert::message() + " [" + print_endpoint(ip) + "] "
|
|
|
|
+ mode[direction] + " " + event_type + " [ " + msg() + " ]";
|
2014-12-09 10:08:26 +01:00
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
lsd_error_alert::lsd_error_alert(aux::stack_allocator&, error_code const& ec)
|
|
|
|
: alert()
|
|
|
|
, error(ec)
|
|
|
|
{}
|
|
|
|
|
2015-01-17 00:01:14 +01:00
|
|
|
std::string lsd_error_alert::message() const
|
|
|
|
{
|
|
|
|
return "Local Service Discovery error: " + error.message();
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
session_stats_alert::session_stats_alert(aux::stack_allocator&, counters const& cnt)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < counters::num_counters; ++i)
|
|
|
|
values[i] = cnt[i];
|
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
std::string session_stats_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[100];
|
|
|
|
snprintf(msg, sizeof(msg), "session stats (%d values)", int(sizeof(values)));
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_stats_alert::dht_stats_alert(aux::stack_allocator&
|
|
|
|
, std::vector<dht_routing_bucket> const& table
|
|
|
|
, std::vector<dht_lookup> const& requests)
|
|
|
|
: alert()
|
|
|
|
, active_requests(requests)
|
|
|
|
, routing_table(table)
|
|
|
|
{}
|
|
|
|
|
2015-01-17 18:02:58 +01:00
|
|
|
std::string dht_stats_alert::message() const
|
|
|
|
{
|
|
|
|
char buf[2048];
|
|
|
|
snprintf(buf, sizeof(buf), "DHT stats: reqs: %d buckets: %d"
|
|
|
|
, int(active_requests.size())
|
2015-01-18 22:36:24 +01:00
|
|
|
, int(routing_table.size()));
|
2015-01-17 18:02:58 +01:00
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
url_seed_alert::url_seed_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
|
|
|
, std::string const& u, error_code const& e)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, url(u)
|
|
|
|
, msg(convert_from_native(e.message()))
|
|
|
|
#endif
|
|
|
|
, error(e)
|
|
|
|
, m_url_idx(alloc.copy_string(u))
|
|
|
|
, m_msg_idx(-1)
|
|
|
|
{}
|
|
|
|
|
|
|
|
url_seed_alert::url_seed_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
|
|
|
, std::string const& u, std::string const& m)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, url(u)
|
|
|
|
, msg(m)
|
|
|
|
#endif
|
|
|
|
, m_url_idx(alloc.copy_string(u))
|
|
|
|
, m_msg_idx(alloc.copy_string(m))
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string url_seed_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " url seed ("
|
|
|
|
+ server_url() + ") failed: " + convert_from_native(error.message());
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* url_seed_alert::server_url() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_url_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* url_seed_alert::error_message() const
|
|
|
|
{
|
|
|
|
if (m_msg_idx == -1) return "";
|
|
|
|
return m_alloc.ptr(m_msg_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
file_error_alert::file_error_alert(aux::stack_allocator& alloc
|
|
|
|
, error_code const& ec
|
|
|
|
, std::string const& file
|
|
|
|
, char const* op
|
|
|
|
, torrent_handle const& h)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, file(file)
|
|
|
|
#endif
|
|
|
|
, error(ec)
|
|
|
|
, operation(op)
|
|
|
|
, m_file_idx(alloc.copy_string(file))
|
|
|
|
{
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
msg = convert_from_native(error.message());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* file_error_alert::filename() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_file_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string file_error_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " "
|
|
|
|
+ (operation?operation:"") + " (" + filename()
|
|
|
|
+ ") error: " + convert_from_native(error.message());
|
|
|
|
}
|
2015-05-17 04:00:43 +02:00
|
|
|
|
2015-05-09 05:04:08 +02:00
|
|
|
incoming_request_alert::incoming_request_alert(aux::stack_allocator& alloc
|
|
|
|
, peer_request r, torrent_handle h
|
|
|
|
, tcp::endpoint const& ep, peer_id const& peer_id)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, req(r)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string incoming_request_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[1024];
|
|
|
|
snprintf(msg, sizeof(msg), "%s: incoming request [ piece: %d start: %d length: %d ]"
|
|
|
|
, peer_alert::message().c_str(), req.piece, req.start, req.length);
|
|
|
|
return msg;
|
|
|
|
}
|
2015-04-03 22:15:48 +02:00
|
|
|
|
2015-05-10 06:54:02 +02:00
|
|
|
dht_log_alert::dht_log_alert(aux::stack_allocator& alloc
|
|
|
|
, dht_log_alert::dht_module_t m, const char* msg)
|
|
|
|
: module(m)
|
|
|
|
, m_alloc(alloc)
|
|
|
|
, m_msg_idx(alloc.copy_string(msg))
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* dht_log_alert::log_message() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_msg_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string dht_log_alert::message() const
|
|
|
|
{
|
2015-05-10 20:38:10 +02:00
|
|
|
static char const* const dht_modules[] =
|
2015-05-10 06:54:02 +02:00
|
|
|
{
|
|
|
|
"tracker",
|
|
|
|
"node",
|
|
|
|
"routing_table",
|
|
|
|
"rpc_manager",
|
|
|
|
"traversal"
|
|
|
|
};
|
|
|
|
|
|
|
|
char ret[900];
|
2015-05-17 04:00:43 +02:00
|
|
|
snprintf(ret, sizeof(ret), "DHT %s: %s", dht_modules[module]
|
2015-05-10 06:54:02 +02:00
|
|
|
, log_message());
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-05-28 22:36:22 +02:00
|
|
|
dht_pkt_alert::dht_pkt_alert(aux::stack_allocator& alloc
|
|
|
|
, char const* buf, int size, dht_pkt_alert::direction_t d, udp::endpoint ep)
|
|
|
|
: dir(d)
|
|
|
|
, node(ep)
|
|
|
|
, m_alloc(alloc)
|
|
|
|
, m_msg_idx(alloc.copy_buffer(buf, size))
|
|
|
|
, m_size(size)
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* dht_pkt_alert::pkt_buf() const
|
|
|
|
{
|
|
|
|
return m_alloc.ptr(m_msg_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
int dht_pkt_alert::pkt_size() const
|
|
|
|
{
|
|
|
|
return m_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string dht_pkt_alert::message() const
|
|
|
|
{
|
|
|
|
bdecode_node print;
|
|
|
|
error_code ec;
|
|
|
|
|
|
|
|
// ignore errors here. This is best-effort. It may be a broken encoding
|
|
|
|
// but at least we'll print the valid parts
|
|
|
|
bdecode(pkt_buf(), pkt_buf() + pkt_size(), print, ec, NULL, 100, 100);
|
|
|
|
|
|
|
|
std::string msg = print_entry(print, true);
|
|
|
|
|
|
|
|
char const* prefix[2] = { "<==", "==>"};
|
|
|
|
char buf[1024];
|
|
|
|
snprintf(buf, sizeof(buf), "%s [%s] %s", prefix[dir]
|
|
|
|
, print_endpoint(node).c_str(), msg.c_str());
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2003-11-29 17:34:07 +01:00
|
|
|
} // namespace libtorrent
|
|
|
|
|