2003-11-29 17:34:07 +01:00
|
|
|
/*
|
|
|
|
|
2012-10-02 05:16:33 +02:00
|
|
|
Copyright (c) 2003-2012, 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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2007-03-17 18:15:16 +01:00
|
|
|
#include "libtorrent/pch.hpp"
|
|
|
|
|
2011-06-05 08:32:00 +02:00
|
|
|
#include <string>
|
|
|
|
|
2011-02-25 18:00:36 +01:00
|
|
|
#include "libtorrent/config.hpp"
|
2003-11-29 17:34:07 +01:00
|
|
|
#include "libtorrent/alert.hpp"
|
2009-11-26 22:40:10 +01:00
|
|
|
#include "libtorrent/alert_types.hpp"
|
2009-11-23 09:38:50 +01:00
|
|
|
#include "libtorrent/io_service.hpp"
|
2009-11-26 22:40:10 +01:00
|
|
|
#include "libtorrent/socket_io.hpp"
|
2009-11-25 07:55:34 +01:00
|
|
|
#include "libtorrent/time.hpp"
|
2009-11-27 08:08:47 +01:00
|
|
|
#include "libtorrent/error_code.hpp"
|
2009-11-28 23:41:21 +01:00
|
|
|
#include "libtorrent/escape_string.hpp"
|
2011-01-29 11:37:21 +01:00
|
|
|
#include "libtorrent/extensions.hpp"
|
2009-05-23 23:36:09 +02:00
|
|
|
#include <boost/bind.hpp>
|
2003-11-29 17:34:07 +01:00
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
namespace libtorrent {
|
2004-01-23 01:39:05 +01:00
|
|
|
|
2008-07-06 14:22:56 +02:00
|
|
|
alert::alert() : m_timestamp(time_now()) {}
|
|
|
|
alert::~alert() {}
|
|
|
|
ptime alert::timestamp() const { return m_timestamp; }
|
2004-01-23 01:39:05 +01:00
|
|
|
|
2009-11-26 22:40:10 +01:00
|
|
|
|
|
|
|
std::string torrent_alert::message() const
|
|
|
|
{
|
|
|
|
if (!handle.is_valid()) return " - ";
|
2013-03-04 04:24:53 +01:00
|
|
|
torrent_status st = handle.status(torrent_handle::query_name);
|
|
|
|
if (st.name.empty())
|
2009-11-26 22:40:10 +01:00
|
|
|
{
|
|
|
|
char msg[41];
|
2013-03-04 04:24:53 +01:00
|
|
|
to_hex((char const*)&st.info_hash[0], 20, msg);
|
2009-11-26 22:40:10 +01:00
|
|
|
return msg;
|
|
|
|
}
|
2013-03-04 04:24:53 +01:00
|
|
|
return st.name;
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string peer_alert::message() const
|
|
|
|
{
|
|
|
|
error_code ec;
|
|
|
|
return torrent_alert::message() + " peer (" + ip.address().to_string(ec)
|
|
|
|
+ ", " + identify_client(pid) + ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string tracker_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " (" + url + ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string read_piece_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
2013-01-29 03:18:32 +01:00
|
|
|
if (ec)
|
|
|
|
{
|
|
|
|
snprintf(msg, sizeof(msg), "%s: read_piece %u failed: %s"
|
|
|
|
, torrent_alert::message().c_str() , piece, ec.message().c_str());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
snprintf(msg, sizeof(msg), "%s: read_piece %u successful"
|
|
|
|
, torrent_alert::message().c_str() , piece);
|
|
|
|
}
|
2009-11-26 22:40:10 +01:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string file_completed_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200 + TORRENT_MAX_PATH];
|
|
|
|
snprintf(msg, sizeof(msg), "%s: file %d finished downloading"
|
|
|
|
, torrent_alert::message().c_str(), index);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string file_renamed_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200 + TORRENT_MAX_PATH * 2];
|
|
|
|
snprintf(msg, sizeof(msg), "%s: file %d renamed to %s", torrent_alert::message().c_str()
|
|
|
|
, index, name.c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string file_rename_failed_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200 + TORRENT_MAX_PATH * 2];
|
|
|
|
snprintf(ret, sizeof(ret), "%s: failed to rename file %d: %s"
|
2013-01-19 07:39:32 +01:00
|
|
|
, torrent_alert::message().c_str(), index, convert_from_native(error.message()).c_str());
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string performance_alert::message() const
|
|
|
|
{
|
|
|
|
static char const* warning_str[] =
|
|
|
|
{
|
|
|
|
"max outstanding disk writes reached",
|
|
|
|
"max outstanding piece requests reached",
|
|
|
|
"upload limit too low (download rate will suffer)",
|
|
|
|
"download limit too low (upload rate will suffer)",
|
2010-02-06 08:39:45 +01:00
|
|
|
"send buffer watermark too low (upload rate will suffer)",
|
2010-02-09 04:04:41 +01:00
|
|
|
"too many optimistic unchoke slots",
|
2011-03-16 08:45:51 +01:00
|
|
|
"using bittyrant unchoker with no upload rate limit set",
|
2012-03-03 03:29:37 +01:00
|
|
|
"the disk queue limit is too high compared to the cache size. The disk queue eats into the cache size",
|
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];
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string state_changed_alert::message() const
|
|
|
|
{
|
|
|
|
static char const* state_str[] =
|
|
|
|
{"checking (q)", "checking", "dl metadata"
|
|
|
|
, "downloading", "finished", "seeding", "allocating"
|
|
|
|
, "checking (r)"};
|
|
|
|
|
|
|
|
return torrent_alert::message() + ": state changed to: "
|
|
|
|
+ state_str[state];
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string tracker_error_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
|
|
|
snprintf(ret, sizeof(ret), "%s (%d) %s (%d)"
|
2010-02-18 04:49:22 +01:00
|
|
|
, tracker_alert::message().c_str(), status_code
|
2009-11-26 22:40:10 +01:00
|
|
|
, msg.c_str(), times_in_row);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string tracker_warning_alert::message() const
|
|
|
|
{
|
|
|
|
return tracker_alert::message() + " warning: " + msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string scrape_reply_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
|
|
|
snprintf(ret, sizeof(ret), "%s scrape reply: %u %u"
|
2010-02-18 04:49:22 +01:00
|
|
|
, tracker_alert::message().c_str(), incomplete, complete);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string scrape_failed_alert::message() const
|
|
|
|
{
|
|
|
|
return tracker_alert::message() + " scrape failed: " + msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string tracker_reply_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
|
|
|
snprintf(ret, sizeof(ret), "%s received peers: %u"
|
2010-02-18 04:49:22 +01:00
|
|
|
, tracker_alert::message().c_str(), num_peers);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string dht_reply_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
|
|
|
snprintf(ret, sizeof(ret), "%s received DHT peers: %u"
|
2010-02-18 04:49:22 +01:00
|
|
|
, tracker_alert::message().c_str(), num_peers);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string tracker_announce_alert::message() const
|
|
|
|
{
|
2010-09-25 19:48:51 +02:00
|
|
|
const static char* event_str[] = {"none", "completed", "started", "stopped", "paused"};
|
2011-02-14 02:59:01 +01:00
|
|
|
TORRENT_ASSERT_VAL(event < int(sizeof(event_str)/sizeof(event_str[0])), event);
|
2009-11-26 22:40:10 +01:00
|
|
|
return tracker_alert::message() + " sending announce (" + event_str[event] + ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string hash_failed_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[400];
|
|
|
|
snprintf(ret, sizeof(ret), "%s hash for piece %u failed"
|
|
|
|
, torrent_alert::message().c_str(), piece_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string peer_ban_alert::message() const
|
|
|
|
{
|
|
|
|
return peer_alert::message() + " banned peer";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string peer_unsnubbed_alert::message() const
|
|
|
|
{
|
|
|
|
return peer_alert::message() + " peer unsnubbed";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string peer_snubbed_alert::message() const
|
|
|
|
{
|
|
|
|
return peer_alert::message() + " peer snubbed";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string invalid_request_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s peer sent an invalid piece request (piece: %u start: %u len: %u)"
|
2013-06-04 04:58:32 +02:00
|
|
|
, peer_alert::message().c_str(), request.piece, request.start, request.length);
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string piece_finished_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s piece: %u finished downloading"
|
|
|
|
, torrent_alert::message().c_str(), piece_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string request_dropped_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s peer dropped block ( piece: %u block: %u)"
|
|
|
|
, torrent_alert::message().c_str(), piece_index, block_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string block_timeout_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s peer timed out request ( piece: %u block: %u)"
|
|
|
|
, torrent_alert::message().c_str(), piece_index, block_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string block_finished_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s block finished downloading (piece: %u block: %u)"
|
|
|
|
, torrent_alert::message().c_str(), piece_index, block_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string block_downloading_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s requested block (piece: %u block: %u) %s"
|
|
|
|
, torrent_alert::message().c_str(), piece_index, block_index, peer_speedmsg);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string unwanted_block_alert::message() const
|
|
|
|
{
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "%s received block not in download queue (piece: %u block: %u)"
|
|
|
|
, torrent_alert::message().c_str(), piece_index, block_index);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string listen_failed_alert::message() const
|
|
|
|
{
|
2013-10-06 08:32:33 +02:00
|
|
|
static char const* op_str[] =
|
2013-06-04 02:35:42 +02:00
|
|
|
{
|
|
|
|
"parse_addr",
|
|
|
|
"open",
|
|
|
|
"bind",
|
|
|
|
"listen",
|
|
|
|
"get_peer_name",
|
|
|
|
"accept"
|
|
|
|
};
|
2013-10-06 08:32:33 +02:00
|
|
|
static char const* type_str[] =
|
|
|
|
{
|
|
|
|
"TCP", "TCP/SSL", "UDP", "I2P", "Socks5"
|
|
|
|
};
|
2013-06-04 02:35:42 +02:00
|
|
|
char ret[250];
|
2013-10-06 08:32:33 +02:00
|
|
|
snprintf(ret, sizeof(ret), "listening on %s failed: [%s] [%s] %s"
|
2013-06-04 02:35:42 +02:00
|
|
|
, print_endpoint(endpoint).c_str()
|
|
|
|
, op_str[operation]
|
2013-10-06 08:32:33 +02:00
|
|
|
, type_str[sock_type]
|
2013-06-04 02:35:42 +02:00
|
|
|
, convert_from_native(error.message()).c_str());
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string listen_succeeded_alert::message() const
|
|
|
|
{
|
2013-10-06 08:32:33 +02:00
|
|
|
static char const* type_str[] =
|
|
|
|
{
|
|
|
|
"TCP", "TCP/SSL", "UDP"
|
|
|
|
};
|
2009-11-26 22:40:10 +01:00
|
|
|
char ret[200];
|
2013-10-06 08:32:33 +02:00
|
|
|
snprintf(ret, sizeof(ret), "successfully listening on [%s] %s"
|
|
|
|
, type_str[sock_type], print_endpoint(endpoint).c_str());
|
2009-11-26 22:40:10 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string portmap_error_alert::message() const
|
|
|
|
{
|
|
|
|
static char const* type_str[] = {"NAT-PMP", "UPnP"};
|
|
|
|
return std::string("could not map port using ") + type_str[map_type]
|
2013-01-19 07:39:32 +01:00
|
|
|
+ ": " + convert_from_native(error.message());
|
2009-11-26 22:40:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string portmap_alert::message() const
|
|
|
|
{
|
|
|
|
static char const* type_str[] = {"NAT-PMP", "UPnP"};
|
|
|
|
char ret[200];
|
|
|
|
snprintf(ret, sizeof(ret), "successfully mapped port using %s. external port: %u"
|
|
|
|
, type_str[map_type], external_port);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string portmap_log_alert::message() const
|
|
|
|
{
|
|
|
|
static char const* type_str[] = {"NAT-PMP", "UPnP"};
|
2009-12-25 23:30:18 +01:00
|
|
|
char ret[600];
|
2009-11-26 22:40:10 +01:00
|
|
|
snprintf(ret, sizeof(ret), "%s: %s", type_str[map_type], msg.c_str());
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string dht_announce_alert::message() const
|
|
|
|
{
|
|
|
|
error_code ec;
|
|
|
|
char ih_hex[41];
|
|
|
|
to_hex((const char*)&info_hash[0], 20, ih_hex);
|
|
|
|
char msg[200];
|
|
|
|
snprintf(msg, sizeof(msg), "incoming dht announce: %s:%u (%s)"
|
|
|
|
, ip.to_string(ec).c_str(), port, ih_hex);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string dht_get_peers_alert::message() const
|
|
|
|
{
|
|
|
|
char ih_hex[41];
|
|
|
|
to_hex((const char*)&info_hash[0], 20, ih_hex);
|
|
|
|
char msg[200];
|
|
|
|
snprintf(msg, sizeof(msg), "incoming dht get_peers: %s", ih_hex);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2010-01-02 15:16:35 +01:00
|
|
|
stats_alert::stats_alert(torrent_handle const& h, int in
|
|
|
|
, stat const& s)
|
|
|
|
: torrent_alert(h)
|
|
|
|
, interval(in)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < num_channels; ++i)
|
|
|
|
transferred[i] = s[i].counter();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string stats_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
|
|
|
snprintf(msg, sizeof(msg), "%s: [%d] %d %d %d %d %d %d %d %d %d %d"
|
|
|
|
, torrent_alert::message().c_str()
|
|
|
|
, interval
|
|
|
|
, transferred[0]
|
|
|
|
, transferred[1]
|
|
|
|
, transferred[2]
|
|
|
|
, transferred[3]
|
|
|
|
, transferred[4]
|
|
|
|
, transferred[5]
|
|
|
|
, transferred[6]
|
|
|
|
, transferred[7]
|
|
|
|
, transferred[8]
|
|
|
|
, transferred[9]);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2010-01-09 22:17:52 +01:00
|
|
|
cache_flushed_alert::cache_flushed_alert(torrent_handle const& h): torrent_alert(h) {}
|
|
|
|
|
2010-04-13 06:30:34 +02:00
|
|
|
std::string anonymous_mode_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
|
|
|
char const* msgs[] = {
|
|
|
|
"tracker is not anonymous, set a proxy"
|
|
|
|
};
|
|
|
|
snprintf(msg, sizeof(msg), "%s: %s: %s"
|
|
|
|
, torrent_alert::message().c_str()
|
|
|
|
, msgs[kind], str.c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2010-07-15 07:56:29 +02:00
|
|
|
std::string lsd_peer_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
|
|
|
snprintf(msg, sizeof(msg), "%s: received peer from local service discovery"
|
|
|
|
, peer_alert::message().c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2010-11-18 06:51:52 +01:00
|
|
|
std::string trackerid_alert::message() const
|
|
|
|
{
|
|
|
|
return "trackerid received: " + trackerid;
|
|
|
|
}
|
|
|
|
|
2010-12-12 04:17:08 +01:00
|
|
|
std::string dht_bootstrap_alert::message() const
|
|
|
|
{
|
|
|
|
return "DHT bootstrap complete";
|
|
|
|
}
|
|
|
|
|
2011-01-18 04:41:54 +01:00
|
|
|
std::string rss_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
char const* state_msg[] = {"updating", "updated", "error"};
|
|
|
|
snprintf(msg, sizeof(msg), "RSS feed %s: %s (%s)"
|
2013-01-19 07:39:32 +01:00
|
|
|
, url.c_str(), state_msg[state], convert_from_native(error.message()).c_str());
|
2011-01-18 04:41:54 +01:00
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2011-01-22 20:06:43 +01:00
|
|
|
std::string torrent_error_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
2013-01-19 07:39:32 +01:00
|
|
|
snprintf(msg, sizeof(msg), " ERROR: %s", convert_from_native(error.message()).c_str());
|
2011-01-22 20:06:43 +01:00
|
|
|
return torrent_alert::message() + msg;
|
|
|
|
}
|
2011-02-01 04:25:40 +01:00
|
|
|
|
|
|
|
std::string torrent_added_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " added";
|
|
|
|
}
|
2011-01-22 20:06:43 +01:00
|
|
|
|
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
|
|
|
|
2011-09-12 05:51:49 +02:00
|
|
|
std::string torrent_need_cert_alert::message() const
|
|
|
|
{
|
|
|
|
return torrent_alert::message() + " needs SSL certificate";
|
|
|
|
}
|
|
|
|
|
2013-08-01 02:44:14 +02:00
|
|
|
static char const* type_str[] = {
|
|
|
|
"null",
|
|
|
|
"TCP",
|
|
|
|
"Socks5/TCP",
|
|
|
|
"HTTP",
|
|
|
|
"uTP",
|
|
|
|
"i2p",
|
|
|
|
"SSL/TCP",
|
|
|
|
"SSL/Socks5",
|
|
|
|
"HTTPS",
|
|
|
|
"SSL/uTP"
|
|
|
|
};
|
|
|
|
|
2011-09-17 03:44:05 +02:00
|
|
|
std::string incoming_connection_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
error_code ec;
|
|
|
|
snprintf(msg, sizeof(msg), "incoming connection from %s (%s)"
|
|
|
|
, print_endpoint(ip).c_str(), type_str[socket_type]);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2013-08-01 02:44:14 +02:00
|
|
|
std::string peer_connect_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
error_code ec;
|
|
|
|
snprintf(msg, sizeof(msg), "%s connecting to peer (%s)"
|
|
|
|
, peer_alert::message().c_str(), type_str[socket_type]);
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2011-10-12 12:27:17 +02:00
|
|
|
std::string add_torrent_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
if (error)
|
|
|
|
{
|
2013-01-19 07:39:32 +01:00
|
|
|
snprintf(msg, sizeof(msg), "failed to add torrent: %s"
|
|
|
|
, convert_from_native(error.message()).c_str());
|
2011-10-12 12:27:17 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-08 03:07:10 +01:00
|
|
|
snprintf(msg, sizeof(msg), "added torrent: %s"
|
|
|
|
, !params.url.empty() ? params.url.c_str()
|
|
|
|
: params.ti ? params.ti->name().c_str()
|
|
|
|
: !params.name.empty() ? params.name.c_str()
|
|
|
|
: !params.uuid.empty() ? params.uuid.c_str()
|
|
|
|
: "");
|
2011-10-12 12:27:17 +02:00
|
|
|
}
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2011-11-15 03:34:00 +01:00
|
|
|
std::string state_update_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
snprintf(msg, sizeof(msg), "state updates for %d torrents", int(status.size()));
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2013-05-17 05:19:23 +02:00
|
|
|
std::string torrent_update_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[200];
|
|
|
|
snprintf(msg, sizeof(msg), " torrent changed info-hash from: %s to %s"
|
|
|
|
, to_hex(old_ih.to_string()).c_str()
|
|
|
|
, to_hex(new_ih.to_string()).c_str());
|
|
|
|
return torrent_alert::message() + msg;
|
|
|
|
}
|
|
|
|
|
2013-06-02 04:48:57 +02:00
|
|
|
std::string rss_item_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[500];
|
|
|
|
snprintf(msg, sizeof(msg), "feed [%s] has new RSS item %s"
|
|
|
|
, handle.get_feed_status().title.c_str()
|
|
|
|
, item.title.empty() ? item.url.c_str() : item.title.c_str());
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2013-07-28 17:06:28 +02:00
|
|
|
std::string peer_disconnected_alert::message() const
|
|
|
|
{
|
|
|
|
char msg[600];
|
|
|
|
snprintf(msg, sizeof(msg), "%s disconnecting: [%s] %s", peer_alert::message().c_str()
|
2013-08-08 06:32:54 +02:00
|
|
|
, error.category().name(), convert_from_native(error.message()).c_str());
|
2013-07-28 17:06:28 +02:00
|
|
|
return msg;
|
|
|
|
}
|
2003-11-29 17:34:07 +01:00
|
|
|
} // namespace libtorrent
|
|
|
|
|