Commit Graph
1160 Commits
Author SHA1 Message Date
Wez Furlong 6c49d51ee7 smtp_server: add smtp_server_connection_accepted event 2025-03-23 07:15:45 -07:00
Wez Furlong d37432a644 docs: changelog for new via, meta, peer options 2025-03-23 07:11:24 -07:00
Wez Furlong 8253417576 smtp_server: add meta parameter to start_esmtp_listener
This allows pre-defining connection metadata values.  When coupled with
`peer` and/or `via`, these can be done based on the corresponding
addresses associated with the session.

closes: https://github.com/KumoCorp/kumomta/issues/355
2025-03-22 11:13:22 -07:00
Wez Furlong a7c98a7d0f smtp_server: add via matching parameter to start_esmtp_listener
Similar to the peer option, but this one matches based on the
local address, giving a bit more flexibility for virtual hosting.
2025-03-22 11:07:19 -07:00
Wez Furlong 3e9bc5a946 smtp_server: introduce new peer matching option to start_esmtp_listener
This allows crafting peer-address-specific values for a listener.
2025-03-22 10:35:42 -07:00
Wez Furlong 9de685aa54 smtp_server: refactor tls_config
The motivation here is to remove tls_config from EsmtpListenerParams
to make some future configuration changes easier, so this commit
moves that simple cache out to an explicit lru ttl cache.

This has the welcome side effect of enabling periodic reloading
of the tls parameters, which in turn makes it a hands-off process
for updating certificates: we no longer require the service to
be restarted for that.
2025-03-22 09:18:38 -07:00
Wez Furlong 19341dc710 lruttl: add params to control timeout and retry on sema timeout
These are hooked up only for memoize at this time.  No default
behavior is changed by this commit, but you can optionally
specify these parameters in order to change the behavior.
2025-03-21 16:56:12 -07:00
Wez Furlong d21b98ab45 docs: format logging.md 2025-03-21 16:56:12 -07:00
Ryan Bonnell 2513070837 Fix incorrect URL in changelog for new logging functions 2025-03-21 13:22:58 -07:00
Wez Furlong 3344d84283 shaping: fix missing field http_timeout error in validation mode
The workaround is to explicitly add `http_timeout` to your
validation_options for the shaping helper.
2025-03-20 10:14:30 -07:00
Ryan Bonnell 0d7a0b4bd6 Clarify example of log format template usage for customization 2025-03-20 08:26:31 -07:00
Wez Furlong 337b4e33a8 docs: update for stable 2025.03.19-1d3f1f67 release 2025-03-20 07:28:32 -07:00
Wez Furlong 360850dc67 smtp_dispatcher: fix incorrect retry of broken tls when policy=required
The introduction of the
`opportunistic_tls_reconnect_on_failed_handshake` option resulted in
this regression, which is because I misread the `match` statement
for this case as being only for the opportunistic case, but it
also encompasses the required case.

The issue is:

* A site has an MTA-STS policy enforcing Required tls
* The handshake with that site fails (for reasons unknown and
  irrelevant)
* We would unconditionally (wrt. Required vs. Opportunistic) respect
  opportunistic_tls_reconnect_on_failed_handshake and re-queue the
  current address for the next connection attempt
* Ordinarily, opportunistic_tls_reconnect_on_failed_handshake +
  the remembered broken state would cause that next attempt to
  downgrade to clear text, but MTA-STS forces the policy to
  Require
* Goto step 2 (modulated by connection rate throttling)

The fix is simply to only apply
opportunistic_tls_reconnect_on_failed_handshake when the policy
is actually opportunistic.
2025-03-19 05:14:22 -07:00
Wez Furlong f7b5395249 tsa-daemon: increase broadcast buffer to resolve channel lag error
We were using a fairly tight limit of 16 messages in the channel
that buffers the effects of changing bounces/suspensions from
any websocket-connected-clients.

A busy server could hit that limit fairly easily, resulting
in a `channel lagged by NUMBER` error that drops the websocket,
causing the client to need to reconnect and resync.

This commit resolves that by making the buffer a much more healthy size.
2025-03-18 14:05:54 -07:00
Wez Furlong 1f633847d3 tsa-daemon: fix over zealous dedup of bounce/suspension data on websocket
We were deduping just by rule_hash, but each of these tables has
additional required fields as part of the primary key.

The result was that, for sites with a lot of bounces/suspensions
triggered by the same rules across a related set of sources,
the full set of bounces and suspensions would not be correctly
reported as part of a websocket push.
2025-03-18 14:05:54 -07:00
Wez Furlong dd63267db7 tsa-daemon: fix sqlite locking blocking tokio scheduler
sqlite doesn't have a native async interface, and instead will
use traditional OS-level mutexes to ensure thread safety.

