mirror of
https://github.com/Mailu/Mailu.git
synced 2025-01-12 02:28:20 +02:00
Merge #940
940: Fix host variables r=mergify[bot] a=ionutfilip ## What type of PR? bug-fix ## What does this PR do? ### Related issue(s) - Fix #884 ## Prerequistes Before we can consider review and merge, please make sure the following list is done and checked. If an entry in not applicable, you can check it or remove it from the list. - [x] In case of feature or enhancement: documentation updated accordingly - [x] Unless it's docs or a minor change: place entry in the [changelog](CHANGELOG.md), under the latest un-released version. Co-authored-by: Ionut Filip <ionut.philip@gmail.com> Co-authored-by: Tim Möhlmann <muhlemmer@gmail.com>
This commit is contained in:
commit
3e626b8500
@ -52,13 +52,19 @@ DEFAULT_CONFIG = {
|
||||
'RECAPTCHA_PRIVATE_KEY': '',
|
||||
# Advanced settings
|
||||
'PASSWORD_SCHEME': 'BLF-CRYPT',
|
||||
'LOG_LEVEL': 'WARNING',
|
||||
# Host settings
|
||||
'HOST_IMAP': 'imap',
|
||||
'HOST_LMTP': 'imap:2525',
|
||||
'HOST_POP3': 'imap',
|
||||
'HOST_SMTP': 'smtp',
|
||||
'HOST_AUTHSMTP': 'smtp',
|
||||
'HOST_ADMIN': 'admin',
|
||||
'HOST_ANTISPAM': 'antispam:11334',
|
||||
'HOST_WEBMAIL': 'webmail',
|
||||
'HOST_WEBDAV': 'webdav:5232',
|
||||
'HOST_REDIS': 'redis',
|
||||
'HOST_FRONT': 'front',
|
||||
'HOST_AUTHSMTP': os.environ.get('HOST_SMTP', 'smtp'),
|
||||
'SUBNET': '192.168.203.0/24',
|
||||
'POD_ADDRESS_RANGE': None
|
||||
}
|
||||
@ -73,7 +79,7 @@ class ConfigManager(dict):
|
||||
'mysql': 'mysql://{DB_USER}:{DB_PW}@{DB_HOST}/{DB_NAME}'
|
||||
}
|
||||
|
||||
HOSTS = ('IMAP', 'POP3', 'AUTHSMTP', 'SMTP')
|
||||
HOSTS = ('IMAP', 'POP3', 'AUTHSMTP', 'SMTP', 'REDIS')
|
||||
OPTIONAL_HOSTS = ('WEBMAIL', 'ANTISPAM')
|
||||
|
||||
def __init__(self):
|
||||
@ -83,7 +89,8 @@ class ConfigManager(dict):
|
||||
optional = [item for item in self.OPTIONAL_HOSTS if item in self.config and self.config[item] != "none"]
|
||||
for item in list(self.HOSTS) + optional:
|
||||
host = 'HOST_' + item
|
||||
self.config[host] = system.resolve_address(self.config[host])
|
||||
address = item + '_ADDRESS'
|
||||
self.config[address] = system.resolve_address(self.config[host])
|
||||
|
||||
def __coerce_value(self, value):
|
||||
if isinstance(value, str) and value.lower() in ('true','yes'):
|
||||
@ -105,6 +112,9 @@ class ConfigManager(dict):
|
||||
if self.config['DB_FLAVOR']:
|
||||
template = self.DB_TEMPLATES[self.config['DB_FLAVOR']]
|
||||
self.config['SQLALCHEMY_DATABASE_URI'] = template.format(**self.config)
|
||||
|
||||
self.config['RATELIMIT_STORAGE_URL'] = 'redis://{0}/2'.format(self.config['REDIS_ADDRESS'])
|
||||
self.config['QUOTA_STORAGE_URL'] = 'redis://{0}/1'.format(self.config['REDIS_ADDRESS'])
|
||||
# update the app config itself
|
||||
app.config = self
|
||||
|
||||
|
@ -80,12 +80,12 @@ def extract_host_port(host_and_port, default_port):
|
||||
|
||||
def get_server(protocol, authenticated=False):
|
||||
if protocol == "imap":
|
||||
hostname, port = extract_host_port(app.config['HOST_IMAP'], 143)
|
||||
hostname, port = extract_host_port(app.config['IMAP_ADDRESS'], 143)
|
||||
elif protocol == "pop3":
|
||||
hostname, port = extract_host_port(app.config['HOST_POP3'], 110)
|
||||
hostname, port = extract_host_port(app.config['POP3_ADDRESS'], 110)
|
||||
elif protocol == "smtp":
|
||||
if authenticated:
|
||||
hostname, port = extract_host_port(app.config['HOST_AUTHSMTP'], 10025)
|
||||
hostname, port = extract_host_port(app.config['AUTHSMTP_ADDRESS'], 10025)
|
||||
else:
|
||||
hostname, port = extract_host_port(app.config['HOST_SMTP'], 25)
|
||||
hostname, port = extract_host_port(app.config['SMTP_ADDRESS'], 25)
|
||||
return hostname, port
|
||||
|
@ -21,11 +21,11 @@ def start_podop():
|
||||
])
|
||||
|
||||
# Actual startup script
|
||||
os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("FRONT_ADDRESS", "front"))
|
||||
os.environ["REDIS_ADDRESS"] = system.resolve_address(os.environ.get("REDIS_ADDRESS", "redis"))
|
||||
os.environ["ADMIN_ADDRESS"] = system.resolve_address(os.environ.get("ADMIN_ADDRESS", "admin"))
|
||||
os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("HOST_FRONT", "front"))
|
||||
os.environ["REDIS_ADDRESS"] = system.resolve_address(os.environ.get("HOST_REDIS", "redis"))
|
||||
os.environ["ADMIN_ADDRESS"] = system.resolve_address(os.environ.get("HOST_ADMIN", "admin"))
|
||||
if os.environ["WEBMAIL"] != "none":
|
||||
os.environ["WEBMAIL_ADDRESS"] = system.resolve_address(os.environ.get("WEBMAIL_ADDRESS", "webmail"))
|
||||
os.environ["WEBMAIL_ADDRESS"] = system.resolve_address(os.environ.get("HOST_WEBMAIL", "webmail"))
|
||||
|
||||
for dovecot_file in glob.glob("/conf/*.conf"):
|
||||
conf.jinja(dovecot_file, os.environ, os.path.join("/etc/dovecot", os.path.basename(dovecot_file)))
|
||||
|
@ -41,10 +41,14 @@ http {
|
||||
# Favicon stuff
|
||||
root /static;
|
||||
# Variables for proxifying
|
||||
set $admin {{ HOST_ADMIN }};
|
||||
set $antispam {{ HOST_ANTISPAM }};
|
||||
set $webmail {{ HOST_WEBMAIL }};
|
||||
set $webdav {{ HOST_WEBDAV }};
|
||||
set $admin {{ ADMIN_ADDRESS }};
|
||||
set $antispam {{ ANTISPAM_ADDRESS }};
|
||||
{% if WEBMAIL_ADDRESS %}
|
||||
set $webmail {{ WEBMAIL_ADDRESS }};
|
||||
{% endif %}
|
||||
{% if WEBDAV_ADDRESS %}
|
||||
set $webdav {{ WEBDAV_ADDRESS }};
|
||||
{% endif %}
|
||||
|
||||
# Always listen over HTTP
|
||||
listen 80;
|
||||
@ -168,7 +172,7 @@ http {
|
||||
# Forwarding authentication server
|
||||
server {
|
||||
# Variables for proxifying
|
||||
set $admin {{ HOST_ADMIN }};
|
||||
set $admin {{ ADMIN_ADDRESS }};
|
||||
|
||||
listen 127.0.0.1:8000;
|
||||
|
||||
|
@ -14,14 +14,14 @@ with open("/etc/resolv.conf") as handle:
|
||||
content = handle.read().split()
|
||||
args["RESOLVER"] = content[content.index("nameserver") + 1]
|
||||
|
||||
args["HOST_ADMIN"] = system.resolve_address(args.get("HOST_ADMIN", "admin"))
|
||||
args["HOST_ANTISPAM"] = system.resolve_address(args.get("HOST_ANTISPAM", "antispam:11334"))
|
||||
args["ADMIN_ADDRESS"] = system.resolve_address(args.get("HOST_ADMIN", "admin"))
|
||||
args["ANTISPAM_ADDRESS"] = system.resolve_address(args.get("HOST_ANTISPAM", "antispam:11334"))
|
||||
args["HOST_WEBMAIL"] = args.get("HOST_WEBMAIL", "webmail")
|
||||
if args["WEBMAIL"] != "none":
|
||||
args["HOST_WEBMAIL"] = system.resolve_address(args.get("HOST_WEBMAIL"))
|
||||
args["WEBMAIL_ADDRESS"] = system.resolve_address(args.get("HOST_WEBMAIL"))
|
||||
args["HOST_WEBDAV"] = args.get("HOST_WEBDAV", "webdav:5232")
|
||||
if args["WEBDAV"] != "none":
|
||||
args["HOST_WEBDAV"] = system.resolve_address(args.get("HOST_WEBDAV"))
|
||||
args["WEBDAV_ADDRESS"] = system.resolve_address(args.get("HOST_WEBDAV"))
|
||||
|
||||
# TLS configuration
|
||||
cert_name = os.getenv("TLS_CERT_FILENAME", default="cert.pem")
|
||||
|
@ -73,7 +73,7 @@ virtual_mailbox_maps = ${podop}mailbox
|
||||
# Mails are transported if required, then forwarded to Dovecot for delivery
|
||||
relay_domains = ${podop}transport
|
||||
transport_maps = ${podop}transport
|
||||
virtual_transport = lmtp:inet:{{ HOST_LMTP }}
|
||||
virtual_transport = lmtp:inet:{{ LMTP_ADDRESS }}
|
||||
|
||||
# In order to prevent Postfix from running DNS query, enforce the use of the
|
||||
# native DNS stack, that will check /etc/hosts properly.
|
||||
@ -112,7 +112,7 @@ unverified_recipient_reject_reason = Address lookup failure
|
||||
# Milter
|
||||
###############
|
||||
|
||||
smtpd_milters = inet:{{ HOST_ANTISPAM }}
|
||||
smtpd_milters = inet:{{ ANTISPAM_ADDRESS }}
|
||||
milter_protocol = 6
|
||||
milter_mail_macros = i {mail_addr} {client_addr} {client_name} {auth_authen}
|
||||
milter_default_action = tempfail
|
||||
|
@ -26,10 +26,10 @@ def start_podop():
|
||||
])
|
||||
|
||||
# Actual startup script
|
||||
os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("FRONT_ADDRESS", "front"))
|
||||
os.environ["ADMIN_ADDRESS"] = system.resolve_address(os.environ.get("ADMIN_ADDRESS", "admin"))
|
||||
os.environ["HOST_ANTISPAM"] = system.resolve_address(os.environ.get("HOST_ANTISPAM", "antispam:11332"))
|
||||
os.environ["HOST_LMTP"] = system.resolve_address(os.environ.get("HOST_LMTP", "imap:2525"))
|
||||
os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("HOST_FRONT", "front"))
|
||||
os.environ["ADMIN_ADDRESS"] = system.resolve_address(os.environ.get("HOST_ADMIN", "admin"))
|
||||
os.environ["ANTISPAM_ADDRESS"] = system.resolve_address(os.environ.get("HOST_ANTISPAM", "antispam:11332"))
|
||||
os.environ["LMTP_ADDRESS"] = system.resolve_address(os.environ.get("HOST_LMTP", "imap:2525"))
|
||||
|
||||
for postfix_file in glob.glob("/conf/*.cf"):
|
||||
conf.jinja(postfix_file, os.environ, os.path.join("/etc/postfix", os.path.basename(postfix_file)))
|
||||
|
@ -1 +1 @@
|
||||
servers = "{{ HOST_REDIS }}";
|
||||
servers = "{{ REDIS_ADDRESS }}";
|
||||
|
@ -1 +1 @@
|
||||
servers = "{{ HOST_REDIS }}";
|
||||
servers = "{{ REDIS_ADDRESS }}";
|
||||
|
@ -9,9 +9,11 @@ from socrate import system, conf
|
||||
log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING"))
|
||||
|
||||
# Actual startup script
|
||||
os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("FRONT_ADDRESS", "front"))
|
||||
os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("HOST_FRONT", "front"))
|
||||
|
||||
if "HOST_REDIS" not in os.environ:
|
||||
os.environ["REDIS_ADDRESS"] = system.resolve_address(os.environ.get("HOST_REDIS", "redis"))
|
||||
|
||||
if "HOST_REDIS" not in os.environ: os.environ["HOST_REDIS"] = "redis"
|
||||
|
||||
for rspamd_file in glob.glob("/conf/*"):
|
||||
conf.jinja(rspamd_file, os.environ, os.path.join("/etc/rspamd/local.d", os.path.basename(rspamd_file)))
|
||||
|
1
towncrier/newsfragments/884.bugfix
Normal file
1
towncrier/newsfragments/884.bugfix
Normal file
@ -0,0 +1 @@
|
||||
Fix HOST_* variable usage
|
@ -9,8 +9,8 @@ from socrate import system, conf
|
||||
log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING"))
|
||||
|
||||
# Actual startup script
|
||||
os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("FRONT_ADDRESS", "front"))
|
||||
os.environ["IMAP_ADDRESS"] = system.resolve_address(os.environ.get("IMAP_ADDRESS", "imap"))
|
||||
os.environ["FRONT_ADDRESS"] = system.resolve_address(os.environ.get("HOST_FRONT", "front"))
|
||||
os.environ["IMAP_ADDRESS"] = system.resolve_address(os.environ.get("HOST_IMAP", "imap"))
|
||||
|
||||
os.environ["MAX_FILESIZE"] = str(int(int(os.environ.get("MESSAGE_SIZE_LIMIT"))*0.66/1048576))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user