Development

This commit is contained in:
Matthew Grotke 2026-06-09 00:35:41 -04:00
parent 7270ca7f28
commit 89306b132d

View file

@ -502,11 +502,11 @@ def validate_config(data):
for idx, bl in enumerate(data.get("dns_blocking", {}).get("blocklists", [])): for idx, bl in enumerate(data.get("dns_blocking", {}).get("blocklists", [])):
name = bl.get("name", "") name = bl.get("name", "")
label = f"dns_blocking.blocklists[{idx}] '{name}'" label = f"dns_blocking.blocklists[{idx}] '{name}'"
for field in ("name", "description", "save_as", "url", "format"): bl_type = bl.get("bl_type", "community")
required = ("name", "description", "save_as") + (() if bl_type == "local" else ("url",))
for field in required:
if not bl.get(field): if not bl.get(field):
errors.append(f"{label}: missing or empty field '{field}'.") errors.append(f"{label}: missing or empty field '{field}'.")
if bl.get("format") and bl["format"] not in VALID_BLOCKLIST_FORMATS:
errors.append(f"{label}: format must be one of: {', '.join(sorted(VALID_BLOCKLIST_FORMATS))}.")
if name: if name:
err = check_blocklist_name_unique( err = check_blocklist_name_unique(
data.get("dns_blocking", {}).get("blocklists", []), name, exclude_idx=idx data.get("dns_blocking", {}).get("blocklists", []), name, exclude_idx=idx