Development
This commit is contained in:
parent
909030bace
commit
721670469e
3 changed files with 43 additions and 17 deletions
|
|
@ -36,8 +36,20 @@ def _dnsblocking_log_tail(cfg):
|
|||
return '(error reading log)', ''
|
||||
|
||||
|
||||
WARN_ICON = '<img src="/www/icons/warning.svg" data-tooltip="Cached blocklist used. Verify URL is correct." style="width:1em;height:1em;vertical-align:middle;margin-left:0.35em;">'
|
||||
|
||||
|
||||
def _last_dl_time():
|
||||
path = f'{config_utils.BLOCKLISTS_DIR}/.last-dl'
|
||||
try:
|
||||
return int(open(path).read().strip())
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def blocklist_stats_html(cfg):
|
||||
db_rows = config_utils._bl_db_rows()
|
||||
db_rows = config_utils._bl_db_rows()
|
||||
last_dl = _last_dl_time()
|
||||
rows = ''
|
||||
for bl in cfg.get('dns_blocking', {}).get('blocklists', []):
|
||||
name = bl.get('name', '')
|
||||
|
|
@ -53,6 +65,7 @@ def blocklist_stats_html(cfg):
|
|||
except Exception:
|
||||
size_str = '-'
|
||||
last_refreshed = 'Local'
|
||||
warn = ''
|
||||
else:
|
||||
fetched_at = db.get('fetched_at')
|
||||
if fetched_at:
|
||||
|
|
@ -66,14 +79,19 @@ def blocklist_stats_html(cfg):
|
|||
bl_path = f'{config_utils.BLOCKLISTS_DIR}/{save_as}' if save_as else ''
|
||||
try:
|
||||
size_str = config_utils.fmt_bytes(os.path.getsize(bl_path))
|
||||
file_mtime = int(os.path.getmtime(bl_path))
|
||||
except Exception:
|
||||
size_str = '-'
|
||||
size_str = '-'
|
||||
file_mtime = None
|
||||
warn = ''
|
||||
if last_dl and file_mtime is not None and file_mtime < last_dl:
|
||||
warn = WARN_ICON
|
||||
rows += (
|
||||
'<tr>'
|
||||
f'<td class="table-cell">{factory.e(name)}</td>'
|
||||
f'<td class="table-cell">{entries}</td>'
|
||||
f'<td class="table-cell">{size_str}</td>'
|
||||
f'<td class="table-cell">{factory.e(last_refreshed)}</td>'
|
||||
f'<td class="table-cell">{factory.e(last_refreshed)}{warn}</td>'
|
||||
'</tr>'
|
||||
)
|
||||
if not rows:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue