From 2c3083e0631f59faeb60197bfa06235b36b86a99 Mon Sep 17 00:00:00 2001 From: Isis Lovecruft Date: Mon, 15 Apr 2013 19:41:15 +0000 Subject: Change the logic on sending Postfix TCP map status codes and messages. --- src/leap/mx/alias_resolver.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/leap') diff --git a/src/leap/mx/alias_resolver.py b/src/leap/mx/alias_resolver.py index c080123..1a7392d 100644 --- a/src/leap/mx/alias_resolver.py +++ b/src/leap/mx/alias_resolver.py @@ -189,9 +189,21 @@ class AliasResolver(postfix.PostfixTCPMapServer): self.status_codes = StatusCodes() def sendCode(self, code, message=None): - """Send an SMTP-like code with a message.""" - if not message: - message = self.status_codes.get(code) + """Send an SMTP-like code with a message. + + :type code: str or int + :param code: The status code to send, see + ``alias_resolver.StatusCodes``. + """ + try: + assert isinstance(code, int), "status code must be type int" + except AssertionError as ae: + log.err(ae.message) + self.sendLine('500 internal server error: %s' % ae.message) + + msg = self.status_codes.get(code) + if message is not None and isinstance(message, str): + msg += (" " + message) self.sendLine('%3.3d %s' % (code, message or '')) def do_get(self, key): -- cgit v1.2.3