paulbsd-salt/states/_modules/bl.py

17 lines
422 B
Python
Raw Permalink Normal View History

2022-01-02 18:01:47 +01:00
#!/usr/bin/python3
import json
from urllib.request import urlopen, Request
def get_ips(url="https://ipbl.paulbsd.com"):
2022-01-02 18:09:13 +01:00
"""get_ips fetch ips blacklists from ipbl"""
2022-03-23 18:26:38 +01:00
fullurl = f"{url}/ips/last?interval=3%20h"
2022-01-02 18:01:47 +01:00
req = Request(method="GET", url=fullurl)
res = urlopen(req)
results = json.loads(res.read())
2022-01-02 18:09:13 +01:00
ips = [i["ip"] for i in results]
2022-01-02 18:01:47 +01:00
if res.status == 200:
2022-01-02 18:09:13 +01:00
return ips
2022-01-02 18:01:47 +01:00
return None