From 6a69f7e530ce027d8cfce057aab24dab58cca264 Mon Sep 17 00:00:00 2001
From: Janne Mareike Koschinski <janne@kuschku.de>
Date: Sat, 30 Apr 2022 22:51:04 +0200
Subject: [PATCH] fix: correct issues with subnets

---
 templates/configmap-global.yaml | 2 +-
 templates/configmap-smtp.yaml   | 4 ++--
 templates/deploy-admin.yaml     | 9 ++++-----
 values.yaml                     | 2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/templates/configmap-global.yaml b/templates/configmap-global.yaml
index 4c4803d..76ba6e9 100644
--- a/templates/configmap-global.yaml
+++ b/templates/configmap-global.yaml
@@ -30,7 +30,7 @@ data:
   RECIPIENT_DELIMITER: "{{ .Values.config.recipientDelimiter }}"
   SITENAME: "{{ .Values.config.siteName }}"
   SUBNET: "{{ .Values.config.subnet }}"
-  SUBNET_ADMIN: "{{ .Values.admin.subnet }}"
+  SUBNET_EXTERNAL: "{{ .Values.config.subnet_external }}"
   TLS_FLAVOR: "mail"
   VERSION: "{{ .Values.image.tag | default .Chart.AppVersion }}"
   WEBDAV: "radicale"
diff --git a/templates/configmap-smtp.yaml b/templates/configmap-smtp.yaml
index 0689d93..fc35d02 100644
--- a/templates/configmap-smtp.yaml
+++ b/templates/configmap-smtp.yaml
@@ -27,8 +27,8 @@ data:
     smtpd_tls_ciphers = high
     smtpd_tls_mandatory_ciphers = high
     # Relayed networks
-    mynetworks=127.0.0.1/32 [::1]/128 10.244.0.0/16 116.202.227.171/32
-    smtpd_authorized_xclient_hosts=10.244.0.0/16 116.202.227.171/32
+    mynetworks=127.0.0.1/32 [::1]/128 {{ .Values.config.subnet }} {{ .Values.config.subnet_external }}/32
+    smtpd_authorized_xclient_hosts={{ .Values.config.subnet }} {{ .Values.config.subnet_external }}/32
 
     postscreen_upstream_proxy_protocol = haproxy
     postscreen_upstream_proxy_protocol = haproxy
diff --git a/templates/deploy-admin.yaml b/templates/deploy-admin.yaml
index 538e466..5708112 100644
--- a/templates/deploy-admin.yaml
+++ b/templates/deploy-admin.yaml
@@ -49,11 +49,10 @@ spec:
                 name: {{ include "mailu-helm.fullname" . }}
           env:
             - name: SUBNET
-              value: 116.202.227.171
-              #valueFrom:
-              #  configMapKeyRef:
-              #    name: {{ include "mailu-helm.fullname" . }}
-              #    key: SUBNET_ADMIN
+              valueFrom:
+                configMapKeyRef:
+                  name: {{ include "mailu-helm.fullname" . }}
+                  key: SUBNET_EXTERNAL
           ports:
             - name: "http"
               containerPort: 80
diff --git a/values.yaml b/values.yaml
index 9082169..4d77aa0 100644
--- a/values.yaml
+++ b/values.yaml
@@ -21,6 +21,7 @@ config:
   recipientDelimiter: "+"
   siteName: "Example.com Mail"
   subnet: "10.42.0.0/16"
+  subnet_external: "1.2.3.4"
 
 welcome:
   enabled: false
@@ -75,7 +76,6 @@ admin:
   enabled: true
   host: "mail.example.com"
   path: "/admin"
-  subnet: "10.42.0.0/16"
   resources:
     limits:
       cpu: 500m
-- 
GitLab