moved some alert functions from the header to the cpp file
This commit is contained in:
@@ -39,9 +39,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
#include "libtorrent/identify_client.hpp"
|
#include "libtorrent/identify_client.hpp"
|
||||||
#include "libtorrent/socket_io.hpp"
|
//#include "libtorrent/socket_io.hpp"
|
||||||
#include "libtorrent/address.hpp"
|
#include "libtorrent/address.hpp"
|
||||||
#include "libtorrent/escape_string.hpp" // to_hex
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
@@ -51,17 +50,7 @@ namespace libtorrent
|
|||||||
: handle(h)
|
: handle(h)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
if (!handle.is_valid()) return " - ";
|
|
||||||
if (handle.name().empty())
|
|
||||||
{
|
|
||||||
char msg[41];
|
|
||||||
to_hex((char const*)&handle.info_hash()[0], 20, msg);
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
return handle.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
torrent_handle handle;
|
torrent_handle handle;
|
||||||
};
|
};
|
||||||
@@ -77,12 +66,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
const static int static_category = alert::peer_notification;
|
const static int static_category = alert::peer_notification;
|
||||||
virtual int category() const { return static_category; }
|
virtual int category() const { return static_category; }
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
error_code ec;
|
|
||||||
return torrent_alert::message() + " peer (" + ip.address().to_string(ec)
|
|
||||||
+ ", " + identify_client(pid) + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
tcp::endpoint ip;
|
tcp::endpoint ip;
|
||||||
peer_id pid;
|
peer_id pid;
|
||||||
@@ -98,10 +82,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
const static int static_category = alert::tracker_notification;
|
const static int static_category = alert::tracker_notification;
|
||||||
virtual int category() const { return static_category; }
|
virtual int category() const { return static_category; }
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
return torrent_alert::message() + " (" + url + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string url;
|
std::string url;
|
||||||
};
|
};
|
||||||
@@ -127,13 +108,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(read_piece_alert);
|
TORRENT_DEFINE_ALERT(read_piece_alert);
|
||||||
|
|
||||||
const static int static_category = alert::storage_notification;
|
const static int static_category = alert::storage_notification;
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char msg[200];
|
|
||||||
snprintf(msg, sizeof(msg), "%s: piece %s %u", torrent_alert::message().c_str()
|
|
||||||
, buffer ? "successful" : "failed", piece);
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::shared_array<char> buffer;
|
boost::shared_array<char> buffer;
|
||||||
int piece;
|
int piece;
|
||||||
@@ -151,13 +126,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(file_completed_alert);
|
TORRENT_DEFINE_ALERT(file_completed_alert);
|
||||||
|
|
||||||
const static int static_category = alert::progress_notification;
|
const static int static_category = alert::progress_notification;
|
||||||
virtual std::string message() const
|
virtual std::string 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
@@ -175,13 +144,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(file_renamed_alert);
|
TORRENT_DEFINE_ALERT(file_renamed_alert);
|
||||||
|
|
||||||
const static int static_category = alert::storage_notification;
|
const static int static_category = alert::storage_notification;
|
||||||
virtual std::string message() const
|
virtual std::string 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 name;
|
std::string name;
|
||||||
int index;
|
int index;
|
||||||
@@ -201,13 +164,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
const static int static_category = alert::storage_notification;
|
const static int static_category = alert::storage_notification;
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char ret[200 + TORRENT_MAX_PATH * 2];
|
|
||||||
snprintf(ret, sizeof(ret), "%s: failed to rename file %d: %s"
|
|
||||||
, torrent_alert::message().c_str(), index, error.message().c_str());
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int index;
|
int index;
|
||||||
error_code error;
|
error_code error;
|
||||||
@@ -234,20 +191,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
const static int static_category = alert::performance_warning;
|
const static int static_category = alert::performance_warning;
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string 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)",
|
|
||||||
"send buffer watermark too low (upload rate will suffer)"
|
|
||||||
};
|
|
||||||
|
|
||||||
return torrent_alert::message() + ": performance warning: "
|
|
||||||
+ warning_str[warning_code];
|
|
||||||
}
|
|
||||||
|
|
||||||
performance_warning_t warning_code;
|
performance_warning_t warning_code;
|
||||||
};
|
};
|
||||||
@@ -266,16 +210,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
const static int static_category = alert::status_notification;
|
const static int static_category = alert::status_notification;
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string 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];
|
|
||||||
}
|
|
||||||
|
|
||||||
torrent_status::state_t state;
|
torrent_status::state_t state;
|
||||||
torrent_status::state_t prev_state;
|
torrent_status::state_t prev_state;
|
||||||
@@ -312,14 +247,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(tracker_error_alert);
|
TORRENT_DEFINE_ALERT(tracker_error_alert);
|
||||||
|
|
||||||
const static int static_category = alert::tracker_notification | alert::error_notification;
|
const static int static_category = alert::tracker_notification | alert::error_notification;
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char ret[400];
|
|
||||||
snprintf(ret, sizeof(ret), "%s (%d) %s (%d)"
|
|
||||||
, torrent_alert::message().c_str(), status_code
|
|
||||||
, msg.c_str(), times_in_row);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int times_in_row;
|
int times_in_row;
|
||||||
int status_code;
|
int status_code;
|
||||||
@@ -338,10 +266,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(tracker_warning_alert);
|
TORRENT_DEFINE_ALERT(tracker_warning_alert);
|
||||||
|
|
||||||
const static int static_category = alert::tracker_notification | alert::error_notification;
|
const static int static_category = alert::tracker_notification | alert::error_notification;
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
return tracker_alert::message() + " warning: " + msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string msg;
|
std::string msg;
|
||||||
};
|
};
|
||||||
@@ -359,13 +284,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
TORRENT_DEFINE_ALERT(scrape_reply_alert);
|
TORRENT_DEFINE_ALERT(scrape_reply_alert);
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char ret[400];
|
|
||||||
snprintf(ret, sizeof(ret), "%s scrape reply: %u %u"
|
|
||||||
, torrent_alert::message().c_str(), incomplete, complete);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int incomplete;
|
int incomplete;
|
||||||
int complete;
|
int complete;
|
||||||
@@ -390,8 +309,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(scrape_failed_alert);
|
TORRENT_DEFINE_ALERT(scrape_failed_alert);
|
||||||
|
|
||||||
const static int static_category = alert::tracker_notification | alert::error_notification;
|
const static int static_category = alert::tracker_notification | alert::error_notification;
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{ return tracker_alert::message() + " scrape failed: " + msg; }
|
|
||||||
|
|
||||||
std::string msg;
|
std::string msg;
|
||||||
};
|
};
|
||||||
@@ -407,13 +325,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
TORRENT_DEFINE_ALERT(tracker_reply_alert);
|
TORRENT_DEFINE_ALERT(tracker_reply_alert);
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char ret[400];
|
|
||||||
snprintf(ret, sizeof(ret), "%s received peers: %u"
|
|
||||||
, torrent_alert::message().c_str(), num_peers);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int num_peers;
|
int num_peers;
|
||||||
};
|
};
|
||||||
@@ -428,13 +340,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
TORRENT_DEFINE_ALERT(dht_reply_alert);
|
TORRENT_DEFINE_ALERT(dht_reply_alert);
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char ret[400];
|
|
||||||
snprintf(ret, sizeof(ret), "%s received DHT peers: %u"
|
|
||||||
, torrent_alert::message().c_str(), num_peers);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int num_peers;
|
int num_peers;
|
||||||
};
|
};
|
||||||
@@ -449,11 +355,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
TORRENT_DEFINE_ALERT(tracker_announce_alert);
|
TORRENT_DEFINE_ALERT(tracker_announce_alert);
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
const static char* event_str[] = {"none", "completed", "started", "stopped"};
|
|
||||||
return tracker_alert::message() + " sending announce (" + event_str[event] + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
int event;
|
int event;
|
||||||
};
|
};
|
||||||
@@ -470,13 +372,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(hash_failed_alert);
|
TORRENT_DEFINE_ALERT(hash_failed_alert);
|
||||||
|
|
||||||
const static int static_category = alert::status_notification;
|
const static int static_category = alert::status_notification;
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char ret[400];
|
|
||||||
snprintf(ret, sizeof(ret), "%s hash for piece %u failed"
|
|
||||||
, torrent_alert::message().c_str(), piece_index);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int piece_index;
|
int piece_index;
|
||||||
};
|
};
|
||||||
@@ -490,8 +386,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
TORRENT_DEFINE_ALERT(peer_ban_alert);
|
TORRENT_DEFINE_ALERT(peer_ban_alert);
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{ return peer_alert::message() + " banned peer"; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TORRENT_EXPORT peer_unsnubbed_alert: peer_alert
|
struct TORRENT_EXPORT peer_unsnubbed_alert: peer_alert
|
||||||
@@ -503,8 +398,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
TORRENT_DEFINE_ALERT(peer_unsnubbed_alert);
|
TORRENT_DEFINE_ALERT(peer_unsnubbed_alert);
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{ return peer_alert::message() + " peer unsnubbed"; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TORRENT_EXPORT peer_snubbed_alert: peer_alert
|
struct TORRENT_EXPORT peer_snubbed_alert: peer_alert
|
||||||
@@ -516,8 +410,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
TORRENT_DEFINE_ALERT(peer_snubbed_alert);
|
TORRENT_DEFINE_ALERT(peer_snubbed_alert);
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{ return peer_alert::message() + " peer snubbed"; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TORRENT_EXPORT peer_error_alert: peer_alert
|
struct TORRENT_EXPORT peer_error_alert: peer_alert
|
||||||
@@ -597,13 +490,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
TORRENT_DEFINE_ALERT(invalid_request_alert);
|
TORRENT_DEFINE_ALERT(invalid_request_alert);
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char ret[200];
|
|
||||||
snprintf(ret, sizeof(ret), "%s peer sent an invalid piece request (piece: %u start: %u len: %u)"
|
|
||||||
, torrent_alert::message().c_str(), request.piece, request.start, request.length);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
peer_request request;
|
peer_request request;
|
||||||
};
|
};
|
||||||
@@ -634,13 +521,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(piece_finished_alert);
|
TORRENT_DEFINE_ALERT(piece_finished_alert);
|
||||||
|
|
||||||
const static int static_category = alert::progress_notification;
|
const static int static_category = alert::progress_notification;
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char ret[200];
|
|
||||||
snprintf(ret, sizeof(ret), "%s piece: %u finished downloading"
|
|
||||||
, torrent_alert::message().c_str(), piece_index);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int piece_index;
|
int piece_index;
|
||||||
};
|
};
|
||||||
@@ -658,13 +539,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
const static int static_category = alert::progress_notification
|
const static int static_category = alert::progress_notification
|
||||||
| alert::peer_notification;
|
| alert::peer_notification;
|
||||||
virtual std::string message() const
|
virtual std::string 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int block_index;
|
int block_index;
|
||||||
int piece_index;
|
int piece_index;
|
||||||
@@ -683,13 +558,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
const static int static_category = alert::progress_notification
|
const static int static_category = alert::progress_notification
|
||||||
| alert::peer_notification;
|
| alert::peer_notification;
|
||||||
virtual std::string message() const
|
virtual std::string 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int block_index;
|
int block_index;
|
||||||
int piece_index;
|
int piece_index;
|
||||||
@@ -707,13 +576,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(block_finished_alert);
|
TORRENT_DEFINE_ALERT(block_finished_alert);
|
||||||
|
|
||||||
const static int static_category = alert::progress_notification;
|
const static int static_category = alert::progress_notification;
|
||||||
virtual std::string message() const
|
virtual std::string 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int block_index;
|
int block_index;
|
||||||
int piece_index;
|
int piece_index;
|
||||||
@@ -732,13 +595,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(block_downloading_alert);
|
TORRENT_DEFINE_ALERT(block_downloading_alert);
|
||||||
|
|
||||||
const static int static_category = alert::progress_notification;
|
const static int static_category = alert::progress_notification;
|
||||||
virtual std::string message() const
|
virtual std::string 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
char const* peer_speedmsg;
|
char const* peer_speedmsg;
|
||||||
int block_index;
|
int block_index;
|
||||||
@@ -756,13 +613,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
TORRENT_DEFINE_ALERT(unwanted_block_alert);
|
TORRENT_DEFINE_ALERT(unwanted_block_alert);
|
||||||
|
|
||||||
virtual std::string message() const
|
virtual std::string 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int block_index;
|
int block_index;
|
||||||
int piece_index;
|
int piece_index;
|
||||||
@@ -1077,13 +928,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(listen_failed_alert);
|
TORRENT_DEFINE_ALERT(listen_failed_alert);
|
||||||
|
|
||||||
const static int static_category = alert::status_notification | alert::error_notification;
|
const static int static_category = alert::status_notification | alert::error_notification;
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char ret[200];
|
|
||||||
snprintf(ret, sizeof(ret), "listening on %s failed: %s"
|
|
||||||
, print_endpoint(endpoint).c_str(), error.message().c_str());
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
tcp::endpoint endpoint;
|
tcp::endpoint endpoint;
|
||||||
error_code error;
|
error_code error;
|
||||||
@@ -1098,12 +943,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(listen_succeeded_alert);
|
TORRENT_DEFINE_ALERT(listen_succeeded_alert);
|
||||||
|
|
||||||
const static int static_category = alert::status_notification;
|
const static int static_category = alert::status_notification;
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
char ret[200];
|
|
||||||
snprintf(ret, sizeof(ret), "successfully listening on %s", print_endpoint(endpoint).c_str());
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
tcp::endpoint endpoint;
|
tcp::endpoint endpoint;
|
||||||
};
|
};
|
||||||
@@ -1122,12 +962,7 @@ namespace libtorrent
|
|||||||
|
|
||||||
const static int static_category = alert::port_mapping_notification
|
const static int static_category = alert::port_mapping_notification
|
||||||
| alert::error_notification;
|
| alert::error_notification;
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
static char const* type_str[] = {"NAT-PMP", "UPnP"};
|
|
||||||
return std::string("could not map port using ") + type_str[map_type]
|
|
||||||
+ ": " + error.message();
|
|
||||||
}
|
|
||||||
|
|
||||||
int mapping;
|
int mapping;
|
||||||
int map_type;
|
int map_type;
|
||||||
@@ -1146,14 +981,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(portmap_alert);
|
TORRENT_DEFINE_ALERT(portmap_alert);
|
||||||
|
|
||||||
const static int static_category = alert::port_mapping_notification;
|
const static int static_category = alert::port_mapping_notification;
|
||||||
virtual std::string message() const
|
virtual std::string 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
int mapping;
|
int mapping;
|
||||||
int external_port;
|
int external_port;
|
||||||
@@ -1169,13 +997,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(portmap_log_alert);
|
TORRENT_DEFINE_ALERT(portmap_log_alert);
|
||||||
|
|
||||||
const static int static_category = alert::port_mapping_notification;
|
const static int static_category = alert::port_mapping_notification;
|
||||||
virtual std::string message() const
|
virtual std::string message() const;
|
||||||
{
|
|
||||||
static char const* type_str[] = {"NAT-PMP", "UPnP"};
|
|
||||||
char ret[200];
|
|
||||||
snprintf(ret, sizeof(ret), "%s: %s", type_str[map_type], msg.c_str());
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
int map_type;
|
int map_type;
|
||||||
std::string msg;
|
std::string msg;
|
||||||
@@ -1238,16 +1060,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(dht_announce_alert);
|
TORRENT_DEFINE_ALERT(dht_announce_alert);
|
||||||
|
|
||||||
const static int static_category = alert::dht_notification;
|
const static int static_category = alert::dht_notification;
|
||||||
virtual std::string message() const
|
virtual std::string 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
address ip;
|
address ip;
|
||||||
int port;
|
int port;
|
||||||
@@ -1263,14 +1076,7 @@ namespace libtorrent
|
|||||||
TORRENT_DEFINE_ALERT(dht_get_peers_alert);
|
TORRENT_DEFINE_ALERT(dht_get_peers_alert);
|
||||||
|
|
||||||
const static int static_category = alert::dht_notification;
|
const static int static_category = alert::dht_notification;
|
||||||
virtual std::string message() const
|
virtual std::string 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
sha1_hash info_hash;
|
sha1_hash info_hash;
|
||||||
};
|
};
|
||||||
|
278
src/alert.cpp
278
src/alert.cpp
@@ -33,7 +33,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "libtorrent/pch.hpp"
|
#include "libtorrent/pch.hpp"
|
||||||
|
|
||||||
#include "libtorrent/alert.hpp"
|
#include "libtorrent/alert.hpp"
|
||||||
|
#include "libtorrent/alert_types.hpp"
|
||||||
#include "libtorrent/io_service.hpp"
|
#include "libtorrent/io_service.hpp"
|
||||||
|
#include "libtorrent/socket_io.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/time.hpp"
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
@@ -43,6 +45,282 @@ namespace libtorrent {
|
|||||||
alert::~alert() {}
|
alert::~alert() {}
|
||||||
ptime alert::timestamp() const { return m_timestamp; }
|
ptime alert::timestamp() const { return m_timestamp; }
|
||||||
|
|
||||||
|
|
||||||
|
std::string torrent_alert::message() const
|
||||||
|
{
|
||||||
|
if (!handle.is_valid()) return " - ";
|
||||||
|
if (handle.name().empty())
|
||||||
|
{
|
||||||
|
char msg[41];
|
||||||
|
to_hex((char const*)&handle.info_hash()[0], 20, msg);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
return handle.name();
|
||||||
|
}
|
||||||
|
|
||||||
|
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];
|
||||||
|
snprintf(msg, sizeof(msg), "%s: piece %s %u", torrent_alert::message().c_str()
|
||||||
|
, buffer ? "successful" : "failed", piece);
|
||||||
|
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"
|
||||||
|
, torrent_alert::message().c_str(), index, error.message().c_str());
|
||||||
|
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)",
|
||||||
|
"send buffer watermark too low (upload rate will suffer)"
|
||||||
|
};
|
||||||
|
|
||||||
|
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)"
|
||||||
|
, torrent_alert::message().c_str(), status_code
|
||||||
|
, 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"
|
||||||
|
, torrent_alert::message().c_str(), incomplete, complete);
|
||||||
|
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"
|
||||||
|
, torrent_alert::message().c_str(), num_peers);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string dht_reply_alert::message() const
|
||||||
|
{
|
||||||
|
char ret[400];
|
||||||
|
snprintf(ret, sizeof(ret), "%s received DHT peers: %u"
|
||||||
|
, torrent_alert::message().c_str(), num_peers);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string tracker_announce_alert::message() const
|
||||||
|
{
|
||||||
|
const static char* event_str[] = {"none", "completed", "started", "stopped"};
|
||||||
|
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)"
|
||||||
|
, torrent_alert::message().c_str(), request.piece, request.start, request.length);
|
||||||
|
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
|
||||||
|
{
|
||||||
|
char ret[200];
|
||||||
|
snprintf(ret, sizeof(ret), "listening on %s failed: %s"
|
||||||
|
, print_endpoint(endpoint).c_str(), error.message().c_str());
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string listen_succeeded_alert::message() const
|
||||||
|
{
|
||||||
|
char ret[200];
|
||||||
|
snprintf(ret, sizeof(ret), "successfully listening on %s", print_endpoint(endpoint).c_str());
|
||||||
|
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]
|
||||||
|
+ ": " + error.message();
|
||||||
|
}
|
||||||
|
|
||||||
|
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"};
|
||||||
|
char ret[200];
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
alert_manager::alert_manager(io_service& ios)
|
alert_manager::alert_manager(io_service& ios)
|
||||||
: m_alert_mask(alert::error_notification)
|
: m_alert_mask(alert::error_notification)
|
||||||
, m_queue_size_limit(queue_size_limit_default)
|
, m_queue_size_limit(queue_size_limit_default)
|
||||||
|
Reference in New Issue
Block a user