updated nftables state

This commit is contained in:
Paul 2022-01-02 18:09:13 +01:00
parent abe739eb94
commit 891bf239ae
2 changed files with 4 additions and 3 deletions

View File

@ -5,11 +5,12 @@ from urllib.request import urlopen, Request
def get_ips(url="https://ipbl.paulbsd.com"): def get_ips(url="https://ipbl.paulbsd.com"):
"""get_jobs fetch jobs from dkron""" """get_ips fetch ips blacklists from ipbl"""
fullurl = f"{url}/ips" fullurl = f"{url}/ips"
req = Request(method="GET", url=fullurl) req = Request(method="GET", url=fullurl)
res = urlopen(req) res = urlopen(req)
results = json.loads(res.read()) results = json.loads(res.read())
ips = [i["ip"] for i in results]
if res.status == 200: if res.status == 200:
return results return ips
return None return None

View File

@ -2,7 +2,7 @@
{% set blackips = salt["bl.get_ips"]() %} {% set blackips = salt["bl.get_ips"]() %}
{% if blackips|length > 0 %} {% if blackips|length > 0 %}
define blacklist = { {{ blackips.join(",") }} } define blacklist = { {{ blackips|join(", ") }} }
{% else %} {% else %}
define blacklist = { 127.255.255.255 } define blacklist = { 127.255.255.255 }
{% endif %} {% endif %}