|
|
@ -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,18 +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):
|
|
|
|
if '@' in sender:
|
|
|
|
localpart, domain_name = models.Email.resolve_domain(sender)
|
|
|
|
if sender.startswith('<') and sender.endswith('>'):
|
|
|
|
return flask.jsonify("REJECT") if models.Domain.query.get(domain_name) else flask.abort(404)
|
|
|
|
sender = sender[1:-1]
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
return flask.abort(404)
|
|
|
|
localpart, domain_name = models.Email.resolve_domain(sender)
|
|
|
|
|
|
|
|
if models.Domain.query.get(domain_name):
|
|
|
|
|
|
|
|
return flask.jsonify("REJECT")
|
|
|
|
def is_void_address(email):
|
|
|
|
except sqlalchemy.exc.StatementError:
|
|
|
|
'''True if the email is void (null) email address.
|
|
|
|
pass
|
|
|
|
'''
|
|
|
|
return flask.abort(404)
|
|
|
|
if email.startswith('<') and email.endswith('>'):
|
|
|
|
|
|
|
|
email = email[1:-1]
|
|
|
|
|
|
|
|
# Some MTAs use things like '<MAILER-DAEMON>' instead of '<>'; so let's
|
|
|
|
|
|
|
|
# consider void any such thing.
|
|
|
|
|
|
|
|
return '@' not in email
|
|
|
|
|
|
|
|