Пример #1
0
 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'))
Пример #2
0
 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'))
Пример #3
0
 def _startFactory(self):
     log.msg('Starting the main apt_p2p application')
     self.cache_dir = FilePath(config.get('DEFAULT', 'CACHE_DIR'))
     if not self.cache_dir.child(download_dir).exists():
         self.cache_dir.child(download_dir).makedirs()
     if not self.cache_dir.child(peer_dir).exists():
         self.cache_dir.child(peer_dir).makedirs()
     self.db = DB(self.cache_dir.child('apt-p2p.db'))
     self.dht = DHT(self.dhtClass, self.db)
     df = self.dht.start()
     df.addCallback(self._dhtStarted)
     self.stats = StatsLogger(self.db)
     self.http_server = TopLevel(self.cache_dir.child(download_dir), self.db, self)
     self.http_server.getHTTPFactory().startFactory()
     self.peers = PeerManager(self.cache_dir.child(peer_dir), self.dht, self.stats)
     self.mirrors = MirrorManager(self.cache_dir)
     self.cache = CacheManager(self.cache_dir.child(download_dir), self.db, self)
Пример #4
0
 def _startFactory(self):
     log.msg('Starting the main apt_p2p application')
     self.cache_dir = FilePath(config.get('DEFAULT', 'CACHE_DIR'))
     if not self.cache_dir.child(download_dir).exists():
         self.cache_dir.child(download_dir).makedirs()
     if not self.cache_dir.child(peer_dir).exists():
         self.cache_dir.child(peer_dir).makedirs()
     self.db = DB(self.cache_dir.child('apt-p2p.db'))
     self.dht = DHT(self.dhtClass, self.db)
     df = self.dht.start()
     df.addCallback(self._dhtStarted)
     self.stats = StatsLogger(self.db)
     self.http_server = TopLevel(self.cache_dir.child(download_dir),
                                 self.db, self)
     self.http_server.getHTTPFactory().startFactory()
     self.peers = PeerManager(self.cache_dir.child(peer_dir), self.dht,
                              self.stats)
     self.mirrors = MirrorManager(self.cache_dir)
     self.cache = CacheManager(self.cache_dir.child(download_dir), self.db,
                               self)
Пример #5
0
 def start(self):
     self.dht = self.dhtClass()
     self.dht.loadConfig(config, config.get('DEFAULT', 'DHT'))
     df = self.dht.join()
     df.addCallbacks(self.joinComplete, self.joinError)
     return df
Пример #6
0
 def start(self):
     self.dht = self.dhtClass()
     self.dht.loadConfig(config, config.get('DEFAULT', 'DHT'))
     df = self.dht.join()
     df.addCallbacks(self.joinComplete, self.joinError)
     return df