summaryrefslogtreecommitdiff
path: root/pcr/libtorrent-extended/ex_bad_peer_handling.patch
diff options
context:
space:
mode:
authorAurelien Desbrieres <aurelien@hackers.camp>2014-12-19 18:50:17 +0100
committerAurelien Desbrieres <aurelien@hackers.camp>2014-12-19 18:50:17 +0100
commit13e56ca02d4250b037853953afca493eb7d40bb2 (patch)
treec704bffb090e3a57b2c6d84d0c6d91a1b0976b3b /pcr/libtorrent-extended/ex_bad_peer_handling.patch
parent5a9d7f349389ea70e03d430b46186ddda98f68a8 (diff)
downloadabslibre-13e56ca02d4250b037853953afca493eb7d40bb2.tar.gz
abslibre-13e56ca02d4250b037853953afca493eb7d40bb2.tar.bz2
abslibre-13e56ca02d4250b037853953afca493eb7d40bb2.zip
BitTorrent library written in C++ with eXtended patches.
Diffstat (limited to 'pcr/libtorrent-extended/ex_bad_peer_handling.patch')
-rw-r--r--pcr/libtorrent-extended/ex_bad_peer_handling.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/pcr/libtorrent-extended/ex_bad_peer_handling.patch b/pcr/libtorrent-extended/ex_bad_peer_handling.patch
new file mode 100644
index 000000000..4285fa1ea
--- /dev/null
+++ b/pcr/libtorrent-extended/ex_bad_peer_handling.patch
@@ -0,0 +1,67 @@
+diff --git a/src/download/choke_manager.cc b/src/download/choke_manager.cc
+index 3c422c0..17f4010 100644
+--- a/src/download/choke_manager.cc
++++ b/src/download/choke_manager.cc
+@@ -200,7 +200,8 @@ ChokeManager::set_snubbed(PeerConnectionBase* pc, ChokeManagerNode* base) {
+ choke_manager_erase(&m_queued, pc);
+ }
+
+- base->set_queued(false);
++ //breaks unsnubbing, ticket #989:
++ //base->set_queued(false);
+ }
+
+ void
+diff --git a/src/torrent/peer/peer.cc b/src/torrent/peer/peer.cc
+index 3f29f82..a15a7b2 100644
+--- a/src/torrent/peer/peer.cc
++++ b/src/torrent/peer/peer.cc
+@@ -63,7 +63,8 @@ bool Peer::is_down_interested() const { return c_ptr()->is_up_interested();
+
+ bool Peer::is_snubbed() const { return c_ptr()->is_up_snubbed(); }
+ void Peer::set_snubbed(bool v) { m_ptr()->set_upload_snubbed(v); }
+-void Peer::set_banned() { m_peerInfo->set_failed_counter(64); }
++void Peer::set_banned() { m_peerInfo->set_banned(); }
++void Peer::set_unbanned() { m_peerInfo->set_unbanned(); }
+
+ const Rate* Peer::down_rate() const { return c_ptr()->c_peer_chunks()->download_throttle()->rate(); }
+ const Rate* Peer::up_rate() const { return c_ptr()->c_peer_chunks()->upload_throttle()->rate(); }
+diff --git a/src/torrent/peer/peer.h b/src/torrent/peer/peer.h
+index 13e2880..e03bda4 100644
+--- a/src/torrent/peer/peer.h
++++ b/src/torrent/peer/peer.h
+@@ -69,7 +69,10 @@ public:
+
+ bool is_snubbed() const;
+ void set_snubbed(bool v);
++
++ bool is_banned() const { return peer_info()->is_banned(); }
+ void set_banned();
++ void set_unbanned();
+
+ bool is_friend() const { return peer_info()->is_friend(); }
+
+diff --git a/src/torrent/peer/peer_info.h b/src/torrent/peer/peer_info.h
+index 8f56f73..5a6fe22 100644
+--- a/src/torrent/peer/peer_info.h
++++ b/src/torrent/peer/peer_info.h
+@@ -55,6 +55,8 @@ public:
+ friend class PeerList;
+ friend class ProtocolExtension;
+
++ static const unsigned int banned_mask = 4096;
++
+ static const int flag_connected = (1 << 0);
+ static const int flag_incoming = (1 << 1);
+ static const int flag_handshake = (1 << 2);
+@@ -88,6 +90,10 @@ public:
+ uint32_t failed_counter() const { return m_failedCounter; }
+ void set_failed_counter(uint32_t c) { m_failedCounter = c; }
+
++ bool is_banned() const { return m_failedCounter & banned_mask; }
++ void set_banned() { m_failedCounter |= banned_mask; }
++ void set_unbanned() { m_failedCounter &= ~banned_mask; }
++
+ uint32_t transfer_counter() const { return m_transferCounter; }
+ void set_transfer_counter(uint32_t c) { m_transferCounter = c; }
+