Using those when under contention in a tokio scheduler thread
can lead to blocking of the tokio scheduler threads, which can
prevent timely delivery of data via websockets, or timely
processing of incoming log records.

This commit fixes up the sqlite access points to use tokio's
spawn_blocking function to move that style of mutex acquisition to a
more suitable context.
2025-03-18 14:05:51 -07:00
Wez Furlong 98e99594d9 shaping: process tsa websocket pushes in batches
We'll wait up to 3s at a time for however many mesages are available
to extract from the tsa daemon websocket, then process the results
in batches.

This avoids the potential for geometric complexity if there is a run of
subscription updates happening around the same time.
2025-03-18 14:05:30 -07:00
Wez Furlong 9e6321ecb6 shaping: add timeout for tsa shaping data fetches 2025-03-18 14:05:30 -07:00
Wez Furlong 54386ca308 rfc5321 client: fix openssl verify issue when hostname has trailing dot
I'm not totally sure why this isn't universally broken when using
openssl (instead of rustls), but in the specific case we were
investigating, the destination was configured via a routing_domain
and the resulting mx_host name had the trailing FQDN dot on it.

Removing that dot allows the certificate to verify, so let's
ensure that we strip it here in the client.
2025-03-18 06:10:23 -07:00
Wez Furlong 6a5e6df5f0 mailparsing: fix whitespace precedence issue with long mailbox headers
The issue here is that when an rfc2047 encoded display name is split
across multiple lines, the whitespace between them is not recognized
at the right time, which results in the second encoded word being
passed through as-is, without being decoded.

This commit fixes the precedence of whitespace parsing in that
case.
2025-03-17 10:51:07 -07:00
Wez Furlong 6d17a0a453 docs: mention mta-sts and dane on the enable_tls page 2025-03-17 08:52:10 -07:00
Wez Furlong c2444b6266 add expiry to per-msg scheduling overrides
This commit allows setting a per-message `expires` timestamp
via msg:set_scheduling (and thus msg:import_scheduling_header).

The expiration takes precedence over max_age; max_age will be
ignored for messages that have configured and expiration time.

The expiration time is independent of the other scheduling
restrictions.
2025-03-15 07:18:13 -07:00
Wez Furlong e655236fe0 message: manually deserialize scheduling restrictions
This resolves an issue where the default behavior for serde is to
silently swallow issues with this struct, because we use a flattened
optional structure for those restrictions.
2025-03-15 07:18:12 -07:00
Mike Hillyer 1754209db9 Fix a couple of docs build warnings. 2025-03-13 13:27:21 -04:00
Wez Furlong bb2e671f4e add explain-throttle script 2025-03-12 11:07:52 -07:00
Blake Patton 0befdaf665 Complete the missing part of the command 2025-03-11 10:00:13 -07:00
Wez Furlong 9286394e72 docs: fixup list bullets for source_selection_rate 2025-03-11 09:54:14 -07:00
Wez Furlong 6ef73a096e docs for source_selection_rate 2025-03-11 09:46:58 -07:00
Wez Furlong d99f29ebbb egress_source: try other sources if the selected entry is full
Previously, we'd pick a source whether it had room for the new
message or not, then generate a TransientFailure when we subsequent
figure out that it is full.

This commit will try to deliver through one of the other possible
sources instead of delaying the message.
2025-03-11 06:56:46 -07:00
Wez Furlong 501d1f26e5 dkim: support verifying multiple keys
While auditing Answer::as_txt usage as a follow up from the recent
SPF fix, I noticed a TODO in the dkim code (which we forked from
another implementation) to support processing multiple TXT
records.

This commit implements the necessary tweaks to extract multiple
signatures and attempt to verify them against the incoming message.
2025-03-07 09:26:55 -07:00
Wez Furlong 7953a7b0f2 fix: spf didn't parse records when TXT had non-spf records
The issue here was essentially a data fidelity issue around
TXT record representation.

A DNS TXT record can be composed from multiple strings, and a domain can
return multiple TXT records, so there is some nesting.

The SPF RFC says:

```
3.3.  Multiple Strings in a Single DNS Record

   As defined in [RFC1035], Sections 3.3 and 3.3.14, a single text DNS
   record can be composed of more than one string.  If a published
   record contains multiple character-strings, then the record MUST be
   treated as if those strings are concatenated together without adding
   spaces.  For example:

      IN TXT "v=spf1 .... first" "second string..."

   is equivalent to:

      IN TXT "v=spf1 .... firstsecond string..."

   TXT records containing multiple strings are useful in constructing
   records that would exceed the 255-octet maximum length of a
   character-string within a single TXT record.
```

