X-Git-Url: https://git.mxchange.org/?p=quix0rs-apt-p2p.git;a=blobdiff_plain;f=apt_dht_Khashmir%2FDHT.py;h=c4a0b340ec786d2537b4a331a2d0c117793c21bf;hp=ca5bb609bc38d1ad8a7d86418efb54e088d93d37;hb=7dab2471d589ea439ccbfe794258863c2af858e9;hpb=445f3b8084171babfb68e89441927c055eb9bf6f diff --git a/apt_dht_Khashmir/DHT.py b/apt_dht_Khashmir/DHT.py index ca5bb60..c4a0b34 100644 --- a/apt_dht_Khashmir/DHT.py +++ b/apt_dht_Khashmir/DHT.py @@ -17,21 +17,29 @@ class DHT: def loadConfig(self, config, section): """See L{apt_dht.interfaces.IDHT}.""" - self.config = config + self.config_parser = config self.section = section - if self.config.has_option(section, 'port'): - self.port = self.config.get(section, 'port') - else: - self.port = self.config.get('DEFAULT', 'port') + self.config = [] + for k in self.config_parser.options(section): + if k in ['K', 'HASH_LENGTH', 'CONCURRENT_REQS', 'STORE_REDUNDANCY', + 'MAX_FAILURES', 'PORT']: + self.config[k] = self.config_parser.getint(section, k) + elif k in ['CHECKPOINT_INTERVAL', 'MIN_PING_INTERVAL', + 'BUCKET_STALENESS', 'KEINITIAL_DELAY', 'KE_DELAY', 'KE_AGE']: + self.config[k] = self.config_parser.gettime(section, k) + else: + self.config[k] = self.config_parser.get(section, k) + if 'PORT' not in self.config: + self.config['PORT'] = self.config_parser.getint('DEFAULT', 'PORT') def join(self): """See L{apt_dht.interfaces.IDHT}.""" if self.config is None: raise DHTError, "configuration not loaded" - self.khashmir = Khashmir('', self.port) + self.khashmir = Khashmir(self.config, self.config_parser.get('DEFAULT', 'cache_dir')) - for node in self.config.get(self.section, 'bootstrap'): + for node in self.config_parser.get(self.section, 'BOOTSTRAP'): host, port = node.rsplit(':', 1) self.khashmir.addContact(host, port)