Package DebTorrent :: Package BT1 :: Module track
[hide private]
[frames] | no frames]

Module track

source code

Tools to track a download swarm.

Classes [hide private]
  Tracker
Track a download swarm.
Functions [hide private]
 
statefiletemplate(x)
Check the saved state file for corruption.
source code
string
isotime(secs=None)
Create an ISO formatted string of the time.
source code
string
_get_forwarded_ip(headers)
Extract the unNATed IP address from the headers.
source code
string
get_forwarded_ip(headers)
Extract the unNATed IP address from the headers.
source code
string
compact_peer_info(ip, port)
Create a compact representation of peer contact info.
source code
boolean
track(params)
Start the server and tracker.
source code
string
size_format(s)
Format a byte size for reading by the user.
source code
Variables [hide private]
logging.Logger logger = logging.getLogger('DebTorrent.BT1.track')
the logger to send all log messages to for this module
list of (string, unknown, string) defaults = [('configfile', '', 'the configuration file to use,...
the parameter names, default values, and descriptions
string alas = 'your file may exist elsewhere in the universe\nbut ala...
the message to send when the data is not found
DebTorrent.subnetparse.IP_List local_IPs = <DebTorrent.subnetparse.IP_List instance at 0x2b55...
the list of IP subnets that are considered local
Regular Expression http_via_filter = re.compile(r' for ([0-9\.]+)\Z')
the regular expression object to search 'via' header information for the NAT IP address

Imports: parseargs.parseargs, parseargs.formatDefinitions, RawServer.RawServer, RawServer.autodetect_ipv6, RawServer.autodetect_socket_style, HTTPHandler.HTTPHandler, HTTPHandler.months, HTTPHandler.weekdays, parsedir.parsedir, NatCheck.NatCheck, NatCheck.CHECK_PEER_ID_ENCRYPTED, BTcrypto.CRYPTO_OK, T2T.T2TList, subnetparse.IP_List, subnetparse.ipv6_to_ipv4, subnetparse.to_ipv4, subnetparse.is_valid_ip, subnetparse.is_ipv4, iprangeparse.IP_List, torrentlistparse.parsetorrentlist, threading.Event, threading.Thread, bencode.bencode, bencode.bdecode, bencode.Bencached, zurllib.urlopen, zurllib.quote, zurllib.unquote, Filter.Filter, urlparse.urlparse, os.rename, os.getpid, os.path.exists, os.path.isfile, cStringIO.StringIO, time.time, time.gmtime, time.strftime, time.localtime, clock.clock, random.shuffle, random.seed, random.randrange, sha.sha, types.StringType, types.IntType, types.LongType, types.ListType, types.DictType, binascii.b2a_hex, binascii.a2b_hex, string.lower, sys, os, logging, signal, re, DebTorrent, __init__.version, __init__.createPeerID, ConfigDir.ConfigDir


Function Details [hide private]

statefiletemplate(x)

source code 
Check the saved state file for corruption.
Parameters:
  • x (dictionary) - the dictionary of information retrieved from the state file
Raises:
  • ValueError - if the state file info is corrupt

isotime(secs=None)

source code 
Create an ISO formatted string of the time.
Parameters:
  • secs (float) - number of seconds since the epoch (optional, default is to use the current time)
Returns: string
the ISO formatted string representation of the time

_get_forwarded_ip(headers)

source code 
Extract the unNATed IP address from the headers.
Parameters:
  • headers (dictionary) - the headers received from the client
Returns: string
the extracted IP address

get_forwarded_ip(headers)

source code 
Extract the unNATed IP address from the headers.
Parameters:
  • headers (dictionary) - the headers received from the client
Returns: string
the extracted IP address (or None if one could not be extracted)

compact_peer_info(ip, port)

source code 
Create a compact representation of peer contact info.
Parameters:
  • ip (string) - the IP address of the peer
  • port (int) - the port number to contact the peer on
Returns: string
the compact representation (or the empty string if there is no compact representation)

track(params)

source code 
Start the server and tracker.
Parameters:
  • params (list) - the command line arguments to the tracker
Returns: boolean
whether the server should be restarted

size_format(s)

source code 
Format a byte size for reading by the user.
Parameters:
  • s (long) - the number of bytes
Returns: string
the formatted size with appropriate units

Variables Details [hide private]

defaults

the parameter names, default values, and descriptions
Type:
list of (string, unknown, string)
Value:
[('configfile',
  '',
  'the configuration file to use, if not specified then a file in /etc\
/debtorrent will be used, followed by a file in the .DebTorrent direct\
ory in the user\'s home directory'),
 ('cache_dir',
  '',
  'the directory to use to get/store cache files, if not specified the\
...

alas

the message to send when the data is not found
Type:
string
Value:
'''your file may exist elsewhere in the universe
but alas, not here
'''

local_IPs

the list of IP subnets that are considered local
Type:
DebTorrent.subnetparse.IP_List
Value:
IP_List()