fix: [D4] fix module cache

This commit is contained in:
terrtia 2024-01-30 14:31:09 +01:00
parent 5fab2326e6
commit e4f21f05cc
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0

View file

@ -34,16 +34,20 @@ class D4Client(AbstractModule):
self.d4_client = d4.create_d4_client() self.d4_client = d4.create_d4_client()
self.last_refresh = time.time() self.last_refresh = time.time()
self.last_config_check = time.time()
# Send module state to logs # Send module state to logs
self.logger.info(f'Module {self.module_name} initialized') self.logger.info(f'Module {self.module_name} initialized')
def compute(self, dns_record): def compute(self, dns_record):
# Refresh D4 Client # Refresh D4 Client
if self.last_refresh < d4.get_config_last_update_time(): if self.last_config_check < int(time.time()) - 30:
self.d4_client = d4.create_d4_client() print('refresh rrrr')
self.last_refresh = time.time() if self.last_refresh < d4.get_config_last_update_time():
print('D4 Client: config updated') self.d4_client = d4.create_d4_client()
self.last_refresh = time.time()
print('D4 Client: config updated')
self.last_config_check = time.time()
if self.d4_client: if self.d4_client:
# Send DNS Record to D4Server # Send DNS Record to D4Server