Fix exception in logs

This was occuring when you had square brackets in the domain part
master
Florent Daigniere 3 years ago
parent 8cf76afbab
commit 91de20c49c

@ -5,6 +5,7 @@ from flask import current_app as app
import flask import flask
import idna import idna
import re import re
import sqlalchemy.exc
import srslib import srslib
@internal.route("/postfix/dane/<domain_name>") @internal.route("/postfix/dane/<domain_name>")
@ -158,11 +159,13 @@ def postfix_sender_rate(sender):
def postfix_sender_access(sender): def postfix_sender_access(sender):
""" Simply reject any sender that pretends to be from a local domain """ Simply reject any sender that pretends to be from a local domain
""" """
if not is_void_address(sender): try:
localpart, domain_name = models.Email.resolve_domain(sender) if not is_void_address(sender):
return flask.jsonify("REJECT") if models.Domain.query.get(domain_name) else flask.abort(404) localpart, domain_name = models.Email.resolve_domain(sender)
else: return flask.jsonify("REJECT") if models.Domain.query.get(domain_name) else flask.abort(404)
return flask.abort(404) except sqlalchemy.exc.StatementError:
pass
return flask.abort(404)
def is_void_address(email): def is_void_address(email):

Loading…
Cancel
Save