summaryrefslogtreecommitdiff
path: root/src/leap/mx
diff options
context:
space:
mode:
authorIsis Lovecruft <isis@torproject.org>2013-04-15 19:41:15 +0000
committerIsis Lovecruft <isis@torproject.org>2013-04-15 19:41:15 +0000
commit2c3083e0631f59faeb60197bfa06235b36b86a99 (patch)
tree7b15265e146964bee15daad34f384458f62acdfb /src/leap/mx
parent80e9dc5548b36d1c4f99446a4c1412fcb2c93122 (diff)
Change the logic on sending Postfix TCP map status codes and messages.
Diffstat (limited to 'src/leap/mx')
-rw-r--r--src/leap/mx/alias_resolver.py18
1 files changed, 15 insertions, 3 deletions
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):