Development
This commit is contained in:
parent
909030bace
commit
721670469e
3 changed files with 43 additions and 17 deletions
|
|
@ -515,27 +515,30 @@ def check_configurations(data):
|
|||
pass
|
||||
|
||||
# --- Blocklist file freshness ---
|
||||
now = datetime.now(timezone.utc).timestamp()
|
||||
now = datetime.now(timezone.utc).timestamp()
|
||||
bl_library = {bl["name"]: bl for bl in data.get("dns_blocking", {}).get("blocklists", [])}
|
||||
needed = set()
|
||||
for vlan in vlans:
|
||||
names = vlan.get("use_blocklists", [])
|
||||
if not names:
|
||||
needed.update(vlan.get("use_blocklists", []))
|
||||
for name in sorted(needed):
|
||||
bl = bl_library.get(name)
|
||||
if not bl or bl.get("bl_type") == "local":
|
||||
continue
|
||||
vlan_name = vlan["name"]
|
||||
path = _vlan_hosts_file(vlan)
|
||||
label = ", ".join(sorted(names))
|
||||
if not path.exists():
|
||||
save_as = bl.get("save_as", "")
|
||||
path = BLOCKLIST_DIR / save_as if save_as else None
|
||||
if not path or not path.exists():
|
||||
results.append(problem(
|
||||
f"blocklist_{vlan_name}", f"blocklist ({vlan_name})", "warning",
|
||||
f"Blocklist hosts file for '{vlan_name}' does not exist.",
|
||||
"Run `sudo python3 dl_blocklists.py && sudo python3 core.py --merge-blocklists`."))
|
||||
f"blocklist_{name}", f"blocklist ({name})", "warning",
|
||||
f"Blocklist file for '{name}' has not been downloaded.",
|
||||
"Run `sudo python3 dl_blocklists.py`."))
|
||||
elif now - path.stat().st_mtime > BLOCKLIST_STALE_SECS:
|
||||
age_h = int((now - path.stat().st_mtime) / 3600)
|
||||
results.append(problem(
|
||||
f"blocklist_{vlan_name}", f"blocklist ({vlan_name})", "warning",
|
||||
f"Blocklist hosts file for '{vlan_name}' is {age_h}h old (threshold 36h).",
|
||||
"Run `sudo python3 dl_blocklists.py && sudo python3 core.py --merge-blocklists`."))
|
||||
f"blocklist_{name}", f"blocklist ({name})", "warning",
|
||||
f"Blocklist '{name}' is {age_h}h old (threshold 36h).",
|
||||
"Run `sudo python3 dl_blocklists.py`."))
|
||||
else:
|
||||
results.append(ok(f"blocklist_{vlan_name}", f"blocklist ({vlan_name})"))
|
||||
results.append(ok(f"blocklist_{name}", f"blocklist ({name})"))
|
||||
|
||||
# --- Disk space ---
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue