def joinComplete(self, result): """Complete the DHT join process and determine our download information. Called by the DHT when the join has been completed with information on the external IP address and port of this peer. """ my_addr = findMyIPAddr(result, config.getint(config.get('DEFAULT', 'DHT'), 'PORT'), config.getboolean('DEFAULT', 'LOCAL_OK')) if not my_addr: raise RuntimeError, "IP address for this machine could not be found" self.my_contact = compact(my_addr, config.getint('DEFAULT', 'PORT')) if not self.nextRefresh or not self.nextRefresh.active(): self.nextRefresh = reactor.callLater(60, self.refreshFiles) return (my_addr, config.getint('DEFAULT', 'PORT'))
def joinComplete(self, result): """Complete the DHT join process and determine our download information. Called by the DHT when the join has been completed with information on the external IP address and port of this peer. """ my_addr = findMyIPAddr( result, config.getint(config.get('DEFAULT', 'DHT'), 'PORT'), config.getboolean('DEFAULT', 'LOCAL_OK')) if not my_addr: raise RuntimeError, "IP address for this machine could not be found" self.my_contact = compact(my_addr, config.getint('DEFAULT', 'PORT')) if not self.nextRefresh or not self.nextRefresh.active(): self.nextRefresh = reactor.callLater(60, self.refreshFiles) return (my_addr, config.getint('DEFAULT', 'PORT'))
def __init__(self, directory, db, manager): """Initialize the instance. @type directory: L{twisted.python.filepath.FilePath} @param directory: the directory to check for cached files @type db: L{db.DB} @param db: the database to use for looking up files and hashes @type manager: L{apt_p2p.AptP2P} @param manager: the main program object to send requests to """ self.directory = directory self.db = db self.manager = manager self.uploadLimit = None if config.getint('DEFAULT', 'UPLOAD_LIMIT') > 0: self.uploadLimit = int(config.getint('DEFAULT', 'UPLOAD_LIMIT')*1024) self.factory = None
def __init__(self, directory, db, manager): """Initialize the instance. @type directory: L{twisted.python.filepath.FilePath} @param directory: the directory to check for cached files @type db: L{db.DB} @param db: the database to use for looking up files and hashes @type manager: L{apt_p2p.AptP2P} @param manager: the main program object to send requests to """ self.directory = directory self.db = db self.manager = manager self.uploadLimit = None if config.getint('DEFAULT', 'UPLOAD_LIMIT') > 0: self.uploadLimit = int( config.getint('DEFAULT', 'UPLOAD_LIMIT') * 1024) self.factory = None
def addMirror(self): """Use the mirror if there are few peers.""" if not self.addedMirror and len(self.sitelist) + self.outstanding < config.getint('DEFAULT', 'MIN_DOWNLOAD_PEERS'): self.addedMirror = True parsed = urlparse(self.mirror) if parsed[0] == "http": site = splitHostPort(parsed[0], parsed[1]) self.mirror_path = urlunparse(('', '') + parsed[2:]) peer = self.manager.getPeer(site, mirror = True) self.peers[site] = {} self.peers[site]['peer'] = peer self.sitelist.append(site)
def addMirror(self): """Use the mirror if there are few peers.""" if not self.addedMirror and len( self.sitelist) + self.outstanding < config.getint( 'DEFAULT', 'MIN_DOWNLOAD_PEERS'): self.addedMirror = True parsed = urlparse(self.mirror) if parsed[0] == "http": site = splitHostPort(parsed[0], parsed[1]) self.mirror_path = urlunparse(('', '') + parsed[2:]) peer = self.manager.getPeer(site, mirror=True) self.peers[site] = {} self.peers[site]['peer'] = peer self.sitelist.append(site)