Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated enforcemx plugin: use netaddr instead of netcidr because neta…

…ddr also supports IPv6.
  • Loading branch information...
commit a98c6a74a51c2d525db0a47efe770c91e615418e 1 parent be1ec27
neonknight authored
Showing with 9 additions and 8 deletions.
  1. +9 −8 src/postomaat/plugins/enforcemx.py
View
17 src/postomaat/plugins/enforcemx.py
@@ -10,16 +10,17 @@
from unexpected hosts trying to bypass the spam filter.
"""
+__version__ = "0.0.2"
import logging
import os
from threading import Lock
try:
- from netcidr import CIDR
- have_netcidr = True
+ from netaddr import IPAddress, IPNetwork
+ have_netaddr = True
except:
- have_netcidr = False
+ have_netaddr = False
from postomaat.shared import ScannerPlugin, DUNNO, DEFER_IF_PERMIT, REJECT, strip_address, extract_domain
@@ -105,7 +106,7 @@ def _reallyloadData(self, filename):
for item in nets.split(','):
item = item.strip()
- item = CIDR(item)
+ item = IPNetwork(item)
if not item in self.mxnets[domain]:
self.mxnets[domain].append(item)
@@ -119,7 +120,7 @@ def permitted(self, domain, ip):
perm = False
for net in self.mxnets[domain]:
- if ip in net.iterIPs():
+ if IPAddress(ip) in net:
perm = True
break
return perm
@@ -136,7 +137,7 @@ def __init__(self,config,section=None):
def examine(self,suspect):
- if not have_netcidr:
+ if not have_netaddr:
return DUNNO,None
client_address=suspect.get_value('client_address')
@@ -172,8 +173,8 @@ def examine(self,suspect):
def lint(self):
lint_ok = True
- if not have_netcidr:
- print 'netcidr python module not available - please install'
+ if not have_netaddr:
+ print 'netaddr python module not available - please install'
lint_ok = False
if not self.checkConfig():
Please sign in to comment.
Something went wrong with that request. Please try again.