Package DebTorrent :: Package BT1 :: Module T2T :: Class T2TConnection
[hide private]
[frames] | no frames]

Class T2TConnection

source code

A single tracker to tracker connection for a single torrent.

Creates a Rerequester.Rerequester object but does not start it running, instead all requesting is controlled from this class.

Instance Methods [hide private]
 
__init__(self, myid, tracker, hash, interval, peers, timeout, rawserver, disallow, isdisallowed)
Initialize the instance and schedule a request.
source code
boolean
isactive(self)
Check if the tracker connection has been disallowed.
source code
 
deactivate(self)
Deactive the connection.
source code
 
refresh(self)
Request new peer data from the tracker.
source code
 
callback(self)
Process the returned peer data from the tracker.
source code
 
addtolist(self, peers)
Save the returned peer data from the tracker for later processing.
source code
 
errorfunc(self, r)
Process an error that occurred.
source code
list of (string, string, int)
harvest(self)
Retrieve the saved list of peers from this tracker connection.
source code
Instance Variables [hide private]
boolean active
whether the connection is active
boolean busy
not used
method disallow
method to call to disallow a tracker address
int errors
the number of errors that have occurred since the last successful request
string hash
the info hash of the torrent
int interval
original seconds between outgoing tracker announces
method isdisallowed
method to call to check if a tracker address is disallowed
boolean lastsuccessful
whether the last request was successful
list of (string, string, int) newpeerdata
the list of peer data of peer ID, IP address, and port
int operatinginterval
current seconds between outgoing tracker announces
list of list of (string, string, int) peerlists
the last 10 announce peer data of peer ID, IP address, and port
int peers
number of peers to get in a tracker announce
DebTorrent.RawServer.RawServer rawserver
the server instance to use
int rejected
the number of rejections that have occurred since the last successful request
Rerequester.Rerequester rerequester
the tracker rerequester instance
string tracker
the tracker address to contact
boolean trackererror
not used
Method Details [hide private]

__init__(self, myid, tracker, hash, interval, peers, timeout, rawserver, disallow, isdisallowed)
(Constructor)

source code 
Initialize the instance and schedule a request.
Parameters:
  • myid (string) - the peer ID to send to the tracker
  • tracker (string) - the tracker address to contact
  • hash (string) - the info hash of the torrent
  • interval (int) - seconds between outgoing tracker announces
  • peers (int) - number of peers to get in a tracker announce
  • timeout (int) - number of seconds to wait before assuming that a tracker connection has timed out
  • rawserver (DebTorrent.RawServer.RawServer) - the server instance to use
  • disallow (method) - method to call to disallow a tracker address
  • isdisallowed (method) - method to call to check if a tracker address is disallowed

isactive(self)

source code 
Check if the tracker connection has been disallowed.
Returns: boolean
whether the connection is active

addtolist(self, peers)

source code 
Save the returned peer data from the tracker for later processing.
Parameters:
  • peers (list of ((string, int), string, boolean)) - the list of IP address, port, peer ID, and whether to encrypt

errorfunc(self, r)

source code 
Process an error that occurred.
Parameters:
  • r (string) - the error message

harvest(self)

source code 
Retrieve the saved list of peers from this tracker connection.
Returns: list of (string, string, int)
the list of peer data of peer ID, IP address, and port