diff --git a/src/qtlibtorrent/qbtsession.cpp b/src/qtlibtorrent/qbtsession.cpp
index 72e5576cf..74d17a99a 100755
--- a/src/qtlibtorrent/qbtsession.cpp
+++ b/src/qtlibtorrent/qbtsession.cpp
@@ -1725,17 +1725,26 @@ void QBtSession::addConsoleMessage(QString msg, QColor color) {
#endif
}
-void QBtSession::addPeerBanMessage(QString ip, bool from_ipfilter) {
- if (peerBanMessages.size() > MAX_LOG_MESSAGES) {
- peerBanMessages.removeFirst();
- }
- QString msg;
- if (from_ipfilter)
- msg = "" + QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + " - " + tr("%1 was blocked", "x.y.z.w was blocked").arg(ip);
- else
- msg = "" + QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + " - " + tr("%1 was banned", "x.y.z.w was banned").arg(ip);
- peerBanMessages.append(msg);
- emit newBanMessage(msg);
+#if LIBTORRENT_VERSION_NUM < 10000
+void QBtSession::addPeerBanMessage(const QString& ip, bool blocked)
+#else
+void QBtSession::addPeerBanMessage(const QString& ip, bool blocked, const QString& blockedReason)
+#endif
+{
+ if (peerBanMessages.size() > MAX_LOG_MESSAGES) {
+ peerBanMessages.removeFirst();
+ }
+ QString msg;
+ if (blocked)
+#if LIBTORRENT_VERSION_NUM < 10000
+ msg = "" + QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + " - " + tr("%1 was blocked", "x.y.z.w was blocked").arg(ip);
+#else
+ msg = "" + QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + " - " + tr("%1 was blocked %2", "x.y.z.w was blocked").arg(ip).arg(blockedReason);
+#endif
+ else
+ msg = "" + QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + " - " + tr("%1 was banned", "x.y.z.w was banned").arg(ip);
+ peerBanMessages.append(msg);
+ emit newBanMessage(msg);
}
bool QBtSession::isFilePreviewPossible(const QString &hash) const {
@@ -2616,13 +2625,38 @@ void QBtSession::handlePortmapAlert(libtorrent::portmap_alert* p) {
//emit UPnPSuccess(QString(p->msg().c_str()));
}
-void QBtSession::handlePeerBlockedAlert(libtorrent::peer_blocked_alert* p) {
- boost::system::error_code ec;
- string ip = p->ip.to_string(ec);
- if (!ec) {
- addPeerBanMessage(QString::fromLatin1(ip.c_str()), true);
- //emit peerBlocked(QString::fromLatin1(ip.c_str()));
- }
+void QBtSession::handlePeerBlockedAlert(libtorrent::peer_blocked_alert* p)
+{
+ boost::system::error_code ec;
+ string ip = p->ip.to_string(ec);
+ QString reason;
+ switch (p->reason) {
+ case peer_blocked_alert::ip_filter:
+ reason = tr("due to IP filter.", "this peer was blocked due to ip filter.");
+ break;
+ case peer_blocked_alert::port_filter:
+ reason = tr("due to port filter.", "this peer was blocked due to port filter.");
+ break;
+ case peer_blocked_alert::i2p_mixed:
+ reason = tr("due to i2p mixed mode restrictions.", "this peer was blocked due to i2p mixed mode restrictions.");
+ break;
+ case peer_blocked_alert::privileged_ports:
+ reason = tr("because it has a low port.", "this peer was blocked because it has a low port.");
+ break;
+ case peer_blocked_alert::utp_disabled:
+ reason = tr("because μTP is disabled.", "this peer was blocked because μTP is disabled.");
+ break;
+ case peer_blocked_alert::tcp_disabled:
+ reason = tr("because TCP is disabled.", "this peer was blocked because TCP is disabled.");
+ break;
+ }
+
+ if (!ec)
+#if LIBTORRENT_VERSION_NUM < 10000
+ addPeerBanMessage(QString::fromLatin1(ip.c_str()), true);
+#else
+ addPeerBanMessage(QString::fromLatin1(ip.c_str()), true, reason);
+#endif
}
void QBtSession::handlePeerBanAlert(libtorrent::peer_ban_alert* p) {
diff --git a/src/qtlibtorrent/qbtsession.h b/src/qtlibtorrent/qbtsession.h
index c1eec4cc3..de45f9f41 100755
--- a/src/qtlibtorrent/qbtsession.h
+++ b/src/qtlibtorrent/qbtsession.h
@@ -204,7 +204,11 @@ public slots:
#else
void addConsoleMessage(QString msg, QColor color=QApplication::palette().color(QPalette::WindowText));
#endif
- void addPeerBanMessage(QString msg, bool from_ipfilter);
+#if LIBTORRENT_VERSION_NUM < 10000
+ void addPeerBanMessage(const QString &msg, bool blocked);
+#else
+ void addPeerBanMessage(const QString &msg, bool blocked, const QString &blockedReason = QString());
+#endif
void clearConsoleMessages() { consoleMessages.clear(); }
void clearPeerBanMessages() { peerBanMessages.clear(); }
void processDownloadedFile(QString, QString);