Commit 7b9d16d2 authored by kaiyou's avatar kaiyou Committed by ayiniho
Browse files

Support calling an external API for resolving aliases

parent 7b2774d2
......@@ -17,6 +17,7 @@ import passlib.registry
import time
import os
import smtplib
import requests
import idna
import dns.resolver
import dns.exception
......@@ -187,6 +188,7 @@ class Domain(Base):
backref=db.backref('manager_of'), lazy='dynamic')
max_users = db.Column(db.Integer, nullable=False, default=-1)
max_aliases = db.Column(db.Integer, nullable=False, default=-1)
<<<<<<< HEAD
max_quota_bytes = db.Column(db.BigInteger, nullable=False, default=0)
signup_enabled = db.Column(db.Boolean, nullable=False, default=False)
......@@ -276,7 +278,16 @@ class Domain(Base):
hostname = app.config['HOSTNAME']
if app.config['TLS_FLAVOR'] in ('letsencrypt', 'mail-letsencrypt'):
# current ISRG Root X1 (RSA 4096, O = Internet Security Research Group, CN = ISRG Root X1) @20210902
<<<<<<< HEAD
return f'_25._tcp.{hostname}. 86400 IN TLSA 2 1 1 0b9fa5a59eed715c26c1020c711b4f6ec42d58b0015e14337a39dad301c5afc3'
=======
return f'_25._tcp.{hostname}. 86400 IN TLSA 2 1 0 30820222300d06092a864886f70d01010105000382020f003082020a0282020100ade82473f41437f39b9e2b57281c87bedcb7df38908c6e3ce657a078f775c2a2fef56a6ef6004f28dbde68866c4493b6b163fd14126bbf1fd2ea319b217ed1333cba48f5dd79dfb3b8ff12f1219a4bc18a8671694a66666c8f7e3c70bfad292206f3e4c0e680aee24b8fb7997e94039fd347977c99482353e838ae4f0a6f832ed149578c8074b6da2fd0388d7b0370211b75f2303cfa8faeddda63abeb164fc28e114b7ecf0be8ffb5772ef4b27b4ae04c12250c708d0329a0e15324ec13d9ee19bf10b34a8c3f89a36151deac870794f46371ec2ee26f5b9881e1895c34796c76ef3b906279e6dba49a2f26c5d010e10eded9108e16fbb7f7a8f7c7e50207988f360895e7e237960d36759efb0e72b11d9bbc03f94905d881dd05b42ad641e9ac0176950a0fd8dfd5bd121f352f28176cd298c1a80964776e4737baceac595e689d7f72d689c50641293e593edd26f524c911a75aa34c401f46a199b5a73a516e863b9e7d72a712057859ed3e5178150b038f8dd02f05b23e7b4a1c4b730512fcc6eae050137c439374b3ca74e78e1f0108d030d45b7136b407bac130305c48b7823b98a67d608aa2a32982ccbabd83041ba2830341a1d605f11bc2b6f0a87c863b46a8482a88dc769a76bf1f6aa53d198feb38f364dec82b0d0a28fff7dbe21542d422d0275de179fe18e77088ad4ee6d98b3ac6dd27516effbc64f533434f0203010001'
=======
max_quota_bytes = db.Column(db.BigInteger(), nullable=False, default=0)
signup_enabled = db.Column(db.Boolean(), nullable=False, default=False)
alias_delegation_api = db.Column(db.String(255))
>>>>>>> Support calling an external API for resolving aliases
>>>>>>> Support calling an external API for resolving aliases
@property
def dkim_key(self):
......@@ -318,6 +329,11 @@ class Domain(Base):
return True
return False
def delegate_alias(self, localpart):
return requests.get(
self.alias_delegation_api.format(localpart)
).json() or None
def check_mx(self):
""" checks if MX record for domain points to mailu host """
try:
......@@ -435,10 +451,20 @@ class Email(object):
localpart_stripped = None
stripped_alias = None
delimiter = os.environ.get('RECIPIENT_DELIMITER')
if delimiter in localpart:
localpart_stripped = localpart.rsplit(delimiter, 1)[0]
<<<<<<< HEAD
delim = os.environ.get('RECIPIENT_DELIMITER')
if delim in localpart:
localpart_stripped = localpart.rsplit(delim, 1)[0]
=======
domain = Domain.query.get(domain_name)
if domain and domain.alias_delegation_api:
return domain.delegate_alias(localpart)
>>>>>>> Support calling an external API for resolving aliases
user = User.query.get(f'{localpart}@{domain_name}')
if not user and localpart_stripped:
......
<<<<<<< HEAD
alembic==1.7.4
appdirs==1.4.4
Babel==2.9.1
......@@ -73,3 +74,58 @@ webencodings==0.5.1
Werkzeug==2.0.2
WTForms==2.3.3
WTForms-Components==0.10.5
=======
alembic==1.3.2
Babel==2.7.0
bcrypt==3.1.7
blinker==1.4
certifi==2019.11.28
cffi==1.13.2
chardet==3.0.4
Click==7.0
cryptography==3.2
decorator==4.4.1
dnspython==1.16.0
dominate==2.4.0
Flask==1.1.1
Flask-Babel==0.12.2
Flask-Bootstrap==3.3.7.1
Flask-DebugToolbar==0.10.1
Flask-Limiter==1.1.0
Flask-Login==0.4.1
Flask-Migrate==2.5.2
Flask-Script==2.0.6
Flask-SQLAlchemy==2.4.1
Flask-WTF==0.14.2
gunicorn==19.9.0
idna==2.8
infinity==1.4
intervals==0.8.1
itsdangerous==1.1.0
Jinja2==2.10.3
limits==1.4.1
Mako==1.1.0
MarkupSafe==1.1.1
mysqlclient==1.4.6
passlib==1.7.2
psycopg2==2.8.4
pycparser==2.19
pyOpenSSL==19.1.0
python-dateutil==2.8.1
python-editor==1.0.4
srslib==0.1.4
pytz==2019.3
PyYAML==5.2
redis==3.3.11
requests==2.22.0
socrate==0.2.0
SQLAlchemy==1.3.12
tabulate==0.8.6
tenacity==6.0.0
urllib3==1.25.7
validators==0.14.1
visitor==0.1.3
Werkzeug==0.16.0
WTForms==2.2.1
WTForms-Components==0.10.4
>>>>>>> Support calling an external API for resolving aliases
......@@ -8,6 +8,8 @@ Flask-script
Flask-wtf
Flask-debugtoolbar
limits
Flask-limiter
requests
redis
WTForms-Components
socrate
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment