def load_page(): logging_settings = load_configuration('logging_client')['logging'] logging = logging_settings['logging'] log_level = logging['level'] log_length = logging['length'] log_settings = {'level': log_level, 'length': log_length} time_offset = logging_settings['time_offset'] offset_values = { 'direction': time_offset['direction'], 'amount': time_offset['amount'] } system_time = System.format_date_time(fast_time()) local_time = System.calculate_time_offset(fast_time()) local_time = System.format_date_time(local_time) logging_settings = { 'system': system_time, 'local': local_time, 'logging': log_settings, 'offset': offset_values } return logging_settings
def load_page(): logging_settings = load_configuration('logging_client')['logging'] log = logging_settings['logging'] # correcting time for configured offset. time_offset = logging_settings['time_offset'] system_time = System.format_date_time(fast_time()) local_time = System.calculate_time_offset(fast_time()) local_time = System.format_date_time(local_time) logging_settings = { 'system': system_time, 'local': local_time, 'offset': { 'direction': time_offset['direction'], 'amount': time_offset['amount'] }, 'logging': { 'log_levels': [level.title() for level in LOG_LEVELS], 'level': log['level'], 'length': log['length'] } } return logging_settings
def _timeout_reached(self): if (not self._timeout): return False if (fast_time() > self._initial_time + self._timeout): return True return False
def __init__(self, Log, name): self._Log = Log self._name = name self._initial_time = fast_time() self.has_ran = False self._is_initializing = True self._thread_count = 0 self._thread_ready = set()
def add_proxy_domain(whitelist_settings, *, ruleset): input_time = int(fast_time()) expire_time = input_time + whitelist_settings['timer'] * 60 with ConfigurationManager(ruleset) as dnx: domain_list = dnx.load_configuration() domains = domain_list[ruleset]['domain'] domains.update({ whitelist_settings['domain']: { 'time': input_time, 'rule_length': whitelist_settings['timer'], 'expire': expire_time } }) dnx.write_configuration(domain_list)
def timeout_status(): with ConfigurationManager('license') as dnx: dnx_license = dnx.load_configuration()['license'] if not dnx_license['activated']: return timestamp = dnx_license['timestamp'] if (fast_time() - timestamp >= ONE_DAY and dnx_license['validated']): dnx_license['validated'] = False dnx.write_configuration(dnx_license) Log.warning( 'DNX license has been invalidated because it has not contacted the license server in 24 hours.' )
def add_proxy_domain(domain, timer, *, ruleset): input_time = int(fast_time()) expire_time = input_time + timer * 60 with ConfigurationManager(ruleset) as dnx: domain_list = dnx.load_configuration() domains = domain_list[ruleset]['domain'] domains.update({ domain: { 'time': input_time, 'rule_length': timer, 'expire': expire_time } }) dnx.write_configuration(domain_list)
def table_cleaner(self, log_length, table): expire_threshold = int(fast_time()) - (ONE_DAY * log_length) self.c.execute(f'delete from {table} where last_seen < {expire_threshold}') self.data_written = True
def blocked_cleaner(self, table): expire_threshold = int(fast_time()) - FIVE_MIN self.c.execute(f'delete from {table} where timestamp < {expire_threshold}') self.data_written = True