so the SPF logic was dutifully joining records together around the
empty string.

Howerver, if you look at `dig yahoo.com txt` you'll see a bunch
of non-SPF records:

```
yahoo.com.              1800    IN      TXT     "google-site-verification=Z3-Vh6zqUMgybVH4wQl1GxKSKN7JE13kyCyeZ3TZZ-I"
yahoo.com.              1800    IN      TXT     "v=spf1 redirect=_spf.mail.yahoo.com"
yahoo.com.              1800    IN      TXT     "Zoom=13284637"
yahoo.com.              1800    IN      TXT     "edb3bff2c0d64622a9b2250438277a59"
```

these were getting joined together and producing a bogus input.

Obviously we should not join the results from the txt lookup
together like that, but then why would the RFC make a point
of talking about joining stuff together, and where should
that logic live?

Our `Answer::as_txt` implementation was doing some joining
of its own and it turned out that it was concatenating across
the outer layer of the aforementioned TXT record nesting.

This commit fixes that up and adds some test coverage.
2025-03-07 07:06:10 -07:00
Wez Furlong 0fe856516c add kumo.log_(error|info|warn|debug) functions
These log their arguments to the diagnostic log.
2025-03-06 17:15:15 -07:00
Wez Furlong 85b922d40b add kumo.set_lruttl_cache_capacity function
This allows configuring the capacity limit for internal caches.
2025-03-05 08:50:11 -07:00
Wez Furlong 5c154417c7 shaping.lua: fix missing string.format calls
closes: https://github.com/KumoCorp/kumomta/issues/351
2025-03-04 16:24:58 -07:00
Wez Furlong b9fe715c5e changelog: mention lruttl cache change
This is really just so that something shows up there, rather than
an exhaustive description of what those changes are.
2025-03-04 16:23:17 -07:00
Wez Furlong b2887cb7b8 data_processing_timeout: increase default to 5 minutes
I worry that 1 minute might be too short to be universally good,
particularly as a change in behavior from an earlier build: going from
no timeout to 1 minute could be super surprising and un-welcome.

Let's bump this up to 5 minutes which more closely matches the
default for DATA in the base SMTP RFC.
2025-03-04 16:23:16 -07:00
Wez Furlong fa1857be98 docs: add data_processing_timeout 2025-03-04 16:23:15 -07:00
Wez Furlong c5014f9594 docs: add some rocksdb tuning options to the docs 2025-03-04 16:23:14 -07:00
Wez Furlong df8aa10ad1 docs: split define_spool docs into separate pages 2025-03-04 16:23:14 -07:00
Ryan Bonnell eddc42b45c Add missing space in Markdown link to 'UserGuide' 2025-02-28 08:41:39 -08:00
Ryan Bonnell 4180e3a512 Fix accidental misspellings 2025-02-28 08:41:16 -08:00
Ryan Bonnell 04e52757a3 Re-wrap line breaks in comments for readability 2025-02-28 08:40:36 -08:00
Ryan Bonnell c91b978ea3 Fix misspelling of word 'parameter' 2025-02-28 08:40:07 -08:00
Wez Furlong 3966ca597f kumo.http.build_client: use system certificate store
This matches the behavior we switched to for the SMTP client a release
or two ago, which allows reading the system store, or overriding it via
`SSL_CERT_DIR` and `SSL_CERT_FILE` env vars.

https://docs.rs/rustls-native-certs/latest/rustls_native_certs/fn.load_native_certs.html
2025-02-28 08:41:44 -07:00
Wez Furlong 9ba637ab38 dns-resolver: add negative caching for MX lookup failures
This is why slow DNS often expanded to 3-4x as long as the expected
timeout value; we make a handful of calls in succession, assuming
that the cache was effective in an earlier stage.

We now cache errors for 5 minutes by default, and it can be configured
as desired.

refs: https://github.com/KumoCorp/kumomta/issues/325
2025-02-27 15:55:37 -07:00
Wez Furlong 10e60ea10d docs: fmt generate-toc.py 2025-02-27 06:01:11 -07:00
Wez Furlong f363445ceb add kumo.dns.set_mx_timeout and make it default to 5s
closes: https://github.com/KumoCorp/kumomta/issues/325
2025-02-27 05:54:26 -07:00
MHillyer 22a324dd8d Fix double headings. 2025-02-26 17:03:24 -05:00
MHillyer 588ecee4a8 Add YT link to Kubernetes page. 2025-02-26 16:47:19 -05:00
MHillyer c730c78d7c Add reference to Daniel's repo. 2025-02-26 15:51:25 -05:00