1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

courier: Use DNSError.IsNotFound to identify NXDOMAIN

When resolving MX records, we need to distinguish between "no such
domain" and other kinds of errors. Before Go 1.13, this was not
possible, so we had a workaround that assumed any permanent error was a
"no such domain", which is not great, but functional.

Now that our minimum supported version is Go 1.15, we can remove the
workaround.

This patch replaces the workaround with proper logic using
DNSError.IsNotFound to identify NXDOMAIN results when resolving MX
records.

This requires to adjust a few tests, that used to work on environments
where resolving unknown domains (used for testing) returned a permanent
error, and now they no longer do so. Instead of relying on this
environmental property, we make the affected tests use our own DNS
server, which should make them more hermetic and reproducible.
This commit is contained in:
Alberto Bertogli
2021-10-08 23:03:49 +01:00
parent 6633f0785c
commit ed38945fca
10 changed files with 58 additions and 17 deletions

View File

@@ -8,6 +8,12 @@ check_hostaliases
rm -rf .data-A .data-B .mail
# Build with the DNS override, so we can fake DNS records.
export GOTAGS="dnsoverride"
# Launch minidns in the background using our configuration.
minidns_bg --addr=":9053" -zones=zones >> .minidns.log 2>&1
# Two servers:
# A - listens on :1025, hosts srv-A
# B - listens on :2015, hosts srv-B
@@ -23,13 +29,16 @@ CONFDIR=B generate_certs_for srv-B
mkdir -p .logs-A .logs-B
chasquid -v=2 --logfile=.logs-A/chasquid.log --config_dir=A \
--testing__dns_addr=127.0.0.1:9053 \
--testing__max_received_headers=5 \
--testing__outgoing_smtp_port=2025 &
chasquid -v=2 --logfile=.logs-B/chasquid.log --config_dir=B \
--testing__dns_addr=127.0.0.1:9053 \
--testing__outgoing_smtp_port=1025 &
wait_until_ready 1025
wait_until_ready 2025
wait_until_ready 9053
run_msmtp aliasB@srv-B < content

4
test/t-09-loop/zones Normal file
View File

@@ -0,0 +1,4 @@
srv-a A 127.0.0.1
srv-a AAAA ::1
srv-b A 127.0.0.1
srv-b AAAA ::1