[Debtorrent-commits] r59 - in /debtorrent/trunk/DebTorrent/BT1: Connecter.py Encrypter.py Rerequester.py

camrdale-guest at users.alioth.debian.org camrdale-guest at users.alioth.debian.org
Wed May 23 05:22:55 UTC 2007


Author: camrdale-guest
Date: Wed May 23 05:22:54 2007
New Revision: 59

URL: http://svn.debian.org/wsvn/debtorrent/?sc=1&rev=59
Log:
More debug messages to help with connection problems.

Modified:
    debtorrent/trunk/DebTorrent/BT1/Connecter.py
    debtorrent/trunk/DebTorrent/BT1/Encrypter.py
    debtorrent/trunk/DebTorrent/BT1/Rerequester.py

Modified: debtorrent/trunk/DebTorrent/BT1/Connecter.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/Connecter.py?rev=59&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/Connecter.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/Connecter.py Wed May 23 05:22:54 2007
@@ -165,7 +165,7 @@
     def close(self):
         """Close the connection."""
         if DEBUG1:
-            print (self.ccount,'connection closed')
+            print (self.get_ip(),'connection closed')
         self.connection.close()
 
     def is_locally_initiated(self):
@@ -210,7 +210,7 @@
         if self.send_choke_queued:
             self.send_choke_queued = False
             if DEBUG1:
-                print (self.ccount,'CHOKE SUPPRESSED')
+                print (self.get_ip(),'CHOKE SUPPRESSED')
         else:
             self._send_message(UNCHOKE)
             if ( self.partial_message or self.just_unchoked is None
@@ -234,7 +234,7 @@
         self._send_message(REQUEST + tobinary(index) + 
             tobinary(begin) + tobinary(length))
         if DEBUG1:
-            print (self.ccount,'sent request',index,begin,begin+length)
+            print (self.get_ip(),'sent request',index,begin,begin+length)
 
     def send_cancel(self, index, begin, length):
         """Send the L{CANCEL} message.
@@ -253,7 +253,7 @@
         self._send_message(CANCEL + tobinary(index) + 
             tobinary(begin) + tobinary(length))
         if DEBUG1:
-            print (self.ccount,'sent cancel',index,begin,begin+length)
+            print (self.get_ip(),'sent cancel',index,begin,begin+length)
 
     def send_bitfield(self, bitfield):
         """Send the L{BITFIELD} message.
@@ -289,9 +289,9 @@
         
         if DEBUG2:
             if s:
-                print (self.ccount,'SENDING MESSAGE',ord(s[0]),len(s))
+                print (self.get_ip(),'SENDING MESSAGE',ord(s[0]),len(s))
             else:
-                print (self.ccount,'SENDING MESSAGE',-1,0)
+                print (self.get_ip(),'SENDING MESSAGE','keepalive',0)
         s = tobinary(len(s))+s
         if self.partial_message:
             self.outqueue.append(s)
@@ -319,7 +319,7 @@
                             tobinary(len(piece) + 9), PIECE,
                             tobinary(index), tobinary(begin), piece.tostring() ))
             if DEBUG1:
-                print (self.ccount,'sending chunk',index,begin,begin+len(piece))
+                print (self.get_ip(),'sending chunk',index,begin,begin+len(piece))
 
         if bytes < len(self.partial_message):
             self.connection.send_message_raw(self.partial_message[:bytes])
@@ -490,7 +490,7 @@
         self.ccount += 1
         c = Connection(connection, self, self.ccount)
         if DEBUG2:
-            print (c.ccount,'connection made')
+            print (c.get_ip(),'connection made')
         self.connections[connection] = c
         c.upload = self.make_upload(c, self.ratelimiter, self.totalup)
         c.download = self.downloader.make_download(c)
@@ -507,7 +507,7 @@
         
         c = self.connections[connection]
         if DEBUG2:
-            print (c.ccount,'connection closed')
+            print (c.get_ip(),'connection closed')
         del self.connections[connection]
         if c.download:
             c.download.disconnected()
@@ -550,17 +550,17 @@
         c = self.connections[connection]
         t = message[0]
         if DEBUG2:
-            print (c.ccount,'message received',ord(t))
+            print (c.get_ip(),'message received',ord(t))
         if t == BITFIELD and c.got_anything:
             if DEBUG2:
-                print (c.ccount,'misplaced bitfield')
+                print (c.get_ip(),'misplaced bitfield')
             connection.close()
             return
         c.got_anything = True
         if (t in [CHOKE, UNCHOKE, INTERESTED, NOT_INTERESTED] and 
                 len(message) != 1):
             if DEBUG2:
