@@ -49,6 +49,9 @@ if [ "${SMTP_PORT}" = "465" ]; then
49
49
add_config_value " smtp_tls_security_level" " encrypt"
50
50
fi
51
51
52
+ # Bind to both IPv4 and IPv4
53
+ add_config_value " inet_protocols" " all"
54
+
52
55
# Create sasl_passwd file with auth credentials
53
56
if [ ! -f /etc/postfix/sasl_passwd -a ! -z " ${SMTP_USERNAME} " ]; then
54
57
grep -q " ${SMTP_SERVER} " /etc/postfix/sasl_passwd > /dev/null 2>&1
76
79
# Check for subnet restrictions
77
80
nets=' 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16'
78
81
if [ ! -z " ${SMTP_NETWORKS} " ]; then
79
- for i in $( sed ' s/,/\ /g' <<< $SMTP_NETWORKS ) ; do
80
- if grep -Eq " [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]{1,2}" <<< $i ; then
81
- nets+=" , $i "
82
- else
83
- echo " $i is not in proper IPv4 subnet format. Ignoring."
84
- fi
85
- done
82
+ declare ipv6re=" ^((([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|\
83
+ ([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|\
84
+ ([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|\
85
+ ([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|\
86
+ :((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}|\
87
+ ::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|\
88
+ (2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|\
89
+ (2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/[0-9]{1,3})$"
90
+
91
+ for i in $( sed ' s/,/\ /g' <<< $SMTP_NETWORKS ) ; do
92
+ if grep -Eq " [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]{1,2}" <<< $i ; then
93
+ nets+=" , $i "
94
+ elif grep -Eq " $ipv6re " <<< $i ; then
95
+ readarray -d \/ -t arr < <( printf ' %s' " $i " )
96
+ nets+=" , [${arr[0]} ]/${arr[1]} "
97
+ else
98
+ echo " $i is not in proper IPv4 or IPv6 subnet format. Ignoring."
99
+ fi
100
+ done
86
101
fi
87
102
add_config_value " mynetworks" " ${nets} "
88
103
0 commit comments