summaryrefslogtreecommitdiffstats
path: root/libtorrent-extended/bad_peer_handling.patch
blob: 26d9515708c91ebac15c36355b02f9774c31bdfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
diff --git a/src/download/choke_manager.cc b/src/download/choke_manager.cc
index 4915a96..efda46c 100644
--- a/src/download/choke_manager.cc
+++ b/src/download/choke_manager.cc
@@ -193,7 +193,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 70169ad..6d9b4f9 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();
 
   const HashString&    id() const                         { return peer_info()->id(); }
   const char*          options() const                    { return peer_info()->options(); }
diff --git a/src/torrent/peer/peer_info.h b/src/torrent/peer/peer_info.h
index fe80027..9b17e61 100644
--- a/src/torrent/peer/peer_info.h
+++ b/src/torrent/peer/peer_info.h
@@ -51,6 +51,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);
@@ -79,6 +81,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; }