haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.11k stars 660 forks source link

outbound: get_mx overhaul, logging improvements #3322

Closed msimerson closed 7 months ago

msimerson commented 7 months ago

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:

Checklist: