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