home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- import re
- v64p = '[\\da-zA-Z.-]'
- 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'))
- matches = [ (re.compile(pattern, re.DOTALL), name) for pattern, name in matches ]
- unknown_clients = { }
-
- def identify_client(peerid, log = None):
- client = 'unknown'
- version = ''
- for pat, name in matches:
- m = pat.match(peerid)
- if m:
- client = name
- d = m.groupdict()
- if d.has_key('version'):
- version = d['version']
- version = version.replace('-', '.')
- if version.find('.') >= 0:
- version = ''.join(version.split('.'))
-
- version = list(version)
- for i, c in enumerate(version):
- if c <= c:
- pass
- elif c <= '9':
- version[i] = c
- continue
- if c <= c:
- pass
- elif c <= 'Z':
- version[i] = str(ord(c) - 55)
- continue
- if c <= c:
- pass
- elif c <= 'z':
- version[i] = str(ord(c) - 61)
- continue
- if c == '.':
- version[i] = '62'
- continue
- if c == '-':
- version[i] = '63'
- continue
-
- version = '.'.join(version)
- elif d.has_key('bcver'):
- bcver = d['bcver']
- version += str(ord(bcver[0])) + '.'
- version += str(ord(bcver[1]) / 10)
- version += str(ord(bcver[1]) % 10)
- elif d.has_key('rsver'):
- rsver = d['rsver']
- version += str(ord(rsver[0])) + '.'
- version += str(ord(rsver[1]) / 10) + '.'
- version += str(ord(rsver[1]) % 10)
-
- break
- continue
-
- if client == 'unknown' and log is not None:
- if not unknown_clients.has_key(peerid):
- unknown_clients[peerid] = True
- log.write('%s\n' % peerid)
- log.write('------------------------------\n')
-
-
- return (client, version)
-
-