From 7c07efc216138eb4d7402c530e8f4173787ccf53 Mon Sep 17 00:00:00 2001 From: Ionut Filip Date: Tue, 23 Oct 2018 15:42:19 +0300 Subject: [PATCH] Added unbound to setup - Added checkbox for unbound resolver - Added subnet variable - Added dns variable which is generating the ip address based on subnet --- setup/flavors/compose/docker-compose.yml | 44 ++++++++++++++++++++ setup/flavors/compose/mailu.env | 3 ++ setup/server.py | 2 + setup/templates/steps/compose/03_expose.html | 13 ++++++ setup/templates/steps/stack/03_expose.html | 3 +- 5 files changed, 64 insertions(+), 1 deletion(-) diff --git a/setup/flavors/compose/docker-compose.yml b/setup/flavors/compose/docker-compose.yml index b01bb8fd..4fef7468 100644 --- a/setup/flavors/compose/docker-compose.yml +++ b/setup/flavors/compose/docker-compose.yml @@ -28,6 +28,15 @@ services: {% endfor %} volumes: - "{{ root }}/certs:/certs" + + {% if resolver_enabled %} + resolver: + image: mailu/resolver:{{ version }} + restart: always + networks: + default: + ipv4_address: {{ dns }} + {% endif %} admin: image: mailu/admin:{{ version }} @@ -58,6 +67,11 @@ services: - "{{ root }}/overrides:/overrides" depends_on: - front + {% if resolver_enabled %} + - resolver + dns: + - {{ dns }} + {% endif %} # Optional services {% if antispam_enabled %} @@ -70,6 +84,11 @@ services: - "{{ root }}/overrides/rspamd:/etc/rspamd/override.d" depends_on: - front + {% if resolver_enabled %} + - resolver + dns: + - {{ dns }} + {% endif %} {% endif %} {% if antivirus_enabled %} @@ -78,6 +97,12 @@ services: env_file: {{ env }} volumes: - "{{ root }}/filter:/data" + {% if resolver_enabled %} + depends_on: + - resolver + dns: + - {{ dns }} + {% endif %} {% endif %} {% if webdav_enabled %} @@ -92,6 +117,12 @@ services: fetchmail: image: mailu/fetchmail:{{ version }} env_file: {{ env }} + {% if resolver_enabled %} + depends_on: + - resolver + dns: + - {{ dns }} + {% endif %} {% endif %} # Webmail @@ -103,4 +134,17 @@ services: - "{{ root }}/webmail:/data" depends_on: - imap + - resolver + dns: + - {{ dns }} {% endif %} + +{% if resolver_enabled %} +networks: + default: + driver: bridge + ipam: + driver: default + config: + - subnet: {{ subnet }} +{% endif %} diff --git a/setup/flavors/compose/mailu.env b/setup/flavors/compose/mailu.env index 9fc1197d..425f4cad 100644 --- a/setup/flavors/compose/mailu.env +++ b/setup/flavors/compose/mailu.env @@ -25,6 +25,9 @@ SECRET_KEY={{ secret(16) }} # PUBLIC_IPV4= {{ bind4 }} (default: 127.0.0.1) # PUBLIC_IPV6= {{ bind6 }} (default: ::1) +# Subnet +# SUBNET={{ subnet }} + # Main mail domain DOMAIN={{ domain }} diff --git a/setup/server.py b/setup/server.py index bfe5ef15..6f60c3c0 100644 --- a/setup/server.py +++ b/setup/server.py @@ -7,6 +7,7 @@ import jinja2 import uuid import string import random +import ipaddress app = flask.Flask(__name__) @@ -75,6 +76,7 @@ def build_app(path): def submit(): data = flask.request.form.copy() data['uid'] = str(uuid.uuid4()) + data['dns'] = str(ipaddress.IPv4Network(data['subnet'])[-2]) db.set(data['uid'], json.dumps(data)) return flask.redirect(flask.url_for('.setup', uid=data['uid'])) diff --git a/setup/templates/steps/compose/03_expose.html b/setup/templates/steps/compose/03_expose.html index df121c7d..783c2037 100644 --- a/setup/templates/steps/compose/03_expose.html +++ b/setup/templates/steps/compose/03_expose.html @@ -26,6 +26,19 @@ avoid generic all-interfaces addresses like 0.0.0.0 or :: +
+ +
+ +
+ + +
+

You server will be available under a main hostname but may expose multiple public hostnames. Every e-mail domain that points to this server must have one of the hostnames in its MX record. Hostnames must be coma-separated.

diff --git a/setup/templates/steps/stack/03_expose.html b/setup/templates/steps/stack/03_expose.html index a9cffc1c..1cd0cde5 100644 --- a/setup/templates/steps/stack/03_expose.html +++ b/setup/templates/steps/stack/03_expose.html @@ -5,7 +5,8 @@ you expose it to the world.

- +

You server will be available under a main hostname but may expose multiple public