_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.8.3'
+__version__ = '0.9.0'
LOG = logging.getLogger(__name__)
re_remote_id = re.compile(pat_remote_id, re.IGNORECASE)
+ re_relay_address = re.compile(r'\[(?P<addr>[^\]]+)\]')
+
# -------------------------------------------------------------------------
def __init__(self, **kwargs):
"""Initialize this object."""
return
self._relay = val
+ # -----------------------------------------------------------
+ @property
+ def relay_address(self):
+ """Return the IP address of an existing relay for SMTP."""
+ if not self.relay:
+ return None
+
+ m = self.re_relay_address.search(self.relay)
+ if not m:
+ # Did not found IP address in SMTP relay.
+ return None
+
+ try:
+ addr = ipaddress.ip_address(m['addr'])
+ except ValueError as e:
+ msg = _('Could not interprete relay address {a!r}: {e}').format(a=m['addr'], e=e)
+ if self.warn_on_parse_error:
+ LOG.warn(msg)
+ else:
+ LOG.debug(msg)
+ return None
+
+ return addr
+
# -----------------------------------------------------------
@property
def remote_id(self):
# Catch all
res[attrib] = value
+ if not exportable:
+ res['relay_address'] = self.relay_address
+
return res
# -------------------------------------------------------------------------