fix: IPv4 preference + DNS cache fallback for stable POP3/IMAP connections
- Add DNS_CACHE_FALLBACK_ENABLED setting (default: true) - Add in-process DNS cache (_dns_cache, _dns_cache_lock, _get/_set_cached_ipv4) - Add _resolve_ipv4 (async) and _resolve_ipv4_sync: AF_INET lookup, cache on success, return cached IP on EAI_AGAIN when fallback enabled - Add _IMAP4SSLwithSNI: connects to pre-resolved IPv4 but uses original hostname for TLS SNI/cert verification - Add _POP3SSLWithIPv4Pref / _POP3WithIPv4Pref: override _create_socket to use pre-resolved IPv4 while keeping original host for POP3_SSL SNI - Add _make_pop3_conn factory and _make_imap_client async factory - Wire IPv4/cache helpers into all 6 connection call-sites (IMAP x3, POP3 x3) - Distinguish transient DNS (EAI_AGAIN) from permanent in _format_connection_error - Replace asyncio.get_event_loop() with get_running_loop() in 4 async sites - All 75 existing unit tests pass unchanged Agent-Logs-Url: https://github.com/christianlouis/InboxConverge/sessions/be0a3bbd-1af1-408e-b918-84753723154b Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
89ebdd2b79
commit
45a2dd8be2
@@ -4,6 +4,20 @@ Comprehensive task breakdown for repository improvements and production readines
|
||||
|
||||
## ✅ Recently Completed
|
||||
|
||||
- [x] **IMAP/POP3 connection stability — IPv4 preference + DNS cache**: All
|
||||
POP3 and IMAP connections now prefer IPv4 by pre-resolving hostnames with
|
||||
`AF_INET` before connecting. This eliminates `ENETUNREACH` / `Network is
|
||||
unreachable` and sporadic TLS timeouts caused by Docker containers attempting
|
||||
IPv6 connections to servers that block IPv6. Successfully resolved IPv4
|
||||
addresses are cached in-process; when `DNS_CACHE_FALLBACK_ENABLED=true`
|
||||
(default) the cached address is used as a fallback if DNS subsequently fails
|
||||
(`EAI_AGAIN`), keeping mail delivery alive through transient resolver outages.
|
||||
Added `_resolve_ipv4` / `_resolve_ipv4_sync`, `_IMAP4SSLwithSNI`,
|
||||
`_POP3SSLWithIPv4Pref`, `_POP3WithIPv4Pref`, `_make_pop3_conn`, and
|
||||
`_make_imap_client` helpers. Transient DNS errors now report "Temporary DNS
|
||||
failure" rather than "check that the server address is correct". Replaced
|
||||
four deprecated `asyncio.get_event_loop()` calls with `get_running_loop()`.
|
||||
|
||||
- [x] **IMAP/POP3 diagnostics — Step 1: Friendly error messages**: Added
|
||||
`_format_connection_error()` helper that converts raw OS/socket/SSL/POP3/IMAP
|
||||
exceptions into human-readable sentences with host:port context. Applied at
|
||||
|
||||
Reference in New Issue
Block a user