diff --git a/src/peerlistwidget.cpp b/src/peerlistwidget.cpp index ddada3978..88944f5e2 100644 --- a/src/peerlistwidget.cpp +++ b/src/peerlistwidget.cpp @@ -187,8 +187,8 @@ void PeerListWidget::showPeerListMenu(QPoint) { void PeerListWidget::banSelectedPeers(QStringList peer_ips) { // Confirm first int ret = QMessageBox::question(this, tr("Are you sure? -- qBittorrent"), tr("Are you sure you want to ban permanently the selected peers?"), - tr("&Yes"), tr("&No"), - QString(), 0, 1); + tr("&Yes"), tr("&No"), + QString(), 0, 1); if(ret) return; foreach(const QString &ip, peer_ips) { qDebug("Banning peer %s...", ip.toLocal8Bit().data()); @@ -313,7 +313,8 @@ void PeerListWidget::loadPeers(const QTorrentHandle &h, bool force_hostname_reso if(host.isNull()) { resolver->resolve(peer.ip); } else { - peerItems.value(peer_ip)->setData(host); + qDebug("Got peer IP from cache"); + handleResolved(peer_ip, host); } } } @@ -394,6 +395,8 @@ void PeerListWidget::updatePeer(QString ip, peer_info peer) { void PeerListWidget::handleResolved(QString ip, QString hostname) { QStandardItem *item = peerItems.value(ip, 0); if(item) { + qDebug("Resolved %s -> %s", qPrintable(ip), qPrintable(hostname)); item->setData(hostname); + //listModel->setData(listModel->index(item->row(), IP), hostname); } } diff --git a/src/reverseresolution.h b/src/reverseresolution.h index 083d1bec7..783596708 100644 --- a/src/reverseresolution.h +++ b/src/reverseresolution.h @@ -83,10 +83,16 @@ signals: protected: void run() { try { - libtorrent::asio::ip::tcp::resolver::iterator it = resolver.resolve(ip); - if(stopped) return; - libtorrent::asio::ip::tcp::endpoint endpoint = *it; - emit ip_resolved(misc::toQString(endpoint.address().to_string()), misc::toQString((*it).host_name())); + boost::system::error_code ec; + libtorrent::asio::ip::tcp::resolver::iterator it = resolver.resolve(ip, ec); + if(ec || stopped) return; + const std::string ip_str = ip.address().to_string(ec); + if(ec) return; + const QString host_name = misc::toQString(it->host_name()); + const QString ip_qstr = misc::toQString(ip_str); + if(host_name != ip_qstr) { + emit ip_resolved(ip_qstr, host_name); + } } catch(std::exception/* &e*/) { /*std::cerr << "Hostname resolution failed, reason: " << e.what() << std::endl;*/ std::cerr << "Hostname resolution error." << std::endl;