2003-11-29 17:34:07 +01:00
|
|
|
/*
|
|
|
|
|
2016-01-18 00:57:46 +01:00
|
|
|
Copyright (c) 2003-2016, 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>
|
2016-05-17 15:24:06 +02:00
|
|
|
#include <cstdio> // for snprintf
|
|
|
|
#include <cinttypes> // for PRId64 et.al.
|
2011-06-05 08:32:00 +02:00
|
|
|
|
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"
|
|
|
|
#include "libtorrent/socket_io.hpp"
|
2009-11-27 08:08:47 +01:00
|
|
|
#include "libtorrent/error_code.hpp"
|
2014-07-06 21:18:00 +02:00
|
|
|
#include "libtorrent/torrent.hpp"
|
2015-04-03 22:15:48 +02:00
|
|
|
#include "libtorrent/performance_counters.hpp"
|
|
|
|
#include "libtorrent/stack_allocator.hpp"
|
2016-09-24 17:46:56 +02:00
|
|
|
#include "libtorrent/piece_block.hpp"
|
2016-06-04 16:01:43 +02:00
|
|
|
#include "libtorrent/hex.hpp" // to_hex
|
2017-03-08 20:06:27 +01:00
|
|
|
#include "libtorrent/session_stats.hpp"
|
2015-03-15 00:10:20 +01:00
|
|
|
|
2017-03-05 15:31:28 +01:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
#include "libtorrent/write_resume_data.hpp"
|
|
|
|
#endif
|
|
|
|
|
2015-03-15 00:10:20 +01:00
|
|
|
#include "libtorrent/aux_/escape_string.hpp" // for convert_from_native
|
2016-05-17 15:24:06 +02:00
|
|
|
#include "libtorrent/aux_/max_path.hpp" // for TORRENT_MAX_PATH
|
2015-03-15 00:10:20 +01:00
|
|
|
|
2017-04-12 19:00:57 +02:00
|
|
|
namespace libtorrent {
|
2004-01-23 01:39:05 +01:00
|
|
|
|
2017-07-26 06:33:10 +02:00
|
|
|
constexpr alert_category_t alert::error_notification;
|
|
|
|
constexpr alert_category_t alert::peer_notification;
|
|
|
|
constexpr alert_category_t alert::port_mapping_notification;
|
|
|
|
constexpr alert_category_t alert::storage_notification;
|
|
|
|
constexpr alert_category_t alert::tracker_notification;
|
|
|
|
constexpr alert_category_t alert::debug_notification;
|
|
|
|
constexpr alert_category_t alert::status_notification;
|
|
|
|
constexpr alert_category_t alert::progress_notification;
|
|
|
|
constexpr alert_category_t alert::ip_block_notification;
|
|
|
|
constexpr alert_category_t alert::performance_warning;
|
|
|
|
constexpr alert_category_t alert::dht_notification;
|
|
|
|
constexpr alert_category_t alert::stats_notification;
|
|
|
|
constexpr alert_category_t alert::session_log_notification;
|
|
|
|
constexpr alert_category_t alert::torrent_log_notification;
|
|
|
|
constexpr alert_category_t alert::peer_log_notification;
|
|
|
|
constexpr alert_category_t alert::incoming_request_notification;
|
|
|
|
constexpr alert_category_t alert::dht_log_notification;
|
|
|
|
constexpr alert_category_t alert::dht_operation_notification;
|
|
|
|
constexpr alert_category_t alert::port_mapping_log_notification;
|
|
|
|
constexpr alert_category_t alert::picker_log_notification;
|
|
|
|
constexpr alert_category_t alert::all_categories;
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-08-05 23:09:36 +02:00
|
|
|
constexpr alert_category_t alert::rss_notification;
|
2017-07-26 06:33:10 +02:00
|
|
|
#endif
|
|
|
|
|
2015-07-12 05:01:27 +02:00
|
|
|
alert::alert() : m_timestamp(clock_type::now()) {}
|
2016-07-10 13:34:45 +02:00
|
|
|
alert::~alert() = default;
|
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
|
|
|
{
|
2016-08-31 14:27:36 +02:00
|
|
|
std::shared_ptr<torrent> t = h.native_handle();
|
2015-08-20 19:57:03 +02:00
|
|
|
if (t)
|
2015-04-03 22:15:48 +02:00
|
|
|
{
|
2015-08-20 19:57:03 +02:00
|
|
|
std::string name_str = t->name();
|
2017-02-15 15:22:44 +01:00
|
|
|
if (!name_str.empty())
|
|
|
|
{
|
2015-08-20 19:57:03 +02:00
|
|
|
m_name_idx = alloc.copy_string(name_str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-22 16:44:36 +01:00
|
|
|
m_name_idx = alloc.copy_string(aux::to_hex(t->info_hash()));
|
2015-08-20 19:57:03 +02:00
|
|
|
}
|
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
|
2017-01-21 08:28:29 +01:00
|
|
|
name = m_alloc.get().ptr(m_name_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* torrent_alert::torrent_name() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().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)
|
2016-10-19 07:32:15 +02:00
|
|
|
, endpoint(i)
|
2015-04-11 16:17:33 +02:00
|
|
|
, pid(pi)
|
2016-10-19 07:32:15 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, ip(i)
|
|
|
|
#endif
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string peer_alert::message() const
|
|
|
|
{
|
2016-10-19 07:32:15 +02:00
|
|
|
return torrent_alert::message() + " peer (" + print_endpoint(endpoint)
|
2017-06-09 21:30:36 +02:00
|
|
|
+ ", " + aux::identify_client_impl(pid) + ")";
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
tracker_alert::tracker_alert(aux::stack_allocator& alloc
|
2017-08-31 05:57:33 +02:00
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep, string_view u)
|
2015-04-03 22:15:48 +02:00
|
|
|
: torrent_alert(alloc, h)
|
2017-08-31 05:57:33 +02:00
|
|
|
, local_endpoint(ep)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_url_idx(alloc.copy_string(u))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, url(u)
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* tracker_alert::tracker_url() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_url_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string tracker_alert::message() const
|
|
|
|
{
|
2017-08-31 05:57:33 +02:00
|
|
|
return torrent_alert::message() + " (" + tracker_url() + ")"
|
|
|
|
+ "[" + print_endpoint(local_endpoint) + "]";
|
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
|
2016-12-22 16:42:33 +01:00
|
|
|
, piece_index_t p, boost::shared_array<char> d, int s)
|
2015-04-11 16:17:33 +02:00
|
|
|
: torrent_alert(alloc, h)
|
2016-07-10 13:34:45 +02:00
|
|
|
, buffer(std::move(d))
|
2015-04-11 16:17:33 +02:00
|
|
|
, piece(p)
|
|
|
|
, size(s)
|
|
|
|
{}
|
|
|
|
|
|
|
|
read_piece_alert::read_piece_alert(aux::stack_allocator& alloc
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_handle h, piece_index_t p, error_code e)
|
2015-04-11 16:17:33 +02:00
|
|
|
: torrent_alert(alloc, h)
|
2016-10-19 07:32:15 +02:00
|
|
|
, error(e)
|
2015-04-11 16:17:33 +02:00
|
|
|
, piece(p)
|
|
|
|
, size(0)
|
2016-10-19 07:32:15 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, ec(e)
|
|
|
|
#endif
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string read_piece_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
2016-10-19 07:32:15 +02:00
|
|
|
if (error)
|
2013-01-29 03:18:32 +01:00
|
|
|
{
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "%s: read_piece %u failed: %s"
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_alert::message().c_str() , static_cast<int>(piece)
|
2016-10-19 07:32:15 +02:00
|
|
|
, convert_from_native(error.message()).c_str());
|
2013-01-29 03:18:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "%s: read_piece %u successful"
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_alert::message().c_str() , static_cast<int>(piece));
|
2013-01-29 03:18:32 +01:00
|
|
|
}
|
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
|
2016-12-22 16:42:33 +01:00
|
|
|
, file_index_t idx)
|
2015-04-11 16:17:33 +02:00
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, index(idx)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string file_completed_alert::message() const
|
|
|
|
{
|
2017-02-17 05:47:08 +01:00
|
|
|
std::string ret { torrent_alert::message() };
|
|
|
|
char msg[200];
|
|
|
|
std::snprintf(msg, sizeof(msg), ": file %d finished downloading"
|
|
|
|
, static_cast<int>(index));
|
|
|
|
ret.append(msg);
|
|
|
|
return ret;
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
file_renamed_alert::file_renamed_alert(aux::stack_allocator& alloc
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_handle const& h, string_view n, file_index_t const idx)
|
2015-04-03 22:15:48 +02:00
|
|
|
: torrent_alert(alloc, h)
|
2017-06-16 03:39:43 +02:00
|
|
|
, index(idx)
|
|
|
|
, m_name_idx(alloc.copy_string(n))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, name(n)
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* file_renamed_alert::new_name() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_name_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string file_renamed_alert::message() const
|
|
|
|
{
|
2017-02-17 05:47:08 +01:00
|
|
|
std::string ret { torrent_alert::message() };
|
|
|
|
char msg[200];
|
|
|
|
std::snprintf(msg, sizeof(msg), ": file %d renamed to "
|
|
|
|
, static_cast<int>(index));
|
|
|
|
ret.append(msg);
|
|
|
|
ret.append(new_name());
|
|
|
|
return ret;
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
file_rename_failed_alert::file_rename_failed_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
2016-12-22 16:42:33 +01:00
|
|
|
, file_index_t const idx
|
2015-04-11 16:17:33 +02:00
|
|
|
, 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
|
|
|
|
{
|
2017-02-17 05:47:08 +01:00
|
|
|
std::string ret { torrent_alert::message() };
|
|
|
|
char msg[200];
|
|
|
|
std::snprintf(msg, sizeof(msg), ": failed to rename file %d: "
|
|
|
|
, static_cast<int>(index));
|
|
|
|
ret.append(msg);
|
|
|
|
ret.append(convert_from_native(error.message()));
|
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
|
|
|
|
{
|
2017-12-01 00:57:48 +01:00
|
|
|
static char const* const warning_str[] =
|
2009-11-26 22:40:10 +01:00
|
|
|
{
|
|
|
|
"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
|
|
|
|
{
|
2017-12-01 00:57:48 +01:00
|
|
|
static char const* const state_str[] =
|
2009-11-26 22:40:10 +01:00
|
|
|
{"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
|
2017-08-31 05:57:33 +02:00
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep, int times
|
2017-12-18 22:21:08 +01:00
|
|
|
, string_view u, error_code const& e, string_view m)
|
2017-08-31 05:57:33 +02:00
|
|
|
: tracker_alert(alloc, h, ep, u)
|
2015-04-03 22:15:48 +02:00
|
|
|
, times_in_row(times)
|
|
|
|
, error(e)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_msg_idx(alloc.copy_string(m))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-12-18 22:21:08 +01:00
|
|
|
, status_code(e && e.category() == http_category() ? e.value() : -1)
|
2015-04-03 22:15:48 +02:00
|
|
|
, msg(m)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(!u.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* tracker_error_alert::error_message() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_msg_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string tracker_error_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
2017-12-18 22:21:08 +01:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s %s \"%s\" (%d)"
|
|
|
|
, tracker_alert::message().c_str()
|
2015-09-09 01:23:28 +02:00
|
|
|
, convert_from_native(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
|
2017-08-31 05:57:33 +02:00
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep
|
|
|
|
, string_view u, string_view m)
|
|
|
|
: tracker_alert(alloc, h, ep, u)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_msg_idx(alloc.copy_string(m))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, msg(m)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(!u.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* tracker_warning_alert::warning_message() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_msg_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
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
|
2017-08-31 05:57:33 +02:00
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep
|
|
|
|
, int incomp, int comp, string_view u)
|
|
|
|
: tracker_alert(alloc, h, ep, u)
|
2015-04-11 16:17:33 +02:00
|
|
|
, 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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::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
|
2017-08-31 05:57:33 +02:00
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep
|
|
|
|
, string_view u, error_code const& e)
|
|
|
|
: tracker_alert(alloc, h, ep, u)
|
2017-06-16 03:39:43 +02:00
|
|
|
, error(e)
|
|
|
|
, m_msg_idx()
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, msg(convert_from_native(e.message()))
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(!u.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
scrape_failed_alert::scrape_failed_alert(aux::stack_allocator& alloc
|
2017-08-31 05:57:33 +02:00
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep
|
|
|
|
, string_view u, string_view m)
|
|
|
|
: tracker_alert(alloc, h, ep, u)
|
2017-06-16 03:39:43 +02:00
|
|
|
, error(errors::tracker_failure)
|
|
|
|
, m_msg_idx(alloc.copy_string(m))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, msg(m)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(!u.empty());
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* scrape_failed_alert::error_message() const
|
|
|
|
{
|
2016-11-26 09:09:01 +01:00
|
|
|
if (m_msg_idx == aux::allocation_slot()) return "";
|
2016-05-13 14:19:44 +02:00
|
|
|
else return m_alloc.get().ptr(m_msg_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
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
|
2017-08-31 05:57:33 +02:00
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep
|
|
|
|
, int np, string_view u)
|
|
|
|
: tracker_alert(alloc, h, ep, u)
|
2015-04-11 16:17:33 +02:00
|
|
|
, 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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::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)
|
2017-08-31 05:57:33 +02:00
|
|
|
: tracker_alert(alloc, h, {}, "")
|
2015-04-11 16:17:33 +02:00
|
|
|
, num_peers(np)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string dht_reply_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::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
|
2017-08-31 05:57:33 +02:00
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep, string_view u, int e)
|
|
|
|
: tracker_alert(alloc, h, ep, u)
|
2015-04-11 16:17:33 +02:00
|
|
|
, 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
|
|
|
|
{
|
2017-12-01 00:57:48 +01:00
|
|
|
static const char* const event_str[] = {"none", "completed", "started", "stopped", "paused"};
|
|
|
|
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
|
2016-12-22 16:42:33 +01:00
|
|
|
, piece_index_t index)
|
2015-04-11 16:17:33 +02:00
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, piece_index(index)
|
|
|
|
{
|
2016-12-22 16:42:33 +01:00
|
|
|
TORRENT_ASSERT(index >= piece_index_t(0));
|
2015-04-11 16:17:33 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string hash_failed_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s hash for piece %u failed"
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_alert::message().c_str(), static_cast<int>(piece_index));
|
2009-11-26 22:40:10 +01:00
|
|
|
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
|
2015-08-02 05:57:11 +02:00
|
|
|
, bool _have, bool _peer_interested, bool _withheld)
|
2015-04-03 22:15:48 +02:00
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, request(r)
|
2015-08-02 05:57:11 +02:00
|
|
|
, we_have(_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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s peer sent an invalid piece request "
|
2015-04-13 03:34:19 +02:00
|
|
|
"(piece: %u start: %u len: %u)%s"
|
2016-12-22 16:42:33 +01:00
|
|
|
, peer_alert::message().c_str()
|
|
|
|
, static_cast<int>(request.piece)
|
|
|
|
, request.start
|
2015-04-13 03:34:19 +02:00
|
|
|
, 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
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_handle const& h, piece_index_t piece_num)
|
2015-04-11 16:17:33 +02:00
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, piece_index(piece_num)
|
2016-12-22 16:42:33 +01:00
|
|
|
{}
|
2015-04-11 16:17:33 +02:00
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string piece_finished_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s piece: %u finished downloading"
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_alert::message().c_str(), static_cast<int>(piece_index));
|
2009-11-26 22:40:10 +01:00
|
|
|
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
|
2016-12-22 16:42:33 +01:00
|
|
|
, piece_index_t piece_num)
|
2015-04-03 22:15:48 +02:00
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
2016-12-22 16:42:33 +01:00
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= piece_index_t(0));
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
2009-11-26 22:40:10 +01:00
|
|
|
|
|
|
|
std::string request_dropped_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s peer dropped block ( piece: %u block: %u)"
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_alert::message().c_str(), static_cast<int>(piece_index), block_index);
|
2009-11-26 22:40:10 +01:00
|
|
|
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
|
2016-12-22 16:42:33 +01:00
|
|
|
, piece_index_t piece_num)
|
2015-04-03 22:15:48 +02:00
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
2016-12-22 16:42:33 +01:00
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= piece_index_t(0));
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string block_timeout_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s peer timed out request ( piece: %u block: %u)"
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_alert::message().c_str(), static_cast<int>(piece_index), block_index);
|
2009-11-26 22:40:10 +01:00
|
|
|
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
|
2016-12-22 16:42:33 +01:00
|
|
|
, piece_index_t piece_num)
|
2015-04-03 22:15:48 +02:00
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
2016-12-22 16:42:33 +01:00
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= piece_index_t(0));
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string block_finished_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s block finished downloading (piece: %u block: %u)"
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_alert::message().c_str(), static_cast<int>(piece_index), block_index);
|
2009-11-26 22:40:10 +01:00
|
|
|
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
|
2016-12-22 16:42:33 +01:00
|
|
|
, peer_id const& peer_id, int block_num, piece_index_t piece_num)
|
2015-04-03 22:15:48 +02:00
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
2017-06-16 03:39:43 +02:00
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, peer_speedmsg("")
|
|
|
|
#endif
|
|
|
|
{
|
2016-12-22 16:42:33 +01:00
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= piece_index_t(0));
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string block_downloading_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s requested block (piece: %u block: %u)"
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_alert::message().c_str(), static_cast<int>(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
|
2016-12-22 16:42:33 +01:00
|
|
|
, peer_id const& peer_id, int block_num, piece_index_t piece_num)
|
2015-04-03 22:15:48 +02:00
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
2016-12-22 16:42:33 +01:00
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= piece_index_t(0));
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string unwanted_block_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s received block not in download queue (piece: %u block: %u)"
|
2016-12-22 16:42:33 +01:00
|
|
|
, torrent_alert::message().c_str(), static_cast<int>(piece_index), block_index);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
storage_moved_alert::storage_moved_alert(aux::stack_allocator& alloc
|
2016-10-05 05:58:26 +02:00
|
|
|
, torrent_handle const& h, string_view p)
|
2015-04-03 22:15:48 +02:00
|
|
|
: torrent_alert(alloc, h)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_path_idx(alloc.copy_string(p))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, path(p)
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string storage_moved_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " moved storage to: "
|
|
|
|
+ storage_path();
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* storage_moved_alert::storage_path() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_path_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
storage_moved_failed_alert::storage_moved_failed_alert(
|
2016-10-05 05:58:26 +02:00
|
|
|
aux::stack_allocator& alloc, torrent_handle const& h, error_code const& e
|
2017-06-18 00:18:19 +02:00
|
|
|
, string_view f, operation_t const op_)
|
2015-04-03 22:15:48 +02:00
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, error(e)
|
2017-06-18 00:18:19 +02:00
|
|
|
, op(op_)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_file_idx(alloc.copy_string(f))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-06-18 00:18:19 +02:00
|
|
|
, operation(operation_name(op_))
|
2015-08-02 05:57:11 +02:00
|
|
|
, file(f)
|
2015-04-03 22:15:48 +02:00
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* storage_moved_failed_alert::file_path() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_file_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string storage_moved_failed_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " storage move failed. "
|
2017-06-18 00:18:19 +02:00
|
|
|
+ operation_name(op) + " (" + file_path() + "): "
|
2015-04-03 22:15:48 +02:00
|
|
|
+ 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
|
2017-06-16 03:39:43 +02:00
|
|
|
, msg(convert_from_native(error.message()))
|
2015-04-03 22:15:48 +02:00
|
|
|
#endif
|
2017-06-16 03:39:43 +02:00
|
|
|
{
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string torrent_delete_failed_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " torrent deletion failed: "
|
2016-11-17 20:34:49 +01:00
|
|
|
+ convert_from_native(error.message());
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
save_resume_data_alert::save_resume_data_alert(aux::stack_allocator& alloc
|
2017-03-05 15:31:28 +01:00
|
|
|
, add_torrent_params p
|
2015-04-03 22:15:48 +02:00
|
|
|
, torrent_handle const& h)
|
|
|
|
: torrent_alert(alloc, h)
|
2017-03-05 15:31:28 +01:00
|
|
|
, params(std::move(p))
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-06-16 03:39:43 +02:00
|
|
|
, resume_data(std::make_shared<entry>(write_resume_data(params)))
|
2017-03-05 15:31:28 +01:00
|
|
|
#endif
|
2017-06-16 03:39:43 +02:00
|
|
|
{
|
2017-03-05 15:31:28 +01:00
|
|
|
}
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
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
|
2017-06-16 03:39:43 +02:00
|
|
|
, msg(convert_from_native(error.message()))
|
2015-04-03 22:15:48 +02:00
|
|
|
#endif
|
2017-06-16 03:39:43 +02:00
|
|
|
{
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
|
2017-04-12 19:00:57 +02:00
|
|
|
namespace {
|
|
|
|
|
2017-06-18 00:18:19 +02:00
|
|
|
int sock_type_idx(socket_type_t type)
|
|
|
|
{
|
|
|
|
int idx =
|
|
|
|
static_cast<std::underlying_type<socket_type_t>::type>(type);
|
|
|
|
TORRENT_ASSERT(0 <= idx && idx < 6);
|
|
|
|
return idx;
|
|
|
|
}
|
2016-10-19 07:32:15 +02:00
|
|
|
|
2017-06-18 00:18:19 +02:00
|
|
|
char const* sock_type_str(socket_type_t type)
|
|
|
|
{
|
2017-12-01 00:57:48 +01:00
|
|
|
static char const* const type_str[] =
|
2017-06-18 00:18:19 +02:00
|
|
|
{ "TCP", "TCP/SSL", "UDP", "I2P", "Socks5", "uTP/SSL" };
|
2016-10-19 07:32:15 +02:00
|
|
|
|
2017-06-18 00:18:19 +02:00
|
|
|
return type_str[sock_type_idx(type)];
|
|
|
|
}
|
|
|
|
|
2017-09-12 23:10:11 +02:00
|
|
|
char const* const nat_type_str[] = {"NAT-PMP", "UPnP"};
|
2017-06-18 00:18:19 +02:00
|
|
|
|
2017-09-12 23:10:11 +02:00
|
|
|
char const* const protocol_str[] = {"none", "TCP", "UDP"};
|
2017-06-18 00:18:19 +02:00
|
|
|
|
2017-09-12 23:10:11 +02:00
|
|
|
char const* const socket_type_str[] = {
|
2017-06-18 00:18:19 +02:00
|
|
|
"null",
|
|
|
|
"TCP",
|
|
|
|
"Socks5/TCP",
|
|
|
|
"HTTP",
|
|
|
|
"uTP",
|
|
|
|
"i2p",
|
|
|
|
"SSL/TCP",
|
|
|
|
"SSL/Socks5",
|
|
|
|
"HTTPS",
|
|
|
|
"SSL/uTP"
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
|
|
|
|
int to_op_t(operation_t op)
|
|
|
|
{
|
|
|
|
using o = operation_t;
|
|
|
|
using lfo = listen_failed_alert::op_t;
|
2015-02-15 06:17:09 +01:00
|
|
|
|
2017-06-18 00:18:19 +02:00
|
|
|
// we have to use deprecated enum values here. suppress the warnings
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(push, 1)
|
|
|
|
// warning C4996: X: was declared deprecated
|
|
|
|
#pragma warning( disable : 4996 )
|
|
|
|
#endif
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
|
|
|
#endif
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
case o::bittorrent: return -1;
|
|
|
|
case o::iocontrol: return -1;
|
|
|
|
case o::getpeername: return -1;
|
|
|
|
case o::getname: return lfo::get_socket_name;
|
|
|
|
case o::alloc_recvbuf: return -1;
|
|
|
|
case o::alloc_sndbuf: return -1;
|
|
|
|
case o::file_write: return -1;
|
|
|
|
case o::file_read: return -1;
|
|
|
|
case o::file: return -1;
|
|
|
|
case o::sock_write: return -1;
|
|
|
|
case o::sock_read: return -1;
|
|
|
|
case o::sock_open: return lfo::open;
|
|
|
|
case o::sock_bind: return lfo::bind;
|
|
|
|
case o::available: return -1;
|
|
|
|
case o::encryption: return -1;
|
|
|
|
case o::connect: return -1;
|
|
|
|
case o::ssl_handshake: return -1;
|
|
|
|
case o::get_interface: return -1;
|
|
|
|
case o::unknown: return -1;
|
|
|
|
case o::sock_listen: return lfo::listen;
|
|
|
|
case o::sock_bind_to_device: return lfo::bind_to_device;
|
|
|
|
case o::sock_accept: return lfo::accept;
|
|
|
|
case o::parse_address: return lfo::parse_addr;
|
|
|
|
case o::enum_if: return lfo::enum_if;
|
|
|
|
case o::file_stat: return -1;
|
|
|
|
case o::file_copy: return -1;
|
|
|
|
case o::file_fallocate: return -1;
|
|
|
|
case o::file_hard_link: return -1;
|
|
|
|
case o::file_remove: return -1;
|
|
|
|
case o::file_rename: return -1;
|
|
|
|
case o::file_open: return -1;
|
|
|
|
case o::mkdir: return -1;
|
|
|
|
case o::check_resume: return -1;
|
|
|
|
case o::exception: return -1;
|
|
|
|
case o::alloc_cache_piece: return -1;
|
|
|
|
case o::partfile_move: return -1;
|
|
|
|
case o::partfile_read: return -1;
|
|
|
|
case o::partfile_write: return -1;
|
2017-06-18 20:35:05 +02:00
|
|
|
case o::hostname_lookup: return -1;
|
2015-02-15 06:17:09 +01:00
|
|
|
};
|
2017-06-18 00:18:19 +02:00
|
|
|
return -1;
|
2015-02-15 06:17:09 +01:00
|
|
|
}
|
2017-06-18 00:18:19 +02:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // TORRENT_NO_DEPRECATE
|
|
|
|
} // anonymous namespace
|
2015-02-15 06:17:09 +01:00
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
listen_failed_alert::listen_failed_alert(
|
|
|
|
aux::stack_allocator& alloc
|
2016-10-05 05:58:26 +02:00
|
|
|
, string_view iface
|
2016-06-03 04:38:56 +02:00
|
|
|
, libtorrent::address const& listen_addr
|
|
|
|
, int listen_port
|
2017-06-18 00:18:19 +02:00
|
|
|
, operation_t const op_
|
2015-04-03 22:15:48 +02:00
|
|
|
, error_code const& ec
|
2016-10-19 07:32:15 +02:00
|
|
|
, libtorrent::socket_type_t t)
|
2016-01-31 05:23:12 +01:00
|
|
|
: error(ec)
|
2017-06-18 00:18:19 +02:00
|
|
|
, op(op_)
|
2016-10-19 07:32:15 +02:00
|
|
|
, socket_type(t)
|
2016-06-03 04:38:56 +02:00
|
|
|
, address(listen_addr)
|
|
|
|
, port(listen_port)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_alloc(alloc)
|
|
|
|
, m_interface_idx(alloc.copy_string(iface))
|
2016-06-03 04:38:56 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-06-18 00:18:19 +02:00
|
|
|
, operation(to_op_t(op_))
|
2016-11-25 17:17:25 +01:00
|
|
|
, endpoint(listen_addr, std::uint16_t(listen_port))
|
2016-10-19 07:32:15 +02:00
|
|
|
, sock_type(static_cast<socket_type_t>(sock_type_idx(t)))
|
2016-06-03 04:38:56 +02:00
|
|
|
#endif
|
2015-04-03 22:15:48 +02:00
|
|
|
{}
|
|
|
|
|
2016-06-03 04:38:56 +02:00
|
|
|
listen_failed_alert::listen_failed_alert(
|
|
|
|
aux::stack_allocator& alloc
|
2016-10-05 05:58:26 +02:00
|
|
|
, string_view iface
|
2016-06-03 04:38:56 +02:00
|
|
|
, tcp::endpoint const& ep
|
2017-06-18 00:18:19 +02:00
|
|
|
, operation_t const op_
|
2016-06-03 04:38:56 +02:00
|
|
|
, error_code const& ec
|
2016-10-19 07:32:15 +02:00
|
|
|
, libtorrent::socket_type_t t)
|
2016-06-03 04:38:56 +02:00
|
|
|
: listen_failed_alert(alloc
|
|
|
|
, iface
|
|
|
|
, ep.address()
|
|
|
|
, ep.port()
|
2017-06-18 00:18:19 +02:00
|
|
|
, op_
|
2016-06-03 04:38:56 +02:00
|
|
|
, ec
|
|
|
|
, t)
|
|
|
|
{}
|
|
|
|
|
|
|
|
listen_failed_alert::listen_failed_alert(
|
|
|
|
aux::stack_allocator& alloc
|
2016-10-05 05:58:26 +02:00
|
|
|
, string_view iface
|
2016-06-03 04:38:56 +02:00
|
|
|
, udp::endpoint const& ep
|
2017-06-18 00:18:19 +02:00
|
|
|
, operation_t const op_
|
2016-06-03 04:38:56 +02:00
|
|
|
, error_code const& ec
|
2016-10-19 07:32:15 +02:00
|
|
|
, libtorrent::socket_type_t t)
|
2016-06-03 04:38:56 +02:00
|
|
|
: listen_failed_alert(alloc
|
|
|
|
, iface
|
|
|
|
, ep.address()
|
|
|
|
, ep.port()
|
2017-06-18 00:18:19 +02:00
|
|
|
, op_
|
2016-06-03 04:38:56 +02:00
|
|
|
, ec
|
|
|
|
, t)
|
|
|
|
{}
|
|
|
|
|
|
|
|
listen_failed_alert::listen_failed_alert(
|
|
|
|
aux::stack_allocator& alloc
|
2016-10-05 05:58:26 +02:00
|
|
|
, string_view iface
|
2017-06-18 00:18:19 +02:00
|
|
|
, operation_t const op_
|
2016-06-03 04:38:56 +02:00
|
|
|
, error_code const& ec
|
2016-10-19 07:32:15 +02:00
|
|
|
, libtorrent::socket_type_t t)
|
2016-06-03 04:38:56 +02:00
|
|
|
: listen_failed_alert(alloc
|
|
|
|
, iface
|
|
|
|
, libtorrent::address()
|
|
|
|
, 0
|
2017-06-18 00:18:19 +02:00
|
|
|
, op_
|
2016-06-03 04:38:56 +02:00
|
|
|
, ec
|
|
|
|
, t)
|
|
|
|
{}
|
|
|
|
|
2015-04-03 22:15:48 +02:00
|
|
|
char const* listen_failed_alert::listen_interface() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_interface_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string listen_failed_alert::message() const
|
|
|
|
{
|
2014-07-06 21:18:00 +02:00
|
|
|
char ret[300];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "listening on %s (device: %s) failed: [%s] [%s] %s"
|
2016-06-03 04:38:56 +02:00
|
|
|
, print_endpoint(address, port).c_str()
|
2015-04-03 22:15:48 +02:00
|
|
|
, listen_interface()
|
2017-06-18 00:18:19 +02:00
|
|
|
, operation_name(op)
|
2016-10-19 07:32:15 +02:00
|
|
|
, sock_type_str(socket_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&
|
2016-06-03 04:38:56 +02:00
|
|
|
, libtorrent::address const& listen_addr
|
|
|
|
, int listen_port
|
2016-10-19 07:32:15 +02:00
|
|
|
, libtorrent::socket_type_t t)
|
2016-06-03 04:38:56 +02:00
|
|
|
: address(listen_addr)
|
|
|
|
, port(listen_port)
|
2016-10-19 07:32:15 +02:00
|
|
|
, socket_type(t)
|
2016-06-03 04:38:56 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2016-11-25 17:17:25 +01:00
|
|
|
, endpoint(listen_addr, std::uint16_t(listen_port))
|
2016-10-19 07:32:15 +02:00
|
|
|
, sock_type(static_cast<socket_type_t>(sock_type_idx(t)))
|
2016-06-03 04:38:56 +02:00
|
|
|
#endif
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
|
|
|
|
2016-06-03 04:38:56 +02:00
|
|
|
listen_succeeded_alert::listen_succeeded_alert(aux::stack_allocator& alloc
|
|
|
|
, tcp::endpoint const& ep
|
2016-10-19 07:32:15 +02:00
|
|
|
, libtorrent::socket_type_t t)
|
2016-06-03 04:38:56 +02:00
|
|
|
: listen_succeeded_alert(alloc
|
|
|
|
, ep.address()
|
|
|
|
, ep.port()
|
|
|
|
, t)
|
|
|
|
{}
|
|
|
|
|
|
|
|
listen_succeeded_alert::listen_succeeded_alert(aux::stack_allocator& alloc
|
|
|
|
, udp::endpoint const& ep
|
2016-10-19 07:32:15 +02:00
|
|
|
, libtorrent::socket_type_t t)
|
2016-06-03 04:38:56 +02:00
|
|
|
: listen_succeeded_alert(alloc
|
|
|
|
, ep.address()
|
|
|
|
, ep.port()
|
|
|
|
, t)
|
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string listen_succeeded_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "successfully listening on [%s] %s"
|
2016-10-19 07:32:15 +02:00
|
|
|
, sock_type_str(socket_type), print_endpoint(address, port).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&
|
2017-08-31 00:49:49 +02:00
|
|
|
, port_mapping_t const i, portmap_transport const t, error_code const& e)
|
2017-08-30 20:47:49 +02:00
|
|
|
: mapping(i)
|
|
|
|
, map_transport(t)
|
|
|
|
, error(e)
|
2015-04-11 16:17:33 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-08-30 20:47:49 +02:00
|
|
|
, map_type(static_cast<int>(t))
|
2017-06-16 03:39:43 +02:00
|
|
|
, msg(convert_from_native(error.message()))
|
2015-04-11 16:17:33 +02:00
|
|
|
#endif
|
2017-06-16 03:39:43 +02:00
|
|
|
{}
|
2015-04-11 16:17:33 +02:00
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string portmap_error_alert::message() const
|
|
|
|
{
|
2017-08-30 20:47:49 +02:00
|
|
|
return std::string("could not map port using ")
|
|
|
|
+ nat_type_str[static_cast<int>(map_transport)]
|
2013-01-19 07:39:32 +01:00
|
|
|
+ ": " + convert_from_native(error.message());
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
2017-08-31 00:49:49 +02:00
|
|
|
portmap_alert::portmap_alert(aux::stack_allocator&, port_mapping_t const i
|
|
|
|
, int port
|
2017-08-30 20:47:49 +02:00
|
|
|
, portmap_transport const t
|
|
|
|
, portmap_protocol const proto)
|
|
|
|
: mapping(i)
|
|
|
|
, external_port(port)
|
|
|
|
, map_protocol(proto)
|
|
|
|
, map_transport(t)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, protocol(static_cast<int>(proto))
|
|
|
|
, map_type(static_cast<int>(t))
|
|
|
|
#endif
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
std::string portmap_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "successfully mapped port using %s. external port: %s/%u"
|
2017-08-30 20:47:49 +02:00
|
|
|
, nat_type_str[static_cast<int>(map_transport)]
|
|
|
|
, protocol_str[static_cast<int>(map_protocol)], external_port);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-08-30 20:47:49 +02:00
|
|
|
portmap_log_alert::portmap_log_alert(aux::stack_allocator& alloc
|
|
|
|
, portmap_transport const t, const char* m)
|
|
|
|
: map_transport(t)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_alloc(alloc)
|
|
|
|
, m_log_idx(alloc.copy_string(m))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-08-30 20:47:49 +02:00
|
|
|
, map_type(static_cast<int>(t))
|
2015-04-03 22:15:48 +02:00
|
|
|
, msg(m)
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* portmap_log_alert::log_message() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_log_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
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];
|
2017-08-30 20:47:49 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s: %s"
|
|
|
|
, nat_type_str[static_cast<int>(map_transport)]
|
2015-04-03 22:15:48 +02:00
|
|
|
, 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
|
2016-10-05 05:58:26 +02:00
|
|
|
, string_view f
|
2017-06-18 20:35:05 +02:00
|
|
|
, operation_t const op_)
|
2015-04-03 22:15:48 +02:00
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, error(ec)
|
2017-06-18 20:35:05 +02:00
|
|
|
, op(op_)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_path_idx(alloc.copy_string(f))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-06-18 20:35:05 +02:00
|
|
|
, operation(operation_name(op_))
|
2015-08-02 05:57:11 +02:00
|
|
|
, file(f)
|
2017-06-15 00:46:11 +02:00
|
|
|
, msg(convert_from_native(error.message()))
|
2015-04-03 22:15:48 +02:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string fastresume_rejected_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " fast resume rejected. "
|
2017-06-18 20:35:05 +02:00
|
|
|
+ operation_name(op) + "(" + file_path() + "): "
|
2015-04-03 22:15:48 +02:00
|
|
|
+ convert_from_native(error.message());
|
|
|
|
}
|
|
|
|
|
|
|
|
char const* fastresume_rejected_alert::file_path() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_path_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
peer_blocked_alert::peer_blocked_alert(aux::stack_allocator& alloc
|
2016-05-23 01:56:14 +02:00
|
|
|
, torrent_handle const& h, tcp::endpoint const& ep, int r)
|
2016-07-09 22:26:26 +02:00
|
|
|
: peer_alert(alloc, h, ep, peer_id(nullptr))
|
2015-04-11 16:17:33 +02:00
|
|
|
, reason(r)
|
|
|
|
{}
|
|
|
|
|
2014-02-07 18:35:56 +01:00
|
|
|
std::string peer_blocked_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[600];
|
2017-12-01 00:57:48 +01:00
|
|
|
static char const* const reason_str[] =
|
2014-02-07 18:35:56 +01:00
|
|
|
{
|
|
|
|
"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
|
|
|
};
|
|
|
|
|
2016-05-23 01:56:14 +02:00
|
|
|
std::snprintf(ret, sizeof(ret), "%s: blocked peer [%s]"
|
|
|
|
, peer_alert::message().c_str(), reason_str[reason]);
|
2014-02-07 18:35:56 +01:00
|
|
|
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 msg[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "incoming dht announce: %s:%u (%s)"
|
2016-12-22 16:44:36 +01:00
|
|
|
, ip.to_string(ec).c_str(), port, aux::to_hex(info_hash).c_str());
|
2009-11-26 22:40:10 +01:00
|
|
|
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 msg[200];
|
2016-12-22 16:44:36 +01:00
|
|
|
std::snprintf(msg, sizeof(msg), "incoming dht get_peers: %s", aux::to_hex(info_hash).c_str());
|
2009-11-26 22:40:10 +01:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2017-04-12 19:00:57 +02:00
|
|
|
namespace {
|
|
|
|
|
2016-10-19 07:32:15 +02:00
|
|
|
std::array<int, stats_alert::num_channels> stat_to_array(stat const& s)
|
|
|
|
{
|
|
|
|
std::array<int, stats_alert::num_channels> arr;
|
|
|
|
|
|
|
|
arr[stats_alert::upload_payload] = s[stat::upload_payload].counter();
|
|
|
|
arr[stats_alert::upload_protocol] = s[stat::upload_protocol].counter();
|
|
|
|
arr[stats_alert::download_payload] = s[stat::download_payload].counter();
|
|
|
|
arr[stats_alert::download_protocol] = s[stat::download_protocol].counter();
|
|
|
|
arr[stats_alert::upload_ip_protocol] = s[stat::upload_ip_protocol].counter();
|
|
|
|
arr[stats_alert::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
|
2016-10-19 07:32:15 +02:00
|
|
|
arr[stats_alert::upload_dht_protocol] = 0;
|
|
|
|
arr[stats_alert::upload_tracker_protocol] = 0;
|
|
|
|
arr[stats_alert::download_dht_protocol] = 0;
|
|
|
|
arr[stats_alert::download_tracker_protocol] = 0;
|
2014-11-26 11:17:44 +01:00
|
|
|
#else
|
2016-10-19 07:32:15 +02:00
|
|
|
arr[stats_alert::deprecated1] = 0;
|
|
|
|
arr[stats_alert::deprecated2] = 0;
|
|
|
|
arr[stats_alert::deprecated3] = 0;
|
|
|
|
arr[stats_alert::deprecated4] = 0;
|
2014-10-26 01:10:07 +02:00
|
|
|
#endif
|
2016-10-19 07:32:15 +02:00
|
|
|
return arr;
|
|
|
|
}
|
2010-01-02 15:16:35 +01:00
|
|
|
}
|
|
|
|
|
2016-10-19 07:32:15 +02:00
|
|
|
stats_alert::stats_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h, int in, stat const& s)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, transferred(stat_to_array(s))
|
|
|
|
, interval(in)
|
|
|
|
{}
|
|
|
|
|
2010-01-02 15:16:35 +01:00
|
|
|
std::string stats_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "%s: [%d] %d %d %d %d %d %d"
|
2014-10-26 01:10:07 +02:00
|
|
|
#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
|
2016-10-05 05:58:26 +02:00
|
|
|
, torrent_handle const& h, int k, string_view s)
|
2015-04-11 16:17:33 +02:00
|
|
|
: 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];
|
2017-12-01 00:57:48 +01:00
|
|
|
static char const* const msgs[] = {
|
2010-04-13 06:30:34 +02:00
|
|
|
"tracker is not anonymous, set a proxy"
|
|
|
|
};
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "%s: %s: %s"
|
2010-04-13 06:30:34 +02:00
|
|
|
, 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)
|
2016-07-09 22:26:26 +02:00
|
|
|
: peer_alert(alloc, h, i, peer_id(nullptr))
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
|
|
|
|
2010-07-15 07:56:29 +02:00
|
|
|
std::string lsd_peer_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "%s: received peer from local service discovery"
|
2010-07-15 07:56:29 +02:00
|
|
|
, 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
|
2017-08-31 05:57:33 +02:00
|
|
|
, tcp::endpoint const& ep
|
2016-10-05 05:58:26 +02:00
|
|
|
, string_view u
|
2015-04-03 22:15:48 +02:00
|
|
|
, const std::string& id)
|
2017-08-31 05:57:33 +02:00
|
|
|
: tracker_alert(alloc, h, ep, u)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_tracker_idx(alloc.copy_string(id))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, trackerid(id)
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
|
|
|
char const* trackerid_alert::tracker_id() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_tracker_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
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-04-03 22:15:48 +02:00
|
|
|
torrent_error_alert::torrent_error_alert(
|
|
|
|
aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
2016-10-05 05:58:26 +02:00
|
|
|
, error_code const& e, string_view f)
|
2015-04-03 22:15:48 +02:00
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, error(e)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_file_idx(alloc.copy_string(f))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, error_file(f)
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
2011-01-22 20:06:43 +01:00
|
|
|
std::string torrent_error_alert::message() const
|
|
|
|
{
|
2016-10-06 06:08:14 +02:00
|
|
|
char msg[400];
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
std::snprintf(msg, sizeof(msg), " ERROR: (%d %s) %s"
|
|
|
|
, error.value(), convert_from_native(error.message()).c_str()
|
|
|
|
, filename());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::snprintf(msg, sizeof(msg), " ERROR: %s", filename());
|
|
|
|
}
|
2011-01-22 20:06:43 +01:00
|
|
|
return torrent_alert::message() + msg;
|
|
|
|
}
|
2015-05-17 04:00:43 +02:00
|
|
|
|
2016-04-20 06:46:42 +02:00
|
|
|
char const* torrent_error_alert::filename() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_file_idx);
|
2016-04-20 06:46:42 +02:00
|
|
|
}
|
|
|
|
|
2017-03-27 01:19:20 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
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";
|
|
|
|
}
|
2017-03-27 01:19:20 +02:00
|
|
|
#endif
|
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)
|
2016-10-19 07:32:15 +02:00
|
|
|
, endpoint(i)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2015-04-11 16:17:33 +02:00
|
|
|
, ip(i)
|
2016-10-19 07:32:15 +02:00
|
|
|
#endif
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "incoming connection from %s (%s)"
|
2016-10-19 07:32:15 +02:00
|
|
|
, print_endpoint(endpoint).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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::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;
|
|
|
|
}
|
|
|
|
|
2016-09-21 08:14:42 +02:00
|
|
|
add_torrent_alert::add_torrent_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
|
|
|
, add_torrent_params const& p, error_code const& ec)
|
2015-04-11 16:17:33 +02:00
|
|
|
: 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();
|
2017-03-29 08:16:07 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2014-08-20 09:02:03 +02:00
|
|
|
else if (!params.url.empty()) torrent_name = params.url.c_str();
|
2017-03-29 08:16:07 +02:00
|
|
|
#endif
|
2016-07-29 08:36:15 +02:00
|
|
|
else aux::to_hex(params.info_hash, info_hash);
|
2014-08-20 09:02:03 +02:00
|
|
|
|
2011-10-12 12:27:17 +02:00
|
|
|
if (error)
|
|
|
|
{
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "failed to add torrent \"%s\": [%s] %s"
|
2014-08-20 09:02:03 +02:00
|
|
|
, 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
|
|
|
|
{
|
2016-05-17 15:24:06 +02:00
|
|
|
std::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)
|
2016-05-04 15:50:44 +02:00
|
|
|
: status(std::move(st))
|
2015-04-19 00:00:27 +02:00
|
|
|
{}
|
|
|
|
|
2011-11-15 03:34:00 +01:00
|
|
|
std::string state_update_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "state updates for %d torrents", int(status.size()));
|
2011-11-15 03:34:00 +01:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2016-10-29 19:42:42 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "mmap cache failed: (%d) %s", error.value()
|
2015-09-09 01:23:28 +02:00
|
|
|
, convert_from_native(error.message()).c_str());
|
2014-07-06 21:18:00 +02:00
|
|
|
return msg;
|
|
|
|
}
|
2016-10-29 19:42:42 +02:00
|
|
|
#endif
|
2014-07-06 21:18:00 +02:00
|
|
|
|
2017-06-15 00:46:11 +02:00
|
|
|
char const* operation_name(operation_t const op)
|
2014-07-06 21:18:00 +02:00
|
|
|
{
|
2017-12-01 00:57:48 +01:00
|
|
|
static char const* const names[] = {
|
2017-06-18 00:18:19 +02:00
|
|
|
"unknown",
|
2014-07-06 21:18:00 +02:00
|
|
|
"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",
|
2017-06-18 00:18:19 +02:00
|
|
|
"sock_listen",
|
|
|
|
"sock_bind_to_device",
|
|
|
|
"sock_accept",
|
|
|
|
"parse_address",
|
|
|
|
"enum_if",
|
|
|
|
"file_stat",
|
|
|
|
"file_copy",
|
|
|
|
"file_fallocate",
|
|
|
|
"file_hard_link",
|
|
|
|
"file_remove",
|
|
|
|
"file_rename",
|
|
|
|
"file_open",
|
|
|
|
"mkdir",
|
|
|
|
"check_resume",
|
|
|
|
"exception",
|
|
|
|
"alloc_cache_piece",
|
|
|
|
"partfile_move",
|
|
|
|
"partfile_read",
|
|
|
|
"partfile_write",
|
2017-06-18 20:35:05 +02:00
|
|
|
"hostname_lookup"
|
2014-07-06 21:18:00 +02:00
|
|
|
};
|
|
|
|
|
2017-06-15 00:46:11 +02:00
|
|
|
int const idx = static_cast<int>(op);
|
2017-12-01 00:57:48 +01:00
|
|
|
if (idx < 0 || idx >= int(sizeof(names) / sizeof(names[0])))
|
2014-07-06 21:18:00 +02:00
|
|
|
return "unknown operation";
|
|
|
|
|
2017-06-15 00:46:11 +02:00
|
|
|
return names[idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
char const* operation_name(int const op)
|
|
|
|
{
|
|
|
|
return operation_name(static_cast<operation_t>(op));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
peer_error_alert::peer_error_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
|
|
|
, tcp::endpoint const& ep, peer_id const& peer_id, operation_t const op_
|
|
|
|
, error_code const& e)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, op(op_)
|
|
|
|
, error(e)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, operation(static_cast<int>(op_))
|
|
|
|
, msg(convert_from_native(error.message()))
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string peer_error_alert::message() const
|
|
|
|
{
|
|
|
|
char buf[200];
|
|
|
|
std::snprintf(buf, sizeof(buf), "%s peer error [%s] [%s]: %s"
|
|
|
|
, peer_alert::message().c_str()
|
|
|
|
, operation_name(op), error.category().name()
|
|
|
|
, convert_from_native(error.message()).c_str());
|
|
|
|
return buf;
|
2014-07-06 21:18:00 +02:00
|
|
|
}
|
|
|
|
|
2016-02-20 21:49:49 +01:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), " torrent changed info-hash from: %s to %s"
|
2016-07-29 08:36:15 +02:00
|
|
|
, aux::to_hex(old_ih).c_str()
|
|
|
|
, aux::to_hex(new_ih).c_str());
|
2013-05-17 05:19:23 +02:00
|
|
|
return torrent_alert::message() + 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
|
2017-06-15 00:46:11 +02:00
|
|
|
, peer_id const& peer_id, operation_t op_, int type, error_code const& e
|
2015-04-03 22:15:48 +02:00
|
|
|
, close_reason_t r)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, socket_type(type)
|
2017-06-15 00:46:11 +02:00
|
|
|
, op(op_)
|
2015-04-03 22:15:48 +02:00
|
|
|
, error(e)
|
|
|
|
, reason(r)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-06-15 00:46:11 +02:00
|
|
|
, operation(static_cast<int>(op))
|
|
|
|
, msg(convert_from_native(error.message()))
|
2015-04-03 22:15:48 +02:00
|
|
|
#endif
|
2017-06-15 00:46:11 +02:00
|
|
|
{}
|
2015-04-03 22:15:48 +02:00
|
|
|
|
2013-07-28 17:06:28 +02:00
|
|
|
std::string peer_disconnected_alert::message() const
|
|
|
|
{
|
2015-08-02 05:57:11 +02:00
|
|
|
char buf[600];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(buf, sizeof(buf), "%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]
|
2017-06-15 00:46:11 +02:00
|
|
|
, operation_name(op), error.category().name()
|
2015-02-28 20:51:15 +01:00
|
|
|
, convert_from_native(error.message()).c_str()
|
|
|
|
, int(reason));
|
2015-08-02 05:57:11 +02:00
|
|
|
return buf;
|
2013-07-28 17:06:28 +02:00
|
|
|
}
|
2014-01-20 10:20:47 +01:00
|
|
|
|
2017-06-18 20:35:05 +02:00
|
|
|
dht_error_alert::dht_error_alert(aux::stack_allocator&
|
|
|
|
, operation_t const op_
|
2015-04-19 00:00:27 +02:00
|
|
|
, error_code const& ec)
|
2017-06-18 20:35:05 +02:00
|
|
|
: error(ec)
|
|
|
|
, op(op_)
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, operation(op_ == operation_t::hostname_lookup
|
|
|
|
? op_t::hostname_lookup : op_t::unknown)
|
|
|
|
#endif
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
2015-05-17 04:00:43 +02:00
|
|
|
|
2014-01-20 10:20:47 +01:00
|
|
|
std::string dht_error_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "DHT error [%s] (%d) %s"
|
2017-06-18 20:35:05 +02:00
|
|
|
, operation_name(op)
|
2014-01-20 10:20:47 +01:00
|
|
|
, 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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "DHT immutable item %s [ %s ]"
|
2016-07-29 08:36:15 +02:00
|
|
|
, aux::to_hex(target).c_str()
|
2014-02-24 01:31:13 +01:00
|
|
|
, 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&
|
2016-05-01 05:10:47 +02:00
|
|
|
, std::array<char, 32> k
|
|
|
|
, std::array<char, 64> sig
|
2016-12-13 16:30:36 +01:00
|
|
|
, std::int64_t sequence
|
2016-10-05 05:58:26 +02:00
|
|
|
, string_view s
|
2015-08-08 05:37:36 +02:00
|
|
|
, entry const& i
|
|
|
|
, bool a)
|
|
|
|
: key(k), signature(sig), seq(sequence), salt(s), item(i), authoritative(a)
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
|
|
|
|
2014-02-24 01:31:13 +01:00
|
|
|
std::string dht_mutable_item_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[1050];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "DHT mutable item (key=%s salt=%s seq=%" PRId64 " %s) [ %s ]"
|
2016-07-29 08:36:15 +02:00
|
|
|
, aux::to_hex(key).c_str()
|
2014-02-24 01:31:13 +01:00
|
|
|
, salt.c_str()
|
|
|
|
, seq
|
2015-08-08 05:37:36 +02:00
|
|
|
, authoritative ? "auth" : "non-auth"
|
2014-02-24 01:31:13 +01:00
|
|
|
, item.to_string().c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-09-22 20:10:57 +02:00
|
|
|
dht_put_alert::dht_put_alert(aux::stack_allocator&, sha1_hash const& t, int n)
|
2015-04-11 16:17:33 +02:00
|
|
|
: target(t)
|
2016-10-19 07:32:15 +02:00
|
|
|
, public_key()
|
|
|
|
, signature()
|
|
|
|
, salt()
|
2015-04-11 16:17:33 +02:00
|
|
|
, seq(0)
|
2015-09-22 20:10:57 +02:00
|
|
|
, num_success(n)
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_put_alert::dht_put_alert(aux::stack_allocator&
|
2016-05-01 05:10:47 +02:00
|
|
|
, std::array<char, 32> key
|
|
|
|
, std::array<char, 64> sig
|
2015-04-11 16:17:33 +02:00
|
|
|
, std::string s
|
2016-12-13 16:30:36 +01:00
|
|
|
, std::int64_t sequence_number
|
2015-09-22 20:10:57 +02:00
|
|
|
, int n)
|
2016-07-09 22:26:26 +02:00
|
|
|
: target(nullptr)
|
2015-04-11 16:17:33 +02:00
|
|
|
, public_key(key)
|
|
|
|
, signature(sig)
|
2016-07-10 13:34:45 +02:00
|
|
|
, salt(std::move(s))
|
2015-04-11 16:17:33 +02:00
|
|
|
, seq(sequence_number)
|
2015-09-22 20:10:57 +02:00
|
|
|
, num_success(n)
|
2015-04-11 16:17:33 +02:00
|
|
|
{}
|
|
|
|
|
2014-02-28 05:02:48 +01:00
|
|
|
std::string dht_put_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[1050];
|
2015-09-16 21:21:05 +02:00
|
|
|
if (target.is_all_zeros())
|
|
|
|
{
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "DHT put complete (success=%d key=%s sig=%s salt=%s seq=%" PRId64 ")"
|
2015-09-22 20:10:57 +02:00
|
|
|
, num_success
|
2016-07-29 08:36:15 +02:00
|
|
|
, aux::to_hex(public_key).c_str()
|
|
|
|
, aux::to_hex(signature).c_str()
|
2015-09-16 21:21:05 +02:00
|
|
|
, salt.c_str()
|
|
|
|
, seq);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "DHT put commplete (success=%d hash=%s)"
|
2015-09-22 20:10:57 +02:00
|
|
|
, num_success
|
2016-07-29 08:36:15 +02:00
|
|
|
, aux::to_hex(target).c_str());
|
2014-02-28 05:02:48 +01:00
|
|
|
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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "i2p_error: [%s] %s"
|
2014-03-15 23:20:19 +01:00
|
|
|
, 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)
|
2016-10-19 07:32:15 +02:00
|
|
|
, endpoint(std::move(ep))
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, ip(endpoint)
|
|
|
|
#endif
|
2015-04-19 00:00:27 +02:00
|
|
|
{}
|
|
|
|
|
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)
|
|
|
|
{
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(obf, sizeof(obf), " [obfuscated: %s]"
|
2016-07-29 08:36:15 +02:00
|
|
|
, aux::to_hex(obfuscated_info_hash).c_str());
|
2014-09-22 21:49:32 +02:00
|
|
|
}
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "outgoing dht get_peers : %s%s -> %s"
|
2016-07-29 08:36:15 +02:00
|
|
|
, aux::to_hex(info_hash).c_str()
|
2014-09-22 21:49:32 +02:00
|
|
|
, obf
|
2016-10-19 07:32:15 +02:00
|
|
|
, print_endpoint(endpoint).c_str());
|
2014-09-22 21:49:32 +02:00
|
|
|
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))
|
|
|
|
{}
|
2016-06-29 00:52:51 +02:00
|
|
|
log_alert::log_alert(aux::stack_allocator& alloc, char const* fmt, va_list v)
|
|
|
|
: m_alloc(alloc)
|
|
|
|
, m_str_idx(alloc.format_string(fmt, v))
|
|
|
|
{}
|
2015-04-03 22:15:48 +02:00
|
|
|
|
2016-10-19 07:32:15 +02:00
|
|
|
char const* log_alert::log_message() const
|
2015-04-03 22:15:48 +02:00
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_str_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2016-10-19 07:32:15 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
char const* log_alert::msg() const
|
|
|
|
{
|
|
|
|
return log_message();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-12-09 10:08:26 +01:00
|
|
|
std::string log_alert::message() const
|
|
|
|
{
|
2016-10-19 07:32:15 +02:00
|
|
|
return log_message();
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2015-12-03 18:34:02 +01:00
|
|
|
torrent_log_alert::torrent_log_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
2016-06-29 00:52:51 +02:00
|
|
|
, char const* fmt, va_list v)
|
2015-04-03 22:15:48 +02:00
|
|
|
: torrent_alert(alloc, h)
|
2016-06-29 00:52:51 +02:00
|
|
|
, m_str_idx(alloc.format_string(fmt, v))
|
2015-04-03 22:15:48 +02:00
|
|
|
{}
|
|
|
|
|
2016-10-19 07:32:15 +02:00
|
|
|
char const* torrent_log_alert::log_message() const
|
2015-04-03 22:15:48 +02:00
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_str_idx);
|
2014-12-09 10:08:26 +01:00
|
|
|
}
|
|
|
|
|
2016-10-19 07:32:15 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
char const* torrent_log_alert::msg() const
|
|
|
|
{
|
|
|
|
return log_message();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-12-09 10:08:26 +01:00
|
|
|
std::string torrent_log_alert::message() const
|
|
|
|
{
|
2016-10-19 07:32:15 +02:00
|
|
|
return torrent_alert::message() + ": " + log_message();
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2016-06-28 07:30:25 +02:00
|
|
|
peer_log_alert::peer_log_alert(aux::stack_allocator& alloc
|
|
|
|
, torrent_handle const& h
|
|
|
|
, tcp::endpoint const& i, peer_id const& pi
|
|
|
|
, peer_log_alert::direction_t dir
|
|
|
|
, char const* event, char const* fmt, va_list v)
|
|
|
|
: peer_alert(alloc, h, i, pi)
|
|
|
|
, event_type(event)
|
|
|
|
, direction(dir)
|
|
|
|
, m_str_idx(alloc.format_string(fmt, v))
|
|
|
|
{}
|
|
|
|
|
2016-10-19 07:32:15 +02:00
|
|
|
char const* peer_log_alert::log_message() const
|
2015-04-03 22:15:48 +02:00
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_str_idx);
|
2014-12-09 10:08:26 +01:00
|
|
|
}
|
|
|
|
|
2016-10-19 07:32:15 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
char const* peer_log_alert::msg() const
|
|
|
|
{
|
|
|
|
return log_message();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-12-09 10:08:26 +01:00
|
|
|
std::string peer_log_alert::message() const
|
|
|
|
{
|
2017-12-01 00:57:48 +01:00
|
|
|
static char const* const mode[] =
|
2015-05-03 04:53:54 +02:00
|
|
|
{ "<==", "==>", "<<<", ">>>", "***" };
|
2016-10-19 07:32:15 +02:00
|
|
|
return torrent_alert::message() + " [" + print_endpoint(endpoint) + "] "
|
|
|
|
+ mode[direction] + " " + event_type + " [ " + log_message() + " ]";
|
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
|
|
|
|
{
|
2016-10-06 06:08:14 +02:00
|
|
|
return "Local Service Discovery error: " + convert_from_native(error.message());
|
2015-01-17 00:01:14 +01:00
|
|
|
}
|
|
|
|
|
2017-04-12 19:00:57 +02:00
|
|
|
namespace {
|
|
|
|
|
2017-03-07 18:33:23 +01:00
|
|
|
aux::array<std::int64_t, counters::num_counters> counters_to_array(counters const& cnt)
|
2016-10-19 07:32:15 +02:00
|
|
|
{
|
2017-03-07 18:33:23 +01:00
|
|
|
aux::array<std::int64_t, counters::num_counters> arr;
|
2016-10-19 07:32:15 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < counters::num_counters; ++i)
|
2017-03-07 18:33:23 +01:00
|
|
|
arr[i] = cnt[i];
|
2016-10-19 07:32:15 +02:00
|
|
|
|
|
|
|
return arr;
|
|
|
|
}
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
2017-05-28 02:33:31 +02:00
|
|
|
session_stats_alert::session_stats_alert(aux::stack_allocator&, struct counters const& cnt)
|
2016-10-19 07:32:15 +02:00
|
|
|
: values(counters_to_array(cnt))
|
|
|
|
{}
|
|
|
|
|
2015-04-11 16:17:33 +02:00
|
|
|
std::string session_stats_alert::message() const
|
|
|
|
{
|
2016-10-22 20:12:23 +02:00
|
|
|
char msg[50];
|
2016-11-27 14:46:53 +01:00
|
|
|
std::snprintf(msg, sizeof(msg), "session stats (%d values): " , int(values.size()));
|
2016-01-11 08:10:42 +01:00
|
|
|
std::string ret = msg;
|
|
|
|
bool first = true;
|
2016-11-27 14:46:53 +01:00
|
|
|
for (auto v : values)
|
2016-01-11 08:10:42 +01:00
|
|
|
{
|
2016-11-27 14:46:53 +01:00
|
|
|
std::snprintf(msg, sizeof(msg), first ? "%" PRId64 : ", %" PRId64, v);
|
2016-01-11 08:10:42 +01:00
|
|
|
first = false;
|
|
|
|
ret += msg;
|
|
|
|
}
|
|
|
|
return ret;
|
2015-04-11 16:17:33 +02:00
|
|
|
}
|
|
|
|
|
2017-05-28 02:33:31 +02:00
|
|
|
span<std::int64_t const> session_stats_alert::counters() const
|
|
|
|
{
|
|
|
|
return values;
|
|
|
|
}
|
|
|
|
|
2015-04-19 00:00:27 +02:00
|
|
|
dht_stats_alert::dht_stats_alert(aux::stack_allocator&
|
2016-05-04 15:50:44 +02:00
|
|
|
, std::vector<dht_routing_bucket> table
|
|
|
|
, std::vector<dht_lookup> requests)
|
2015-04-19 00:00:27 +02:00
|
|
|
: alert()
|
2016-05-04 15:50:44 +02:00
|
|
|
, active_requests(std::move(requests))
|
|
|
|
, routing_table(std::move(table))
|
2015-04-19 00:00:27 +02:00
|
|
|
{}
|
|
|
|
|
2015-01-17 18:02:58 +01:00
|
|
|
std::string dht_stats_alert::message() const
|
|
|
|
{
|
|
|
|
char buf[2048];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(buf, sizeof(buf), "DHT stats: reqs: %d buckets: %d"
|
2015-01-17 18:02:58 +01:00
|
|
|
, 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
|
2016-10-05 05:58:26 +02:00
|
|
|
, string_view u, error_code const& e)
|
2015-04-03 22:15:48 +02:00
|
|
|
: torrent_alert(alloc, h)
|
2017-06-16 03:39:43 +02:00
|
|
|
, error(e)
|
|
|
|
, m_url_idx(alloc.copy_string(u))
|
|
|
|
, m_msg_idx()
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, url(u)
|
|
|
|
, msg(convert_from_native(e.message()))
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
|
|
|
url_seed_alert::url_seed_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
2016-10-05 05:58:26 +02:00
|
|
|
, string_view u, string_view m)
|
2015-04-03 22:15:48 +02:00
|
|
|
: torrent_alert(alloc, h)
|
2017-06-16 03:39:43 +02:00
|
|
|
, m_url_idx(alloc.copy_string(u))
|
|
|
|
, m_msg_idx(alloc.copy_string(m))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, url(u)
|
|
|
|
, msg(m)
|
|
|
|
#endif
|
|
|
|
{}
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_url_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
char const* url_seed_alert::error_message() const
|
|
|
|
{
|
2016-11-26 09:09:01 +01:00
|
|
|
if (m_msg_idx == aux::allocation_slot()) return "";
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_msg_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
file_error_alert::file_error_alert(aux::stack_allocator& alloc
|
2017-06-18 00:18:19 +02:00
|
|
|
, error_code const& ec, string_view f, operation_t const op_
|
2015-04-03 22:15:48 +02:00
|
|
|
, torrent_handle const& h)
|
|
|
|
: torrent_alert(alloc, h)
|
|
|
|
, error(ec)
|
2017-06-18 00:18:19 +02:00
|
|
|
, op(op_)
|
2015-08-02 08:16:21 +02:00
|
|
|
, m_file_idx(alloc.copy_string(f))
|
2015-04-03 22:15:48 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-06-18 00:18:19 +02:00
|
|
|
, operation(operation_name(op_))
|
2017-06-16 03:39:43 +02:00
|
|
|
, file(f)
|
|
|
|
, msg(convert_from_native(error.message()))
|
2015-04-03 22:15:48 +02:00
|
|
|
#endif
|
2017-06-16 03:39:43 +02:00
|
|
|
{}
|
2015-04-03 22:15:48 +02:00
|
|
|
|
|
|
|
char const* file_error_alert::filename() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_file_idx);
|
2015-04-03 22:15:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string file_error_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " "
|
2017-06-18 00:18:19 +02:00
|
|
|
+ operation_name(op) + " (" + filename()
|
2015-04-03 22:15:48 +02:00
|
|
|
+ ") 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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "%s: incoming request [ piece: %d start: %d length: %d ]"
|
2016-12-22 16:42:33 +01:00
|
|
|
, peer_alert::message().c_str(), static_cast<int>(req.piece)
|
|
|
|
, req.start, req.length);
|
2015-05-09 05:04:08 +02:00
|
|
|
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
|
2016-06-29 00:52:51 +02:00
|
|
|
, dht_log_alert::dht_module_t m, const char* fmt, va_list v)
|
2015-05-10 06:54:02 +02:00
|
|
|
: module(m)
|
|
|
|
, m_alloc(alloc)
|
2016-06-29 00:52:51 +02:00
|
|
|
, m_msg_idx(alloc.format_string(fmt, v))
|
2015-05-10 06:54:02 +02:00
|
|
|
{}
|
|
|
|
|
|
|
|
char const* dht_log_alert::log_message() const
|
|
|
|
{
|
2016-05-13 14:19:44 +02:00
|
|
|
return m_alloc.get().ptr(m_msg_idx);
|
2015-05-10 06:54:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::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
|
2016-09-28 05:21:18 +02:00
|
|
|
, span<char const> buf, dht_pkt_alert::direction_t d
|
|
|
|
, udp::endpoint const& ep)
|
2016-10-19 07:32:15 +02:00
|
|
|
: direction(d)
|
2017-12-01 00:57:48 +01:00
|
|
|
, node(ep)
|
2015-05-28 22:36:22 +02:00
|
|
|
, m_alloc(alloc)
|
2016-09-28 05:21:18 +02:00
|
|
|
, m_msg_idx(alloc.copy_buffer(buf))
|
2017-12-01 00:57:48 +01:00
|
|
|
, m_size(buf.size())
|
2017-06-16 03:39:43 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, dir(d)
|
|
|
|
#endif
|
2015-05-28 22:36:22 +02:00
|
|
|
{}
|
|
|
|
|
2016-09-28 05:21:18 +02:00
|
|
|
span<char const> dht_pkt_alert::pkt_buf() const
|
2015-05-28 22:36:22 +02:00
|
|
|
{
|
2017-12-01 00:57:48 +01:00
|
|
|
return {m_alloc.get().ptr(m_msg_idx), m_size};
|
2015-05-28 22:36:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2016-09-28 05:21:18 +02:00
|
|
|
span<char const> pkt = pkt_buf();
|
|
|
|
bdecode(pkt.data(), pkt.data() + int(pkt.size()), print, ec, nullptr, 100, 100);
|
2015-05-28 22:36:22 +02:00
|
|
|
|
|
|
|
std::string msg = print_entry(print, true);
|
|
|
|
|
2017-12-01 00:57:48 +01:00
|
|
|
static char const* const prefix[2] = {"<==", "==>"};
|
2015-05-28 22:36:22 +02:00
|
|
|
char buf[1024];
|
2016-10-19 07:32:15 +02:00
|
|
|
std::snprintf(buf, sizeof(buf), "%s [%s] %s", prefix[direction]
|
2015-05-28 22:36:22 +02:00
|
|
|
, print_endpoint(node).c_str(), msg.c_str());
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2015-06-30 05:26:12 +02:00
|
|
|
dht_get_peers_reply_alert::dht_get_peers_reply_alert(aux::stack_allocator& alloc
|
2015-06-25 17:01:36 +02:00
|
|
|
, sha1_hash const& ih
|
2015-06-30 05:26:12 +02:00
|
|
|
, std::vector<tcp::endpoint> const& peers)
|
2015-08-02 05:57:11 +02:00
|
|
|
: info_hash(ih)
|
|
|
|
, m_alloc(alloc)
|
2015-06-30 05:26:12 +02:00
|
|
|
{
|
2017-02-15 15:22:44 +01:00
|
|
|
for (auto const& endp : peers)
|
|
|
|
{
|
2017-02-18 06:13:46 +01:00
|
|
|
if (endp.protocol() == tcp::v4())
|
|
|
|
m_v4_num_peers++;
|
|
|
|
#if TORRENT_USE_IPV6
|
|
|
|
else
|
|
|
|
m_v6_num_peers++;
|
|
|
|
#endif
|
2015-07-04 04:59:44 +02:00
|
|
|
}
|
|
|
|
|
2017-02-18 06:13:46 +01:00
|
|
|
m_v4_peers_idx = alloc.allocate(m_v4_num_peers * 6);
|
|
|
|
m_v6_peers_idx = alloc.allocate(m_v6_num_peers * 18);
|
2015-07-03 03:35:59 +02:00
|
|
|
|
2017-02-18 06:13:46 +01:00
|
|
|
char* v4_ptr = alloc.ptr(m_v4_peers_idx);
|
|
|
|
#if TORRENT_USE_IPV6
|
|
|
|
char* v6_ptr = alloc.ptr(m_v6_peers_idx);
|
|
|
|
#endif
|
2017-02-15 15:22:44 +01:00
|
|
|
for (auto const& endp : peers)
|
|
|
|
{
|
2017-02-18 06:13:46 +01:00
|
|
|
if (endp.protocol() == tcp::v4())
|
|
|
|
detail::write_endpoint(endp, v4_ptr);
|
|
|
|
#if TORRENT_USE_IPV6
|
|
|
|
else
|
|
|
|
detail::write_endpoint(endp, v6_ptr);
|
|
|
|
#endif
|
2015-06-30 05:26:12 +02:00
|
|
|
}
|
|
|
|
}
|
2015-06-25 17:01:36 +02:00
|
|
|
|
|
|
|
std::string dht_get_peers_reply_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
2017-02-18 06:13:46 +01:00
|
|
|
std::snprintf(msg, sizeof(msg), "incoming dht get_peers reply: %s, peers %d"
|
|
|
|
, aux::to_hex(info_hash).c_str(), num_peers());
|
2015-06-25 17:01:36 +02:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-06-30 05:26:12 +02:00
|
|
|
int dht_get_peers_reply_alert::num_peers() const
|
|
|
|
{
|
2017-02-18 06:13:46 +01:00
|
|
|
return m_v4_num_peers + m_v6_num_peers;
|
2015-06-30 05:26:12 +02:00
|
|
|
}
|
|
|
|
|
2016-04-19 22:16:51 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
2017-02-15 15:22:44 +01:00
|
|
|
void dht_get_peers_reply_alert::peers(std::vector<tcp::endpoint> &v) const
|
|
|
|
{
|
2016-04-19 22:16:51 +02:00
|
|
|
std::vector<tcp::endpoint> p(peers());
|
|
|
|
v.reserve(p.size());
|
|
|
|
std::copy(p.begin(), p.end(), std::back_inserter(v));
|
2016-05-04 15:50:44 +02:00
|
|
|
}
|
2016-04-19 22:16:51 +02:00
|
|
|
#endif
|
2017-02-15 15:22:44 +01:00
|
|
|
std::vector<tcp::endpoint> dht_get_peers_reply_alert::peers() const
|
|
|
|
{
|
2017-02-18 06:13:46 +01:00
|
|
|
aux::vector<tcp::endpoint> peers;
|
|
|
|
peers.reserve(num_peers());
|
2015-07-03 03:35:59 +02:00
|
|
|
|
2017-02-18 06:13:46 +01:00
|
|
|
char const* v4_ptr = m_alloc.get().ptr(m_v4_peers_idx);
|
|
|
|
for (int i = 0; i < m_v4_num_peers; i++)
|
|
|
|
peers.push_back(detail::read_v4_endpoint<tcp::endpoint>(v4_ptr));
|
|
|
|
#if TORRENT_USE_IPV6
|
|
|
|
char const* v6_ptr = m_alloc.get().ptr(m_v6_peers_idx);
|
|
|
|
for (int i = 0; i < m_v6_num_peers; i++)
|
|
|
|
peers.push_back(detail::read_v6_endpoint<tcp::endpoint>(v6_ptr));
|
|
|
|
#endif
|
2016-04-19 22:16:51 +02:00
|
|
|
|
|
|
|
return peers;
|
2015-06-30 05:26:12 +02:00
|
|
|
}
|
|
|
|
|
2014-02-17 06:56:49 +01:00
|
|
|
dht_direct_response_alert::dht_direct_response_alert(
|
2015-08-16 18:17:23 +02:00
|
|
|
aux::stack_allocator& alloc, void* userdata_
|
2015-08-17 15:01:43 +02:00
|
|
|
, udp::endpoint const& addr_, bdecode_node const& response)
|
2016-10-19 07:32:15 +02:00
|
|
|
: userdata(userdata_), endpoint(addr_)
|
|
|
|
, m_alloc(alloc)
|
2016-09-28 05:21:18 +02:00
|
|
|
, m_response_idx(alloc.copy_buffer(response.data_section()))
|
2016-07-24 00:57:04 +02:00
|
|
|
, m_response_size(int(response.data_section().size()))
|
2017-06-16 03:39:43 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, addr(addr_)
|
|
|
|
#endif
|
2014-02-17 06:56:49 +01:00
|
|
|
{}
|
|
|
|
|
2015-08-09 05:29:29 +02:00
|
|
|
dht_direct_response_alert::dht_direct_response_alert(
|
|
|
|
aux::stack_allocator& alloc
|
2015-08-16 18:17:23 +02:00
|
|
|
, void* userdata_
|
|
|
|
, udp::endpoint const& addr_)
|
2016-10-19 07:32:15 +02:00
|
|
|
: userdata(userdata_), endpoint(addr_)
|
|
|
|
, m_alloc(alloc)
|
2016-11-26 09:09:01 +01:00
|
|
|
, m_response_idx()
|
|
|
|
, m_response_size(0)
|
2017-06-16 03:39:43 +02:00
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
, addr(addr_)
|
|
|
|
#endif
|
2015-08-09 05:29:29 +02:00
|
|
|
{}
|
|
|
|
|
2014-02-17 06:56:49 +01:00
|
|
|
std::string dht_direct_response_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[1050];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(msg, sizeof(msg), "DHT direct response (address=%s) [ %s ]"
|
2016-10-19 07:32:15 +02:00
|
|
|
, endpoint.address().to_string().c_str()
|
2017-01-24 07:35:17 +01:00
|
|
|
, m_response_size ? std::string(m_alloc.get().ptr(m_response_idx)
|
|
|
|
, aux::numeric_cast<std::size_t>(m_response_size)).c_str() : "");
|
2014-02-17 06:56:49 +01:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2015-08-09 04:43:47 +02:00
|
|
|
bdecode_node dht_direct_response_alert::response() const
|
2015-08-06 05:20:24 +02:00
|
|
|
{
|
2015-08-09 05:29:29 +02:00
|
|
|
if (m_response_size == 0) return bdecode_node();
|
2016-05-13 14:19:44 +02:00
|
|
|
char const* start = m_alloc.get().ptr(m_response_idx);
|
2015-08-06 05:20:24 +02:00
|
|
|
char const* end = start + m_response_size;
|
|
|
|
error_code ec;
|
2015-08-09 04:43:47 +02:00
|
|
|
bdecode_node ret;
|
2015-08-06 05:20:24 +02:00
|
|
|
bdecode(start, end, ret, ec);
|
|
|
|
TORRENT_ASSERT(!ec);
|
2015-08-09 04:43:47 +02:00
|
|
|
return ret;
|
2015-08-06 05:20:24 +02:00
|
|
|
}
|
|
|
|
|
2015-12-03 18:34:02 +01:00
|
|
|
picker_log_alert::picker_log_alert(aux::stack_allocator& alloc, torrent_handle const& h
|
2017-07-23 09:55:40 +02:00
|
|
|
, tcp::endpoint const& ep, peer_id const& peer_id, picker_flags_t const flags
|
2015-11-29 06:58:46 +01:00
|
|
|
, piece_block const* blocks, int num_blocks)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, picker_flags(flags)
|
2016-09-28 05:21:18 +02:00
|
|
|
, m_array_idx(alloc.copy_buffer({reinterpret_cast<char const*>(blocks)
|
2017-01-24 07:35:17 +01:00
|
|
|
, aux::numeric_cast<std::size_t>(num_blocks) * sizeof(piece_block)}))
|
2015-11-29 06:58:46 +01:00
|
|
|
, m_num_blocks(num_blocks)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::vector<piece_block> picker_log_alert::blocks() const
|
|
|
|
{
|
|
|
|
// we need to copy this array to make sure the structures are properly
|
2016-09-28 05:21:18 +02:00
|
|
|
// aligned, not just to have a nice API
|
2017-01-24 07:35:17 +01:00
|
|
|
std::size_t const num_blocks = aux::numeric_cast<std::size_t>(m_num_blocks);
|
|
|
|
std::vector<piece_block> ret(num_blocks);
|
2015-11-29 06:58:46 +01:00
|
|
|
|
2016-05-13 14:19:44 +02:00
|
|
|
char const* start = m_alloc.get().ptr(m_array_idx);
|
2017-01-24 07:35:17 +01:00
|
|
|
std::memcpy(ret.data(), start, num_blocks * sizeof(piece_block));
|
2015-11-29 06:58:46 +01:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:55:40 +02:00
|
|
|
constexpr picker_flags_t picker_log_alert::partial_ratio;
|
|
|
|
constexpr picker_flags_t picker_log_alert::prioritize_partials;
|
|
|
|
constexpr picker_flags_t picker_log_alert::rarest_first_partials;
|
|
|
|
constexpr picker_flags_t picker_log_alert::rarest_first;
|
|
|
|
constexpr picker_flags_t picker_log_alert::reverse_rarest_first;
|
|
|
|
constexpr picker_flags_t picker_log_alert::suggested_pieces;
|
|
|
|
constexpr picker_flags_t picker_log_alert::prio_sequential_pieces;
|
|
|
|
constexpr picker_flags_t picker_log_alert::sequential_pieces;
|
|
|
|
constexpr picker_flags_t picker_log_alert::reverse_pieces;
|
|
|
|
constexpr picker_flags_t picker_log_alert::time_critical;
|
|
|
|
constexpr picker_flags_t picker_log_alert::random_pieces;
|
|
|
|
constexpr picker_flags_t picker_log_alert::prefer_contiguous;
|
|
|
|
constexpr picker_flags_t picker_log_alert::reverse_sequential;
|
|
|
|
constexpr picker_flags_t picker_log_alert::backup1;
|
|
|
|
constexpr picker_flags_t picker_log_alert::backup2;
|
|
|
|
constexpr picker_flags_t picker_log_alert::end_game;
|
|
|
|
|
2015-11-29 06:58:46 +01:00
|
|
|
std::string picker_log_alert::message() const
|
|
|
|
{
|
|
|
|
static char const* const flag_names[] =
|
|
|
|
{
|
|
|
|
"partial_ratio ",
|
|
|
|
"prioritize_partials ",
|
|
|
|
"rarest_first_partials ",
|
|
|
|
"rarest_first ",
|
|
|
|
"reverse_rarest_first ",
|
|
|
|
"suggested_pieces ",
|
|
|
|
"prio_sequential_pieces ",
|
|
|
|
"sequential_pieces ",
|
|
|
|
"reverse_pieces ",
|
|
|
|
"time_critical ",
|
|
|
|
"random_pieces ",
|
|
|
|
"prefer_contiguous ",
|
|
|
|
"reverse_sequential ",
|
|
|
|
"backup1 ",
|
|
|
|
"backup2 ",
|
|
|
|
"end_game "
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string ret = peer_alert::message();
|
|
|
|
|
2017-07-23 09:55:40 +02:00
|
|
|
auto flags = static_cast<std::uint32_t>(picker_flags);
|
2015-11-29 06:58:46 +01:00
|
|
|
int idx = 0;
|
|
|
|
ret += " picker_log [ ";
|
|
|
|
for (; flags != 0; flags >>= 1, ++idx)
|
|
|
|
{
|
|
|
|
if ((flags & 1) == 0) continue;
|
|
|
|
ret += flag_names[idx];
|
|
|
|
}
|
|
|
|
ret += "] ";
|
|
|
|
|
|
|
|
std::vector<piece_block> b = blocks();
|
|
|
|
|
2016-12-13 16:30:36 +01:00
|
|
|
for (auto const& p : b)
|
2015-11-29 06:58:46 +01:00
|
|
|
{
|
|
|
|
char buf[50];
|
2016-05-17 15:24:06 +02:00
|
|
|
std::snprintf(buf, sizeof(buf), "(%d,%d) "
|
2016-12-22 16:42:33 +01:00
|
|
|
, static_cast<int>(p.piece_index), p.block_index);
|
2015-11-29 06:58:46 +01:00
|
|
|
ret += buf;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-10-06 06:08:14 +02:00
|
|
|
session_error_alert::session_error_alert(aux::stack_allocator& alloc
|
|
|
|
, error_code e, string_view error_str)
|
|
|
|
: error(e)
|
|
|
|
, m_alloc(alloc)
|
|
|
|
, m_msg_idx(alloc.copy_buffer(error_str))
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string session_error_alert::message() const
|
|
|
|
{
|
|
|
|
char buf[400];
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
std::snprintf(buf, sizeof(buf), "session error: (%d %s) %s"
|
|
|
|
, error.value(), convert_from_native(error.message()).c_str()
|
|
|
|
, m_alloc.get().ptr(m_msg_idx));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::snprintf(buf, sizeof(buf), "session error: %s"
|
|
|
|
, m_alloc.get().ptr(m_msg_idx));
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2017-04-12 19:00:57 +02:00
|
|
|
namespace {
|
|
|
|
|
2017-03-16 14:50:23 +01:00
|
|
|
using nodes_slot = std::tuple<int, aux::allocation_slot, int, aux::allocation_slot>;
|
|
|
|
|
|
|
|
nodes_slot write_nodes(aux::stack_allocator& alloc
|
2017-02-19 05:02:23 +01:00
|
|
|
, std::vector<std::pair<sha1_hash, udp::endpoint>> const& nodes)
|
|
|
|
{
|
2017-03-16 14:50:23 +01:00
|
|
|
int v4_num_nodes = 0;
|
|
|
|
int v6_num_nodes = 0;
|
|
|
|
|
2017-02-19 05:02:23 +01:00
|
|
|
for (auto const& n : nodes)
|
|
|
|
{
|
|
|
|
if (n.second.protocol() == udp::v4())
|
2017-03-16 14:50:23 +01:00
|
|
|
v4_num_nodes++;
|
2017-02-19 05:02:23 +01:00
|
|
|
#if TORRENT_USE_IPV6
|
|
|
|
else
|
2017-03-16 14:50:23 +01:00
|
|
|
v6_num_nodes++;
|
2017-02-19 05:02:23 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-03-16 14:50:23 +01:00
|
|
|
aux::allocation_slot const v4_nodes_idx = alloc.allocate(v4_num_nodes * (20 + 6));
|
|
|
|
aux::allocation_slot const v6_nodes_idx = alloc.allocate(v6_num_nodes * (20 + 18));
|
2017-02-19 05:02:23 +01:00
|
|
|
|
2017-03-16 14:50:23 +01:00
|
|
|
char* v4_ptr = alloc.ptr(v4_nodes_idx);
|
2017-02-19 05:02:23 +01:00
|
|
|
#if TORRENT_USE_IPV6
|
2017-03-16 14:50:23 +01:00
|
|
|
char* v6_ptr = alloc.ptr(v6_nodes_idx);
|
2017-02-19 05:02:23 +01:00
|
|
|
#endif
|
|
|
|
for (auto const& n : nodes)
|
|
|
|
{
|
|
|
|
udp::endpoint const& endp = n.second;
|
|
|
|
if (endp.protocol() == udp::v4())
|
|
|
|
{
|
|
|
|
detail::write_string(n.first.to_string(), v4_ptr);
|
|
|
|
detail::write_endpoint(endp, v4_ptr);
|
|
|
|
}
|
|
|
|
#if TORRENT_USE_IPV6
|
|
|
|
else
|
|
|
|
{
|
|
|
|
detail::write_string(n.first.to_string(), v6_ptr);
|
|
|
|
detail::write_endpoint(endp, v6_ptr);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-01-11 01:35:15 +01:00
|
|
|
return nodes_slot{v4_num_nodes, v4_nodes_idx, v6_num_nodes, v6_nodes_idx};
|
2017-02-19 05:02:23 +01:00
|
|
|
}
|
|
|
|
|
2017-03-16 14:50:23 +01:00
|
|
|
std::vector<std::pair<sha1_hash, udp::endpoint>> read_nodes(
|
|
|
|
aux::stack_allocator const& alloc
|
|
|
|
, int const v4_num_nodes, aux::allocation_slot const v4_nodes_idx
|
|
|
|
, int const v6_num_nodes, aux::allocation_slot const v6_nodes_idx)
|
2017-02-19 05:02:23 +01:00
|
|
|
{
|
|
|
|
aux::vector<std::pair<sha1_hash, udp::endpoint>> nodes;
|
2017-03-16 14:50:23 +01:00
|
|
|
nodes.reserve(v4_num_nodes + v6_num_nodes);
|
2017-02-19 05:02:23 +01:00
|
|
|
|
2017-03-16 14:50:23 +01:00
|
|
|
char const* v4_ptr = alloc.ptr(v4_nodes_idx);
|
|
|
|
for (int i = 0; i < v4_num_nodes; i++)
|
2017-02-19 05:02:23 +01:00
|
|
|
{
|
|
|
|
sha1_hash ih;
|
|
|
|
std::memcpy(ih.data(), v4_ptr, 20);
|
|
|
|
v4_ptr += 20;
|
|
|
|
nodes.emplace_back(ih, detail::read_v4_endpoint<udp::endpoint>(v4_ptr));
|
|
|
|
}
|
|
|
|
#if TORRENT_USE_IPV6
|
2017-03-16 14:50:23 +01:00
|
|
|
char const* v6_ptr = alloc.ptr(v6_nodes_idx);
|
|
|
|
for (int i = 0; i < v6_num_nodes; i++)
|
2017-02-19 05:02:23 +01:00
|
|
|
{
|
|
|
|
sha1_hash ih;
|
|
|
|
std::memcpy(ih.data(), v6_ptr, 20);
|
|
|
|
v6_ptr += 20;
|
|
|
|
nodes.emplace_back(ih, detail::read_v6_endpoint<udp::endpoint>(v6_ptr));
|
|
|
|
}
|
2017-03-16 14:50:23 +01:00
|
|
|
#else
|
|
|
|
TORRENT_UNUSED(v6_nodes_idx);
|
2017-02-19 05:02:23 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return nodes;
|
|
|
|
}
|
2017-03-16 14:50:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
dht_live_nodes_alert::dht_live_nodes_alert(aux::stack_allocator& alloc
|
|
|
|
, sha1_hash const& nid
|
|
|
|
, std::vector<std::pair<sha1_hash, udp::endpoint>> const& nodes)
|
|
|
|
: node_id(nid)
|
|
|
|
, m_alloc(alloc)
|
|
|
|
{
|
|
|
|
std::tie(m_v4_num_nodes, m_v4_nodes_idx, m_v6_num_nodes, m_v6_nodes_idx)
|
|
|
|
= write_nodes(alloc, nodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string dht_live_nodes_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
|
|
|
std::snprintf(msg, sizeof(msg), "dht live nodes for id: %s, nodes %d"
|
|
|
|
, aux::to_hex(node_id).c_str(), num_nodes());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dht_live_nodes_alert::num_nodes() const
|
|
|
|
{
|
|
|
|
return m_v4_num_nodes + m_v6_num_nodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::pair<sha1_hash, udp::endpoint>> dht_live_nodes_alert::nodes() const
|
|
|
|
{
|
|
|
|
return read_nodes(m_alloc.get()
|
|
|
|
, m_v4_num_nodes, m_v4_nodes_idx
|
|
|
|
, m_v6_num_nodes, m_v6_nodes_idx);
|
|
|
|
}
|
2017-02-19 05:02:23 +01:00
|
|
|
|
2017-03-08 20:06:27 +01:00
|
|
|
session_stats_header_alert::session_stats_header_alert(aux::stack_allocator&)
|
|
|
|
{}
|
|
|
|
|
|
|
|
std::string session_stats_header_alert::message() const
|
|
|
|
{
|
|
|
|
std::string stats_header = "session stats header: ";
|
|
|
|
std::vector<stats_metric> stats = session_stats_metrics();
|
|
|
|
std::sort(stats.begin(), stats.end()
|
|
|
|
, [] (stats_metric const& lhs, stats_metric const& rhs)
|
|
|
|
{ return lhs.value_index < rhs.value_index; });
|
|
|
|
bool first = true;
|
|
|
|
for (auto const& s : stats)
|
|
|
|
{
|
|
|
|
if (!first) stats_header += ", ";
|
|
|
|
stats_header += s.name;
|
|
|
|
first = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return stats_header;
|
|
|
|
}
|
|
|
|
|
2017-06-12 11:54:11 +02:00
|
|
|
dht_sample_infohashes_alert::dht_sample_infohashes_alert(aux::stack_allocator& alloc
|
|
|
|
, udp::endpoint const& endp
|
|
|
|
, time_duration _interval
|
|
|
|
, int _num
|
|
|
|
, std::vector<sha1_hash> const& samples
|
|
|
|
, std::vector<std::pair<sha1_hash, udp::endpoint>> const& nodes)
|
|
|
|
: endpoint(endp)
|
|
|
|
, interval(_interval)
|
|
|
|
, num_infohashes(_num)
|
|
|
|
, m_alloc(alloc)
|
|
|
|
, m_num_samples(aux::numeric_cast<int>(samples.size()))
|
|
|
|
{
|
|
|
|
m_samples_idx = alloc.allocate(m_num_samples * 20);
|
|
|
|
|
|
|
|
char *ptr = alloc.ptr(m_samples_idx);
|
|
|
|
std::memcpy(ptr, samples.data(), samples.size() * 20);
|
|
|
|
|
|
|
|
std::tie(m_v4_num_nodes, m_v4_nodes_idx, m_v6_num_nodes, m_v6_nodes_idx)
|
|
|
|
= write_nodes(alloc, nodes);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string dht_sample_infohashes_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
|
|
|
std::snprintf(msg, sizeof(msg)
|
|
|
|
, "incoming dht sample_infohashes reply from: %s, samples %d"
|
|
|
|
, print_endpoint(endpoint).c_str(), m_num_samples);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dht_sample_infohashes_alert::num_samples() const
|
|
|
|
{
|
|
|
|
return m_num_samples;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<sha1_hash> dht_sample_infohashes_alert::samples() const
|
|
|
|
{
|
|
|
|
aux::vector<sha1_hash> samples;
|
|
|
|
samples.resize(m_num_samples);
|
|
|
|
|
|
|
|
const char *ptr = m_alloc.get().ptr(m_samples_idx);
|
|
|
|
std::memcpy(samples.data(), ptr, samples.size() * 20);
|
|
|
|
|
|
|
|
return samples;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dht_sample_infohashes_alert::num_nodes() const
|
|
|
|
{
|
|
|
|
return m_v4_num_nodes + m_v6_num_nodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::pair<sha1_hash, udp::endpoint>> dht_sample_infohashes_alert::nodes() const
|
|
|
|
{
|
|
|
|
return read_nodes(m_alloc.get()
|
|
|
|
, m_v4_num_nodes, m_v4_nodes_idx
|
|
|
|
, m_v6_num_nodes, m_v6_nodes_idx);
|
|
|
|
}
|
|
|
|
|
2017-07-02 19:41:38 +02:00
|
|
|
block_uploaded_alert::block_uploaded_alert(aux::stack_allocator& alloc, torrent_handle h
|
|
|
|
, tcp::endpoint const& ep, peer_id const& peer_id, int block_num
|
|
|
|
, piece_index_t piece_num)
|
|
|
|
: peer_alert(alloc, h, ep, peer_id)
|
|
|
|
, block_index(block_num)
|
|
|
|
, piece_index(piece_num)
|
|
|
|
{
|
|
|
|
TORRENT_ASSERT(block_index >= 0 && piece_index >= piece_index_t{0});
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string block_uploaded_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s block uploaded to a peer (piece: %u block: %u)"
|
|
|
|
, torrent_alert::message().c_str(), static_cast<int>(piece_index), block_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-07-26 06:33:10 +02:00
|
|
|
// this will no longer be necessary in C++17
|
|
|
|
constexpr alert_category_t torrent_removed_alert::static_category;
|
|
|
|
constexpr alert_category_t read_piece_alert::static_category;
|
|
|
|
constexpr alert_category_t file_completed_alert::static_category;
|
|
|
|
constexpr alert_category_t file_renamed_alert::static_category;
|
|
|
|
constexpr alert_category_t file_rename_failed_alert::static_category;
|
|
|
|
constexpr alert_category_t performance_alert::static_category;
|
|
|
|
constexpr alert_category_t state_changed_alert::static_category;
|
|
|
|
constexpr alert_category_t tracker_error_alert::static_category;
|
|
|
|
constexpr alert_category_t tracker_warning_alert::static_category;
|
2017-09-16 13:47:04 +02:00
|
|
|
constexpr alert_category_t scrape_reply_alert::static_category;
|
2017-07-26 06:33:10 +02:00
|
|
|
constexpr alert_category_t scrape_failed_alert::static_category;
|
2017-09-16 13:47:04 +02:00
|
|
|
constexpr alert_category_t tracker_reply_alert::static_category;
|
2017-07-26 06:33:10 +02:00
|
|
|
constexpr alert_category_t dht_reply_alert::static_category;
|
2017-09-16 13:47:04 +02:00
|
|
|
constexpr alert_category_t tracker_announce_alert::static_category;
|
2017-07-26 06:33:10 +02:00
|
|
|
constexpr alert_category_t hash_failed_alert::static_category;
|
2017-09-16 13:47:04 +02:00
|
|
|
constexpr alert_category_t peer_ban_alert::static_category;
|
|
|
|
constexpr alert_category_t peer_unsnubbed_alert::static_category;
|
|
|
|
constexpr alert_category_t peer_snubbed_alert::static_category;
|
2017-07-26 06:33:10 +02:00
|
|
|
constexpr alert_category_t peer_error_alert::static_category;
|
|
|
|
constexpr alert_category_t peer_connect_alert::static_category;
|
|
|
|
constexpr alert_category_t peer_disconnected_alert::static_category;
|
2017-09-16 13:47:04 +02:00
|
|
|
constexpr alert_category_t invalid_request_alert::static_category;
|
2017-07-26 06:33:10 +02:00
|
|
|
constexpr alert_category_t torrent_finished_alert::static_category;
|
|
|
|
constexpr alert_category_t piece_finished_alert::static_category;
|
|
|
|
constexpr alert_category_t request_dropped_alert::static_category;
|
|
|
|
constexpr alert_category_t block_timeout_alert::static_category;
|
|
|
|
constexpr alert_category_t block_finished_alert::static_category;
|
|
|
|
constexpr alert_category_t block_downloading_alert::static_category;
|
2017-09-16 13:47:04 +02:00
|
|
|
constexpr alert_category_t unwanted_block_alert::static_category;
|
2017-07-26 06:33:10 +02:00
|
|
|
constexpr alert_category_t storage_moved_alert::static_category;
|
|
|
|
constexpr alert_category_t storage_moved_failed_alert::static_category;
|
|
|
|
constexpr alert_category_t torrent_deleted_alert::static_category;
|
|
|
|
constexpr alert_category_t torrent_delete_failed_alert::static_category;
|
|
|
|
constexpr alert_category_t save_resume_data_alert::static_category;
|
|
|
|
constexpr alert_category_t save_resume_data_failed_alert::static_category;
|
|
|
|
constexpr alert_category_t torrent_paused_alert::static_category;
|
|
|
|
constexpr alert_category_t torrent_resumed_alert::static_category;
|
|
|
|
constexpr alert_category_t torrent_checked_alert::static_category;
|
|
|
|
constexpr alert_category_t url_seed_alert::static_category;
|
|
|
|
constexpr alert_category_t file_error_alert::static_category;
|
|
|
|
constexpr alert_category_t metadata_failed_alert::static_category;
|
|
|
|
constexpr alert_category_t metadata_received_alert::static_category;
|
|
|
|
constexpr alert_category_t udp_error_alert::static_category;
|
|
|
|
constexpr alert_category_t external_ip_alert::static_category;
|
|
|
|
constexpr alert_category_t listen_failed_alert::static_category;
|
|
|
|
constexpr alert_category_t listen_succeeded_alert::static_category;
|
|
|
|
constexpr alert_category_t portmap_error_alert::static_category;
|
|
|
|
constexpr alert_category_t portmap_alert::static_category;
|
|
|
|
constexpr alert_category_t portmap_log_alert::static_category;
|
|
|
|
constexpr alert_category_t fastresume_rejected_alert::static_category;
|
|
|
|
constexpr alert_category_t peer_blocked_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_announce_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_get_peers_alert::static_category;
|
|
|
|
constexpr alert_category_t stats_alert::static_category;
|
|
|
|
constexpr alert_category_t cache_flushed_alert::static_category;
|
|
|
|
constexpr alert_category_t anonymous_mode_alert::static_category;
|
|
|
|
constexpr alert_category_t lsd_peer_alert::static_category;
|
|
|
|
constexpr alert_category_t trackerid_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_bootstrap_alert::static_category;
|
|
|
|
constexpr alert_category_t torrent_error_alert::static_category;
|
|
|
|
constexpr alert_category_t torrent_need_cert_alert::static_category;
|
|
|
|
constexpr alert_category_t incoming_connection_alert::static_category;
|
|
|
|
constexpr alert_category_t add_torrent_alert::static_category;
|
|
|
|
constexpr alert_category_t state_update_alert::static_category;
|
|
|
|
constexpr alert_category_t session_stats_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_error_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_immutable_item_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_mutable_item_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_put_alert::static_category;
|
|
|
|
constexpr alert_category_t i2p_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_outgoing_get_peers_alert::static_category;
|
|
|
|
constexpr alert_category_t log_alert::static_category;
|
|
|
|
constexpr alert_category_t torrent_log_alert::static_category;
|
|
|
|
constexpr alert_category_t peer_log_alert::static_category;
|
|
|
|
constexpr alert_category_t lsd_error_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_stats_alert::static_category;
|
|
|
|
constexpr alert_category_t incoming_request_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_log_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_pkt_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_get_peers_reply_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_direct_response_alert::static_category;
|
|
|
|
constexpr alert_category_t picker_log_alert::static_category;
|
|
|
|
constexpr alert_category_t session_error_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_live_nodes_alert::static_category;
|
|
|
|
constexpr alert_category_t session_stats_header_alert::static_category;
|
|
|
|
constexpr alert_category_t dht_sample_infohashes_alert::static_category;
|
|
|
|
constexpr alert_category_t block_uploaded_alert::static_category;
|
|
|
|
#ifndef TORRENT_NO_DEPRECATE
|
|
|
|
constexpr alert_category_t mmap_cache_alert::static_category;
|
|
|
|
constexpr alert_category_t torrent_added_alert::static_category;
|
|
|
|
constexpr alert_category_t torrent_update_alert::static_category;
|
|
|
|
#endif
|
|
|
|
|
2003-11-29 17:34:07 +01:00
|
|
|
} // namespace libtorrent
|