Don’t print empty element lists in nftables

Because nft chokes on them.
This commit is contained in:
Timotej Lazar 2023-06-26 10:15:03 +02:00
parent e84cb26dc7
commit 5ba9c03e23

View file

@ -81,7 +81,7 @@ def save_config():
return f'''\ return f'''\
set {name} {{ set {name} {{
type {"ipv6_addr" if name.endswith('/6') else "ipv4_addr"}; flags interval type {"ipv6_addr" if name.endswith('/6') else "ipv4_addr"}; flags interval
elements = {{ {', '.join(ips)} }} {"" if ips else "# "}elements = {{ {", ".join(ips)} }}
}}''' }}'''
for name, ips in ipsets.items(): for name, ips in ipsets.items():
print(format_set(name, ips), file=f) print(format_set(name, ips), file=f)