You've already forked Mailu
mirror of
https://github.com/Mailu/Mailu.git
synced 2025-07-03 00:47:16 +02:00
Resolve hosts in admin
This commit is contained in:
committed by
Tim Möhlmann
parent
004a431e97
commit
f8dffe5a19
@ -1,8 +1,9 @@
|
|||||||
FROM alpine:3.8
|
FROM alpine:3.8
|
||||||
# python3 shared with most images
|
# python3 shared with most images
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
python3 py3-pip \
|
python3 py3-pip git \
|
||||||
&& pip3 install --upgrade pip
|
&& pip3 install --upgrade pip
|
||||||
|
RUN pip3 install git+https://github.com/usrpro/MailuStart.git#egg=mailustart
|
||||||
# Image specific layers under this line
|
# Image specific layers under this line
|
||||||
RUN mkdir -p /app
|
RUN mkdir -p /app
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
from mailustart import resolve
|
||||||
|
|
||||||
DEFAULT_CONFIG = {
|
DEFAULT_CONFIG = {
|
||||||
# Specific to the admin UI
|
# Specific to the admin UI
|
||||||
@ -60,7 +60,6 @@ DEFAULT_CONFIG = {
|
|||||||
'POD_ADDRESS_RANGE': None
|
'POD_ADDRESS_RANGE': None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class ConfigManager(dict):
|
class ConfigManager(dict):
|
||||||
""" Naive configuration manager that uses environment only
|
""" Naive configuration manager that uses environment only
|
||||||
"""
|
"""
|
||||||
@ -74,6 +73,12 @@ class ConfigManager(dict):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.config = dict()
|
self.config = dict()
|
||||||
|
|
||||||
|
def resolve_host(self):
|
||||||
|
self.config['HOST_IMAP'] = resolve(self.config['HOST_IMAP'])
|
||||||
|
self.config['HOST_POP3'] = resolve(self.config['HOST_POP3'])
|
||||||
|
self.config['HOST_AUTHSMTP'] = resolve(self.config['HOST_AUTHSMTP'])
|
||||||
|
self.config['HOST_SMTP'] = resolve(self.config['HOST_SMTP'])
|
||||||
|
|
||||||
def __coerce_value(self, value):
|
def __coerce_value(self, value):
|
||||||
if isinstance(value, str) and value.lower() in ('true','yes'):
|
if isinstance(value, str) and value.lower() in ('true','yes'):
|
||||||
return True
|
return True
|
||||||
@ -88,6 +93,7 @@ class ConfigManager(dict):
|
|||||||
key: self.__coerce_value(os.environ.get(key, value))
|
key: self.__coerce_value(os.environ.get(key, value))
|
||||||
for key, value in DEFAULT_CONFIG.items()
|
for key, value in DEFAULT_CONFIG.items()
|
||||||
})
|
})
|
||||||
|
self.resolve_host()
|
||||||
|
|
||||||
# automatically set the sqlalchemy string
|
# automatically set the sqlalchemy string
|
||||||
if self.config['DB_FLAVOR']:
|
if self.config['DB_FLAVOR']:
|
||||||
|
@ -2,7 +2,6 @@ from mailu import models
|
|||||||
from flask import current_app as app
|
from flask import current_app as app
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import socket
|
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
|
|
||||||
@ -89,5 +88,4 @@ def get_server(protocol, authenticated=False):
|
|||||||
hostname, port = extract_host_port(app.config['HOST_AUTHSMTP'], 10025)
|
hostname, port = extract_host_port(app.config['HOST_AUTHSMTP'], 10025)
|
||||||
else:
|
else:
|
||||||
hostname, port = extract_host_port(app.config['HOST_SMTP'], 25)
|
hostname, port = extract_host_port(app.config['HOST_SMTP'], 25)
|
||||||
address = socket.gethostbyname(hostname)
|
return hostname, port
|
||||||
return address, port
|
|
||||||
|
@ -14,10 +14,14 @@ with open("/etc/resolv.conf") as handle:
|
|||||||
content = handle.read().split()
|
content = handle.read().split()
|
||||||
args["RESOLVER"] = content[content.index("nameserver") + 1]
|
args["RESOLVER"] = content[content.index("nameserver") + 1]
|
||||||
|
|
||||||
args["HOST_WEBMAIL"] = resolve(args.get("HOST_WEBMAIL", "webmail"))
|
|
||||||
args["HOST_ADMIN"] = resolve(args.get("HOST_ADMIN", "admin"))
|
args["HOST_ADMIN"] = resolve(args.get("HOST_ADMIN", "admin"))
|
||||||
args["HOST_WEBDAV"] = resolve(args.get("HOST_WEBDAV", "webdav:5232"))
|
|
||||||
args["HOST_ANTISPAM"] = resolve(args.get("HOST_ANTISPAM", "antispam:11334"))
|
args["HOST_ANTISPAM"] = resolve(args.get("HOST_ANTISPAM", "antispam:11334"))
|
||||||
|
args["HOST_WEBMAIL"] = args.get("HOST_WEBMAIL", "webmail")
|
||||||
|
if args["WEBMAIL"] != "none":
|
||||||
|
args["HOST_WEBMAIL"] = resolve(args.get("HOST_WEBMAIL"))
|
||||||
|
args["HOST_WEBDAV"] = args.get("HOST_WEBDAV", "webdav:5232")
|
||||||
|
if args["WEBDAV"] != "none":
|
||||||
|
args["HOST_WEBDAV"] = resolve(args.get("HOST_WEBDAV"))
|
||||||
|
|
||||||
# TLS configuration
|
# TLS configuration
|
||||||
cert_name = os.getenv("TLS_CERT_FILENAME", default="cert.pem")
|
cert_name = os.getenv("TLS_CERT_FILENAME", default="cert.pem")
|
||||||
|
Reference in New Issue
Block a user