-                print (c.ccount,'bad message length')
+                print (c.get_ip(),'bad message length')
             connection.close()
             return
         if t == CHOKE:
@@ -575,13 +575,13 @@
         elif t == HAVE:
             if len(message) != 5:
                 if DEBUG2:
-                    print (c.ccount,'bad message length')
+                    print (c.get_ip(),'bad message length')
                 connection.close()
                 return
             i = toint(message[1:])
             if i >= self.numpieces:
                 if DEBUG2:
-                    print (c.ccount,'bad piece number')
+                    print (c.get_ip(),'bad piece number')
                 connection.close()
                 return
             if c.download.got_have(i):
@@ -591,7 +591,7 @@
                 b = Bitfield(self.numpieces, message[1:])
             except ValueError:
                 if DEBUG2:
-                    print (c.ccount,'bad bitfield')
+                    print (c.get_ip(),'bad bitfield')
                 connection.close()
                 return
             if c.download.got_have_bitfield(b):
@@ -599,13 +599,13 @@
         elif t == REQUEST:
             if len(message) != 13:
                 if DEBUG2:
-                    print (c.ccount,'bad message length')
+                    print (c.get_ip(),'bad message length')
                 connection.close()
                 return
             i = toint(message[1:5])
             if i >= self.numpieces:
                 if DEBUG2:
-                    print (c.ccount,'bad piece number')
+                    print (c.get_ip(),'bad piece number')
                 connection.close()
                 return
             c.got_request(i, toint(message[5:9]), 
@@ -613,13 +613,13 @@
         elif t == CANCEL:
             if len(message) != 13:
                 if DEBUG2:
-                    print (c.ccount,'bad message length')
+                    print (c.get_ip(),'bad message length')
                 connection.close()
                 return
             i = toint(message[1:5])
             if i >= self.numpieces:
                 if DEBUG2:
-                    print (c.ccount,'bad piece number')
+                    print (c.get_ip(),'bad piece number')
                 connection.close()
                 return
             c.upload.got_cancel(i, toint(message[5:9]), 
@@ -627,16 +627,18 @@
         elif t == PIECE:
             if len(message) <= 9:
                 if DEBUG2:
-                    print (c.ccount,'bad message length')
+                    print (c.get_ip(),'bad message length')
                 connection.close()
                 return
             i = toint(message[1:5])
             if i >= self.numpieces:
                 if DEBUG2:
-                    print (c.ccount,'bad piece number')
+                    print (c.get_ip(),'bad piece number')
                 connection.close()
                 return
             if c.download.got_piece(i, toint(message[5:9]), message[9:]):
                 self.got_piece(i)
         else:
+            if DEBUG2:
+                print (c.get_ip(),'unknown message type')
             connection.close()

Modified: debtorrent/trunk/DebTorrent/BT1/Encrypter.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/Encrypter.py?rev=59&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/Encrypter.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/Encrypter.py Wed May 23 05:22:54 2007
@@ -586,6 +586,8 @@
             if self.config['security'] and ip != 'unknown' and ip == dns[0]:
                 return True
         try:
+            if DEBUG:
+                print 'initiating connection to:', dns, id, encrypted
             c = self.raw_server.start_connection(dns)
             con = Connection(self, c, id, encrypted = encrypted)
             self.connections[c] = con

Modified: debtorrent/trunk/DebTorrent/BT1/Rerequester.py
URL: http://svn.debian.org/wsvn/debtorrent/debtorrent/trunk/DebTorrent/BT1/Rerequester.py?rev=59&op=diff
==============================================================================
--- debtorrent/trunk/DebTorrent/BT1/Rerequester.py (original)
+++ debtorrent/trunk/DebTorrent/BT1/Rerequester.py Wed May 23 05:22:54 2007
@@ -28,6 +28,8 @@
 except:
     True = 1
     False = 0
+
+DEBUG = True
 
 mapbase64 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.-'
 keys = {}
@@ -383,6 +385,8 @@
                 x = p[i]
                 peers.append(((x['ip'].strip(), x['port']),
                               x.get('peer id',0), cflags[i]))
+        if DEBUG:
+            print 'received from tracker:', peers
         ps = len(peers) + self.howmany()
         if ps < self.maxpeers:
             if self.doneflag.isSet():




More information about the Debtorrent-commits mailing list