From b3f57ac29355add5f0c4c176050cae67a50b58a8 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Thu, 15 Jul 2010 05:56:29 +0000 Subject: [PATCH] added incoming lsd alert --- ChangeLog | 1 + docs/manual.rst | 14 ++++++++++++++ include/libtorrent/alert_types.hpp | 13 +++++++++++++ src/alert.cpp | 8 ++++++++ src/session_impl.cpp | 2 ++ 5 files changed, 38 insertions(+) diff --git a/ChangeLog b/ChangeLog index 536f07875..447d21dc4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * added alert for incoming local service discovery messages * added option to set file priorities when adding torrents * removed the session mutex for improved performance * added upload and download activity timer stats for torrents diff --git a/docs/manual.rst b/docs/manual.rst index f94fe9a0e..dd0188d1f 100644 --- a/docs/manual.rst +++ b/docs/manual.rst @@ -5875,6 +5875,20 @@ This alert is generated when a block request receives a response. }; +lsd_peer_alert +-------------- + +This alert is generated when we receive a local service discovery message from a peer +for a torrent we're currently participating in. + +:: + + struct lsd_peer_alert: peer_alert + { + // ... + }; + + file_completed_alert -------------------- diff --git a/include/libtorrent/alert_types.hpp b/include/libtorrent/alert_types.hpp index 930354221..6ca9916c2 100644 --- a/include/libtorrent/alert_types.hpp +++ b/include/libtorrent/alert_types.hpp @@ -1154,6 +1154,19 @@ namespace libtorrent std::string str; }; + struct TORRENT_EXPORT lsd_peer_alert: peer_alert + { + lsd_peer_alert(torrent_handle const& h + , tcp::endpoint const& ip_) + : peer_alert(h, ip_, peer_id(0)) + {} + + TORRENT_DEFINE_ALERT(lsd_peer_alert); + + const static int static_category = alert::peer_notification; + virtual std::string message() const; + }; + } diff --git a/src/alert.cpp b/src/alert.cpp index 429914eed..8d36bc049 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -477,5 +477,13 @@ namespace libtorrent { return msg; } + 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; + } + } // namespace libtorrent diff --git a/src/session_impl.cpp b/src/session_impl.cpp index 8582b281f..81dfa5c89 100644 --- a/src/session_impl.cpp +++ b/src/session_impl.cpp @@ -3300,6 +3300,8 @@ namespace aux { << ": added peer from local discovery: " << peer << "\n"; #endif t->get_policy().add_peer(peer, peer_id(0), peer_info::lsd, 0); + if (m_alerts.should_post()) + m_alerts.post_alert(lsd_peer_alert(t->get_handle(), peer)); } void session_impl::on_port_map_log(