コード例 #1
0
ファイル: DHTManager.py プロジェクト: PyroSamurai/apt-p2p
 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
ファイル: DHTManager.py プロジェクト: norpol/apt-p2p
 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
ファイル: apt_p2p.py プロジェクト: PyroSamurai/apt-p2p
 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
ファイル: DHTManager.py プロジェクト: PyroSamurai/apt-p2p
 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
ファイル: DHTManager.py プロジェクト: norpol/apt-p2p
 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