dotfiles/system/hosts/router/a.py

21 lines
441 B
Python
Raw Permalink Normal View History

2024-08-10 18:12:08 +07:00
import traceback
import pytricia # type: ignore
def build_ipset(ips: list[str]) -> pytricia.PyTricia:
pyt = pytricia.PyTricia()
for ip in ips:
try:
pyt.insert(ip, None)
except:
with open("/var/lib/unbound/error.log", "at") as f:
f.write(f"Warning: couldn't insert ip {ip}:\n")
traceback.print_exc(file=f)
return pyt
s = build_ipset(["10.0.0.0/24"])