aboutsummaryrefslogtreecommitdiffstats
path: root/Mailman/Utils.py
diff options
context:
space:
mode:
authorYasuhito FUTATSUKI at POEM <futatuki@poem.co.jp>2018-06-06 02:18:30 +0900
committerYasuhito FUTATSUKI at POEM <futatuki@poem.co.jp>2018-06-06 02:18:30 +0900
commite591f51039f4ebc4a52d6a8aac210d8ebb7978de (patch)
tree004c9f8ba6a59659e2ea930f5f74403a269627f8 /Mailman/Utils.py
parent898c692842fed6e33a4bc309d9d240721a01a4c7 (diff)
parentca506e913faa49331db68f541774fdb773653988 (diff)
downloadmailman2-e591f51039f4ebc4a52d6a8aac210d8ebb7978de.tar.gz
mailman2-e591f51039f4ebc4a52d6a8aac210d8ebb7978de.tar.xz
mailman2-e591f51039f4ebc4a52d6a8aac210d8ebb7978de.zip
merge lp:mailman up to rev 1765
Diffstat (limited to '')
-rw-r--r--Mailman/Utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py
index fd6ac796..cdc82366 100644
--- a/Mailman/Utils.py
+++ b/Mailman/Utils.py
@@ -1495,3 +1495,24 @@ def xml_to_unicode(s, cset):
else:
return s
+def banned_ip(ip):
+ if not dns_resolver:
+ return False
+ parts = ip.split('.')
+ if len(parts) != 4:
+ return False
+ lookup = '{}.{}.{}.{}.zen.spamhaus.org'.format(parts[3],
+ parts[2],
+ parts[1],
+ parts[0])
+ resolver = dns.resolver.Resolver()
+ try:
+ ans = resolver.query(lookup, dns.rdatatype.A)
+ except DNSException:
+ return False
+ if not ans:
+ return False
+ text = ans.rrset.to_text()
+ if re.search(r'127\.0\.0\.[2-7]$', text, re.MULTILINE):
+ return True
+ return False