Fix SMTP STARTTLS flow and restore doctor dial timeout#1
Merged
Conversation
Add a timeout-aware SMTP dial helper and use it in both config doctor and the send path so unreachable SMTP hosts cannot stall diagnostics or sends indefinitely. In config doctor, short-circuit check 8 when SMTP reachability (check 6) fails, and report an explicit cannot-test message instead of attempting STARTTLS/AUTH anyway. Also replace host:port formatting with net.JoinHostPort in doctor/send/imap connection paths for IPv6-safe addressing (and to satisfy go vet). Includes regression coverage for doctor short-circuit behavior and timeout helper/send-path dialing behavior, plus docs updates for the new doctor semantics.
1a2a6a7 to
245c786
Compare
Use a reserved .invalid SMTP hostname in ConfigDoctor short-circuit test instead of relying on localhost port 1 being closed, reducing environment-dependent flakiness.
Owner
|
Thank you @jesseposner -- I'll get this in tomorrow's release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Proton Bridge SMTP (
127.0.0.1:1025) requires STARTTLS (plain connect, then TLS upgrade).The prior STARTTLS fix switched to
smtp.Dial, but that removed the explicit dial timeout inconfig doctor, so unreachable/blackholed SMTP hosts could stall diagnostics.This PR keeps the STARTTLS behavior while restoring bounded connection behavior and tightening related networking paths.
What changed
Added timeout-aware SMTP dial helper:
internal/smtp/connect.goConnectTimeout(5s) andsmtp.NewClientover a timed TCP dial.Updated SMTP send path:
internal/smtp/client.gosmtp.Dialwith the timeout-aware helper.Fixed
config doctorSMTP flow:internal/cli/config.goSMTP port reachable) uses explicit timeout constant.SMTP connection succeeds) now short-circuits when check 6 fails and reports:cannot test - SMTP port not reachableNetworking hardening / convention cleanup:
fmt.Sprintf("%s:%d", host, port)withnet.JoinHostPort(...)in doctor/send/imap connection paths for IPv6-safe addressing.Tests added:
internal/cli/config_test.go: doctor short-circuit regression coverage.internal/smtp/client_test.go: timeout helper coverage and send-path timeout dial usage.Docs updated:
docs/commands.mddocs/setup.mdBehavior impact
config doctornow reports a clear cannot-test message for SMTP auth when SMTP port reachability fails.Validation
go test ./...go vet ./...