forked from premiere/premiere-libtorrent
improve peer_connect_alert
This commit is contained in:
parent
86ce8fbb0a
commit
e1c4101817
|
@ -497,15 +497,17 @@ namespace libtorrent
|
|||
struct TORRENT_EXPORT peer_connect_alert: peer_alert
|
||||
{
|
||||
peer_connect_alert(torrent_handle h, tcp::endpoint const& ep
|
||||
, peer_id const& peer_id)
|
||||
, peer_id const& peer_id, int type)
|
||||
: peer_alert(h, ep, peer_id)
|
||||
, socket_type(type)
|
||||
{}
|
||||
|
||||
TORRENT_DEFINE_ALERT(peer_connect_alert);
|
||||
|
||||
const static int static_category = alert::debug_notification;
|
||||
virtual std::string message() const
|
||||
{ return peer_alert::message() + " connecting to peer"; }
|
||||
virtual std::string message() const;;
|
||||
|
||||
int socket_type;
|
||||
};
|
||||
|
||||
struct TORRENT_EXPORT peer_disconnected_alert: peer_alert
|
||||
|
|
|
@ -442,27 +442,37 @@ namespace libtorrent {
|
|||
return torrent_alert::message() + " needs SSL certificate";
|
||||
}
|
||||
|
||||
static char const* type_str[] = {
|
||||
"null",
|
||||
"TCP",
|
||||
"Socks5/TCP",
|
||||
"HTTP",
|
||||
"uTP",
|
||||
"i2p",
|
||||
"SSL/TCP",
|
||||
"SSL/Socks5",
|
||||
"HTTPS",
|
||||
"SSL/uTP"
|
||||
};
|
||||
|
||||
std::string incoming_connection_alert::message() const
|
||||
{
|
||||
char msg[600];
|
||||
char const* type_str[] = {
|
||||
"null",
|
||||
"TCP",
|
||||
"Socks5/TCP",
|
||||
"HTTP",
|
||||
"uTP",
|
||||
"i2p",
|
||||
"SSL/TCP",
|
||||
"SSL/Socks5",
|
||||
"HTTPS",
|
||||
"SSL/uTP"
|
||||
};
|
||||
error_code ec;
|
||||
snprintf(msg, sizeof(msg), "incoming connection from %s (%s)"
|
||||
, print_endpoint(ip).c_str(), type_str[socket_type]);
|
||||
return msg;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
std::string add_torrent_alert::message() const
|
||||
{
|
||||
char msg[600];
|
||||
|
|
|
@ -5480,7 +5480,7 @@ namespace libtorrent
|
|||
if (t->alerts().should_post<peer_connect_alert>())
|
||||
{
|
||||
t->alerts().post_alert(peer_connect_alert(
|
||||
t->get_handle(), remote(), pid()));
|
||||
t->get_handle(), remote(), pid(), m_socket->type()));
|
||||
}
|
||||
#if defined TORRENT_VERBOSE_LOGGING
|
||||
peer_log("*** LOCAL ENDPOINT[ e: %s ]", print_endpoint(m_socket->local_endpoint(ec)).c_str());
|
||||
|
|
Loading…
Reference in New Issue