bundles/icinga2: add non-listing results to check_spam_blocklist
This commit is contained in:
parent
85b95576c4
commit
42e20b122c
1 changed files with 33 additions and 25 deletions
|
@ -5,29 +5,34 @@ from ipaddress import IPv6Address, ip_address
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
from sys import argv, exit
|
from sys import argv, exit
|
||||||
|
|
||||||
BLOCKLISTS = [
|
BLOCKLISTS = {
|
||||||
'0spam.fusionzero.com',
|
'0spam.fusionzero.com': set(),
|
||||||
'bl.mailspike.org',
|
'bl.mailspike.org': set(),
|
||||||
'bl.spamcop.net',
|
'bl.spamcop.net': set(),
|
||||||
'blackholes.brainerd.net',
|
'blackholes.brainerd.net': set(),
|
||||||
'dnsbl-1.uceprotect.net',
|
'dnsbl-1.uceprotect.net': set(),
|
||||||
'l2.spews.dnsbl.sorbs.net',
|
'l2.spews.dnsbl.sorbs.net': set(),
|
||||||
'list.dsbl.org',
|
'list.dsbl.org': set(),
|
||||||
'map.spam-rbl.com',
|
'map.spam-rbl.com': set(),
|
||||||
'multihop.dsbl.org',
|
'multihop.dsbl.org': set(),
|
||||||
'ns1.unsubscore.com',
|
'ns1.unsubscore.com': set(),
|
||||||
'opm.blitzed.org',
|
'opm.blitzed.org': set(),
|
||||||
'psbl.surriel.com',
|
'psbl.surriel.com': set(),
|
||||||
'rbl.efnet.org',
|
'rbl.efnet.org': set(),
|
||||||
'rbl.schulte.org',
|
'rbl.schulte.org': set(),
|
||||||
'spamguard.leadmon.net',
|
'spamguard.leadmon.net': set(),
|
||||||
'ubl.unsubscore.com',
|
'ubl.unsubscore.com': set(),
|
||||||
'unconfirmed.dsbl.org',
|
'unconfirmed.dsbl.org': set(),
|
||||||
'virbl.dnsbl.bit.nl',
|
'virbl.dnsbl.bit.nl': set(),
|
||||||
'zen.spamhaus.org',
|
'zen.spamhaus.org': {
|
||||||
]
|
# https://www.spamhaus.org/news/article/807/using-our-public-mirrors-check-your-return-codes-now.
|
||||||
|
'127.255.255.252', # Typing Error
|
||||||
|
'127.255.255.254', # public resolver / generic rdns
|
||||||
|
'127.255.255.255', # rate limited
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
def check_list(ip_list, blocklist):
|
def check_list(ip_list, blocklist, warn_ips):
|
||||||
dns_name = '{}.{}'.format(
|
dns_name = '{}.{}'.format(
|
||||||
'.'.join(ip_list),
|
'.'.join(ip_list),
|
||||||
blocklist,
|
blocklist,
|
||||||
|
@ -50,6 +55,9 @@ def check_list(ip_list, blocklist):
|
||||||
blocklist,
|
blocklist,
|
||||||
item,
|
item,
|
||||||
))
|
))
|
||||||
|
if item in warn_ips and returncode < 2:
|
||||||
|
returncode = 1
|
||||||
|
else:
|
||||||
returncode = 2
|
returncode = 2
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if e.returncode == 9:
|
if e.returncode == 9:
|
||||||
|
@ -77,8 +85,8 @@ exitcode = 0
|
||||||
with ThreadPoolExecutor(max_workers=len(BLOCKLISTS)) as executor:
|
with ThreadPoolExecutor(max_workers=len(BLOCKLISTS)) as executor:
|
||||||
futures = set()
|
futures = set()
|
||||||
|
|
||||||
for blocklist in BLOCKLISTS:
|
for blocklist, warn_ips in BLOCKLISTS.items():
|
||||||
futures.add(executor.submit(check_list, ip_list, blocklist))
|
futures.add(executor.submit(check_list, ip_list, blocklist, warn_ips))
|
||||||
|
|
||||||
for future in as_completed(futures):
|
for future in as_completed(futures):
|
||||||
msgs, this_exitcode = future.result()
|
msgs, this_exitcode = future.result()
|
||||||
|
|
Loading…
Reference in a new issue