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

Outbound - Fallback to MX's IPv4 when the MX's IPv6 is bogus #3314

Closed
sriccio opened this issue Apr 12, 2024 · 2 comments · Fixed by #3322
Closed

Outbound - Fallback to MX's IPv4 when the MX's IPv6 is bogus #3314

sriccio opened this issue Apr 12, 2024 · 2 comments · Fixed by #3322
Labels

Comments

@sriccio
Copy link
Contributor

sriccio commented Apr 12, 2024

Hello,

Is your feature request related to a problem? Please describe.
I noticed that when a recipient MX has both IPv6 and IPv4 entries, and that the IPv6 entry is bogus, Haraka doesn't try to connect to the IPv4 address.

Example of bogus MX:

~# host mx.bogus.tld 1.1.1.1

mx.bogus.tld has address 1.2.3.4
mx.bogus.tld has IPv6 address fe80::d250:99ff:feda:9100 <- unroutable

Describe the solution you'd like
For a given MX having both IPv4 and IPv6 entries, first try IPv6 and if it can't connect, fallback to IPv4 before tempfailing and announcing "Tried all MXs"

Describe alternatives you've considered
To avoid the issue I locally overwrote the target MX IP address (through our unbound resolver) to remove the IPv6 entry so the outgoing mail can be delivered.

Additional context
Of course it would be much better that the remote MX admin fix their IPv6 issue, but still, that could be handful to fallback to IPv4 to avoid having to locally patch how the MX resolves.

@msimerson
Copy link
Member

Describe the solution you'd like
For a given MX having both IPv4 and IPv6 entries, first try IPv6 and if it can't connect, fallback to IPv4 before tempfailing and announcing "Tried all MXs"

This is how I expect outbound to work.

What version of Haraka are you running?

@sriccio
Copy link
Contributor Author

sriccio commented Apr 17, 2024

Hello @msimerson,

On this particular server we are running Haraka.js — Version: 3.0.2 at the moment.

Kind regards

msimerson added a commit that referenced this issue Apr 22, 2024
Fixes #3314

Conceptually, the big changes in this PR do the following:

1. outsource outbound DNS to haraka-net-utils
2. improve outbound logging by using logger in *only* 2 common ways:
`logger.info(obj, message)` or `this.loginfo(self, msg...)`
3. In outbound, the control flow is much more linear:
    - run get_mx hooks
    - if no plugin offered a MX, get from net_utils.get_mx (which now
includes implicit MX)
    - pass list of MXes to found_mx, which sorts the MXes
    - net_utils resolves all MX hostnames to IPs (IPv4, IPv6, all at once, for speed)
    - each MX IP is tried in turn until one succeeds or the list is exhausted
4. Injecting logging functions into classes (Connection, Plugin, HMailItem) is now done via logger.add_log_methods

## Changes:

- outbound: minor es6 updates
- outbound: logging improvements
- was: [-] [core] [outbound] Failed to get socket: Outbound connection
error: Error: connect ECONNREFUSED 172.16.16.14:25
- now: [A63B62DF-F...] [outbound] Failed to get socket: connect
ECONNREFUSED 172.16.16.14:25
  - outbound: remove log prefixes of `[outbound] `, no longer needed
  - shorter logger syntax: logger.loginfo -> logger.info
- logger(connection, plugins, hmail), refactor copying in log functions
- logger: don't load outbound (race condition). Instead, set name
property
- outbound: delete try_deliver_host. Use net_utils to resolve MX hosts
to IPs
- outbound: remove config setting ipv6_enabled
- fix(logger): refactor add_log_methods, don't set extra `loglog*` names
- doc(connection): update rfc7001 URL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants