Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix domain socket support #408

Merged
merged 2 commits into from
Jan 8, 2025
Merged

Conversation

wneessen
Copy link
Owner

@wneessen wneessen commented Jan 8, 2025

This PR adds support for connecting to a Unix Domain Socket instead of a TCP port.

The Client can be intructed to connect to a unix socket by prefixing the host with unix:// (Example: mail.NewClient("unix:///var/spool/postfix/private/smtpunix")

This feature is requested by the Forgejo project as part of a possible migration to go-mail: https://codeberg.org/forgejo/forgejo/issues/6028#issuecomment-2560355

Added the ability to connect via Unix Domain Sockets by introducing the `useUnixSocket` flag. Adjusted connection logic to handle `unix://` host prefixes and updated the dialing mechanism to use the appropriate network type (`unix` or `tcp`). This enhances flexibility in connection methods.
This commit introduces functionality to handle Unix domain socket (UDS) connections. It includes updates to the client and test suite to validate UDS support and extends the test server to support Unix sockets. These changes ensure compatibility for environments requiring UDS communication.
@wneessen wneessen linked an issue Jan 8, 2025 that may be closed by this pull request
@wneessen wneessen merged commit eb48854 into main Jan 8, 2025
26 of 27 checks passed
@wneessen wneessen deleted the feature/404_unix-domain-socket-support branch January 8, 2025 17:36
Copy link

codecov bot commented Jan 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.69%. Comparing base (42ce0bf) to head (fa129a2).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #408      +/-   ##
==========================================
+ Coverage   94.67%   94.69%   +0.01%     
==========================================
  Files          30       30              
  Lines        3515     3526      +11     
==========================================
+ Hits         3328     3339      +11     
  Misses        138      138              
  Partials       49       49              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wneessen wneessen mentioned this pull request Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unix domain socket support
1 participant