from .errors import PpAppError
-from .common import pp, to_bool
+from .common import pp, to_bool, RE_DOT_AT_END
from .merge import merge_structure
from .app import PpApplication
-__version__ = '0.6.5'
+__version__ = '0.6.6'
LOG = logging.getLogger(__name__)
VALID_MAIL_METHODS = ('smtp', 'sendmail')
self.initialized = True
# -------------------------------------------------------------------------
- def is_local(self, domain):
+ def is_local_domain(self, domain):
+
+ zone_name = RE_DOT_AT_END.sub('', domain)
if self.verbose > 1:
- LOG.debug("Checking, whether {!r} is a not public zone.".format(domain))
+ LOG.debug("Checking, whether {!r} is a local zone.".format(zone_name))
- tld = domain.split('.')[-1]
+ tld = zone_name.split('.')[-1]
if tld in ('intern', 'internal', 'local', 'localdomain', 'lokal'):
- LOG.debug("Zone {!r} has a local TLD {!r}.".format(domain, tld))
+ LOG.debug("Zone {!r} has a local TLD {!r}.".format(zone_name, tld))
return True
- zone_base = domain.split('.')[0]
+ zone_base = zone_name.split('.')[0]
if zone_base in ('intern', 'internal', 'local', 'localdomain', 'lokal'):
- LOG.debug("Zone {!r} has a local base {!r}.".format(domain, tld))
+ LOG.debug("Zone {!r} has a local base {!r}.".format(zone_name, tld))
return True
if tld != 'arpa':
if self.verbose > 2:
- LOG.debug("Zone {!r} has a public TLD {!r}.".format(domain, tld))
+ LOG.debug("Zone {!r} has a public TLD {!r}.".format(zone_name, tld))
return False
- if domain.endswith('.in-addr.arpa'):
+ if zone_name.endswith('.in-addr.arpa'):
tupels = []
- for tupel in reversed(domain.replace('.in-addr.arpa', '').split('.')):
+ for tupel in reversed(zone_name.replace('.in-addr.arpa', '').split('.')):
tupels.append(tupel)
if self.verbose > 2:
- LOG.debug("Got IPv4 tupels from zone {!r}: {}".format(domain, pp(tupels)))
+ LOG.debug("Got IPv4 tupels from zone {!r}: {}".format(zone_name, pp(tupels)))
bitmask = None
if len(tupels) == 1:
bitmask = 8
bitmask = 24
tupels.append('0')
else:
- LOG.warn("Could not interprete reverse IPv4 zone {!r}.".format(domain))
+ LOG.warn("Could not interprete reverse IPv4 zone {!r}.".format(zone_name))
return False
net_address = '.'.join(tupels) + '/{}'.format(bitmask)
if self.verbose > 2:
- LOG.debug("Got IPv4 network address of zone {!r}: {!r}.".format(domain, net_address))
+ LOG.debug("Got IPv4 network address of zone {!r}: {!r}.".format(zone_name, net_address))
network = ipaddress.ip_network(net_address)
if network.is_global:
if self.verbose > 1:
LOG.debug("The network {!r} of zone {!r} is allocated for public networks.".format(
- net_address, domain))
+ net_address, zone_name))
return False
LOG.debug("The network {!r} of zone {!r} is allocated for local networks.".format(
- net_address, domain))
+ net_address, zone_name))
return True
if self.verbose > 2:
- LOG.debug("Zone {!r} seems to be a reverse zone for a public network.".format(domain))
+ LOG.debug("Zone {!r} seems to be a reverse zone for a public network.".format(zone_name))
return False