def _find_port(self, listen_fail_ok=True): """Run BitTorrent on the first available port found starting from minport in the range [minport, maxport].""" exc_info = None self.config['minport'] = max(1024, self.config['minport']) self.config['maxport'] = max(self.config['minport'], self.config['maxport']) e = (_("maxport less than minport - no ports to check") + (": %s %s" % (self.config['minport'], self.config['maxport']))) for port in xrange(self.config['minport'], self.config['maxport'] + 1): try: self.singleport_listener.open_port(port, self.config) if self.config['start_trackerless_client']: self.dht = UTKhashmir(self.config['bind'], self.singleport_listener.get_port(), self.data_dir, self.rawserver, int(self.config['max_upload_rate'] * 0.01), rlcount=self.up_ratelimiter.increase_offset, config=self.config) break except socket.error, e: exc_info = sys.exc_info()
def init(*args, **kws): global dht global khashmir_imported if khashmir_imported and dht is None: dht = UTKhashmir(*args, **kws) # Arno: no need for separate thread, it now runs on the regular network thread dht.addContact('router.bittorrent.com', 6881)
def simpleSetUp(self): #self.kfiles() d = dict([(x[0],x[1]) for x in common_options + rare_options]) self.r = RawServer(Event(), d) self.l = [] for i in range(self.num): self.l.append(UTKhashmir(self.bind, self.startport + i, 'kh%s.db' % (self.startport + i), self.r)) for i in self.l: i.addContact(self.chost, self.cport) self.r.listen_once(1) self.r.listen_once(1) self.done = 0 i.findCloseNodes(self._done)
def _find_port(self, listen_fail_ok=True): e = _("maxport less than minport - no ports to check") if self.config['minport'] < 1024: self.config['minport'] = 1024 for port in xrange(self.config['minport'], self.config['maxport'] + 1): try: self.singleport_listener.open_port(port, self.config) if self.config['start_trackerless_client']: self.dht = UTKhashmir(self.config['bind'], self.singleport_listener.get_port(), self.config['data_dir'], self.rawserver, int(self.config['max_upload_rate'] * 1024 * 0.01), rlcount=self.ratelimiter.increase_offset, config=self.config) break except socketerror, e: pass
def __init__(self): self.config, self.metainfo = self._load_settings() self.rawserver = RawServer(self.config) self.dht = UTKhashmir(self.config['bind'], self.config['port'], self.config['dumpDir'], self.rawserver)