home *** CD-ROM | disk | FTP | other *** search
/ Mundo do CD-ROM 118 / cdrom118.iso / internet / webaroo / WebarooSetup.exe / Webaroo.msi / _A0DEB44B94924E89917E71AA90C5F226 / BitTorrent / ClientIdentifier.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2005-12-23  |  3.4 KB  |  72 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import re
  5. v64p = '[\\da-zA-Z.-]'
  6. matches = (('-AZ(?P<version>\\d+)-+.+$', 'Azureus'), ('M(?P<version>\\d-\\d-\\d)--.+$', 'BitTorrent'), ('T(?P<version>%s+)-+.+$' % v64p, 'BitTornado'), ('-TS(?P<version>\\d+)-+.+$', 'TorrentStorm'), ('exbc(?P<bcver>.*)LORD.+$', 'BitLord'), ('exbc(?P<bcver>.*).+$', 'BitComet'), ('FUTB(?P<bcver>.*).+$', 'BitComet Mod1'), ('xUTB(?P<bcver>.*).+$', 'BitComet Mod2'), ('A(?P<version>%s+)-+.+$' % v64p, 'ABC'), ('S(?P<version>%s+)-+.+$' % v64p, "Shadow's"), ('-G3.+$', 'G3Torrent'), ('-LT(?P<version>\\d+)-+.+$', 'libtorrent'), ('Mbrst(?P<version>\\d-\\d-\\d).+$', 'burst!'), ('eX.+$', 'eXeem'), ('\x00\x02BS.+$', 'BitSpirit v2'), ('.*(?=HTTPBT$|UDP0$).+$', 'BitSpirit'), ('-BB(?P<version>\\d+)-+.+$', 'BitBuddy'), ('-CT(?P<version>\\d+)-+.+$', 'CTorrent'), ('-MT(?P<version>\\d+)-+.+$', 'MoonlightTorrent'), ('-BX(?P<version>\\d+)-+.+$', 'BitTorrent X'), ('-TN(?P<version>\\d+)-+.+$', 'TorrentDotNET'), ('-SS(?P<version>\\d+)-+.+$', 'SwarmScope'), ('-XT(?P<version>\\d+)-+.+$', 'XanTorrent'), ('U(?P<version>\\d+)-+.+$', 'UPnP NAT Bit Torrent'), ('-BOWP?(?P<version>\\d+)-.+$', 'Bits on Wheels'), ('-AR(?P<version>\\d+)-+.+$', 'Arctic'), ('(?P<rsver>.*)BM.+$', 'BitMagnet'), ('BG(?P<version>\\d+).+$', 'BtGetit'), ('-eX.+$', 'eXeem beta'), ('Plus.+$', 'Plus! II'), ('(?P<rsver>.*)RS.+$', 'Rufus'), ('XBT(?P<version>\\d+)-+.+$', 'XBT'), ('-ZT(?P<version>\\d+)-+.+$', 'ZipTorrent'), (chr(0) * 12 + '.+$', '\\0 * 12'))
  7. matches = [ (re.compile(pattern, re.DOTALL), name) for pattern, name in matches ]
  8. unknown_clients = { }
  9.  
  10. def identify_client(peerid, log = None):
  11.     client = 'unknown'
  12.     version = ''
  13.     for pat, name in matches:
  14.         m = pat.match(peerid)
  15.         if m:
  16.             client = name
  17.             d = m.groupdict()
  18.             if d.has_key('version'):
  19.                 version = d['version']
  20.                 version = version.replace('-', '.')
  21.                 if version.find('.') >= 0:
  22.                     version = ''.join(version.split('.'))
  23.                 
  24.                 version = list(version)
  25.                 for i, c in enumerate(version):
  26.                     if c <= c:
  27.                         pass
  28.                     elif c <= '9':
  29.                         version[i] = c
  30.                         continue
  31.                     if c <= c:
  32.                         pass
  33.                     elif c <= 'Z':
  34.                         version[i] = str(ord(c) - 55)
  35.                         continue
  36.                     if c <= c:
  37.                         pass
  38.                     elif c <= 'z':
  39.                         version[i] = str(ord(c) - 61)
  40.                         continue
  41.                     if c == '.':
  42.                         version[i] = '62'
  43.                         continue
  44.                     if c == '-':
  45.                         version[i] = '63'
  46.                         continue
  47.                 
  48.                 version = '.'.join(version)
  49.             elif d.has_key('bcver'):
  50.                 bcver = d['bcver']
  51.                 version += str(ord(bcver[0])) + '.'
  52.                 version += str(ord(bcver[1]) / 10)
  53.                 version += str(ord(bcver[1]) % 10)
  54.             elif d.has_key('rsver'):
  55.                 rsver = d['rsver']
  56.                 version += str(ord(rsver[0])) + '.'
  57.                 version += str(ord(rsver[1]) / 10) + '.'
  58.                 version += str(ord(rsver[1]) % 10)
  59.             
  60.             break
  61.             continue
  62.     
  63.     if client == 'unknown' and log is not None:
  64.         if not unknown_clients.has_key(peerid):
  65.             unknown_clients[peerid] = True
  66.             log.write('%s\n' % peerid)
  67.             log.write('------------------------------\n')
  68.         
  69.     
  70.     return (client, version)
  71.  
  72.