paulbsd-salt/states/_modules/bl.py

17 lines
407 B
Python
Raw 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"""
fullurl = f"{url}/ips/last"
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