diff --git a/Changelog b/Changelog index 364a84cd3..5eb10f8e0 100644 --- a/Changelog +++ b/Changelog @@ -5,6 +5,7 @@ - FEATURE: Added UPnP/NAT-PMP port forward for the Web UI port - FEATURE: qBittorrent can update dynamic DNS services (DynDNS, no-ip) - BUGFIX: Change systray icon on the fly (no restart needed) + - BUGFIX: Remember peer-level rate limits (requires libtorrent v0.16) - COSMETIC: Added monochrome icon for light themes * Sun Mar 20 2011 - Christophe Dumez - v2.7.0 diff --git a/src/properties/peerlistwidget.cpp b/src/properties/peerlistwidget.cpp index c5e8426f4..e540b680f 100644 --- a/src/properties/peerlistwidget.cpp +++ b/src/properties/peerlistwidget.cpp @@ -207,10 +207,18 @@ void PeerListWidget::banSelectedPeers(QStringList peer_ips) { } void PeerListWidget::limitUpRateSelectedPeers(QStringList peer_ips) { + if(peer_ips.empty()) return; QTorrentHandle h = properties->getCurrentTorrent(); if(!h.is_valid()) return; bool ok=false; - long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Upload rate limiting"), -1, Preferences().getGlobalUploadLimit()*1024.); + int cur_limit = -1; +#if LIBTORRENT_VERSION_MINOR > 15 + libtorrent::asio::ip::tcp::endpoint first_ep = peerEndpoints.value(peer_ips.first(), + libtorrent::asio::ip::tcp::endpoint()); + if(first_ep != libtorrent::asio::ip::tcp::endpoint()) + cur_limit = h.get_peer_upload_limit(first_ep); +#endif + long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Upload rate limiting"), cur_limit, Preferences().getGlobalUploadLimit()*1024.); if(!ok) return; foreach(const QString &ip, peer_ips) { libtorrent::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, libtorrent::asio::ip::tcp::endpoint()); @@ -231,7 +239,14 @@ void PeerListWidget::limitDlRateSelectedPeers(QStringList peer_ips) { QTorrentHandle h = properties->getCurrentTorrent(); if(!h.is_valid()) return; bool ok=false; - long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Download rate limiting"), -1, Preferences().getGlobalDownloadLimit()*1024.); + int cur_limit = -1; +#if LIBTORRENT_VERSION_MINOR > 15 + libtorrent::asio::ip::tcp::endpoint first_ep = peerEndpoints.value(peer_ips.first(), + libtorrent::asio::ip::tcp::endpoint()); + if(first_ep != libtorrent::asio::ip::tcp::endpoint()) + cur_limit = h.get_peer_download_limit(first_ep); +#endif + long limit = SpeedLimitDialog::askSpeedLimit(&ok, tr("Download rate limiting"), cur_limit, Preferences().getGlobalDownloadLimit()*1024.); if(!ok) return; foreach(const QString &ip, peer_ips) { libtorrent::asio::ip::tcp::endpoint ep = peerEndpoints.value(ip, libtorrent::asio::ip::tcp::endpoint());