diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 882cde0f5..59b0d1b53 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -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 diff --git a/src/alert.cpp b/src/alert.cpp index e60451d97..347d64e90 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -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]; diff --git a/src/peer_connection.cpp b/src/peer_connection.cpp index 5483fa179..dc2a01fd7 100644 --- a/src/peer_connection.cpp +++ b/src/peer_connection.cpp @@ -5480,7 +5480,7 @@ namespace libtorrent if (t->alerts().should_post()) { 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());