chatmail / chatmail/core

Core appears to revert to old, outdated and wrong DNS of hostname too eagerly, triggered by brief wifi outage

Open
#7,901 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
929
Forks
143
Avg merge
1d 20h
Merged PRs (30d)
53

Description

- Operating System (Linux/Mac/Windows/iOS/Android): Linux
- Core Version: happened with v2.35.0, just before i updated to v2.43.0
- Client Version: deltachat desktop

## Expected behavior

When a hostname I use for my mailserver changes and has a time to live that is very short, I expect it to at least after an hour or so remain stable especially if the new IP address previously worked for connecting to it.

(This should be especially the case for an e-mail client. I moved my mail server two days ago and while the old one was still running for some hours afterward, due to SPF and other issues the old one wasn't really meant to be used anymore. Such a revert could e.g. cause desync and lost messages and other problems in some situations, even though I was lucky and that didn't happen in my case due to the intricacies of my setup that worked in my favor here.)

Edit: I might be missing some corner cases here, but intuitively to me the expected behavior generally would be: if a DNS result is ever successfully returned and has one or multiple IPs, any previous ones should no longer be considered safe to use. So any set of cached IPs should be based on e.g. the full round robin list that is current, not just on whatever single IPs were recently seen.

## Actual behavior

The core appears to revert to old, outdated and wrong DNS of hostname when triggered in just the right kind of way by a brief wifi outage, which can be seen in the log here:

```
2026-02-26T12:29:04.088Z core/event INFO "" 1 "src/smtp/connect.rs:108: Attempting SMTP connection to mail.ekdawn.com (46.225.XXX.XXX:587)."
2026-02-26T12:29:04.388Z core/event INFO "" 1 "src/smtp/connect.rs:108: Attempting SMTP connection to mail.XXXXXX.com ([2a01:4f8:XXXXXX]:587)."
2026-02-26T12:29:04.389Z core/event WARNING "" 1 "src/smtp/connect.rs:137: Failed to connect to mail.ekdawn.com ([2a01:4f8:XXXXXX]:587): connection failure: Network unreachable (os error 101)."
2026-02-26T12:29:04.389Z core/event INFO "" 1 "src/smtp/connect.rs:108: Attempting SMTP connection to mail.XXXXXX.com (159.69.XXX.XXX:587)."
```
(The `159.69.XXX.XXX` was a 12 hour outdated address.)

This seems to be at best a nuisance in some situations, and at worst a potential security issue.

At first I thought this might be a bug of [DNSCrypt proxy](https://github.com/DNSCrypt/dnscrypt-proxy/issues) which I happen to use. However, after spotting [this file](https://github.com/chatmail/core/blob/main/src/net/dns.rs), it seems to me that this might be a bug of whatever is going on in that module.

### Steps to reproduce the problem

1. Change server IP with the DNS having a time to live that is shorter than half an hour
2. Use deltachat during that time. Observe it use the new IP. Now apparently, any wifi outage in the wrong moment can cause it to revert to the old IP. (Might be complicated to manually reproduce and repeat, but that's how it looks like from the logs.)

### Screenshots

### Logs

See above!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.