Commit Graph
1182 Commits
Author SHA1 Message Date
Wez Furlong 8b1b639d98 message: implicitly load data/meta when calling lua get/set meta/data
I saw an instance where the throttle_insert_ready_queue event was
trying to inspect the metadata but failing because the metadata was
not loaded.

This should avoid that problem.
2025-04-06 08:59:44 -07:00
Wez Furlong eda083f083 dns-resolver: use thundering herd protection and add semaphore
This commit does two things:

* Migrate the limit of 128 concurrent lookups from the shaping code
  and into the general mx lookup code
* Adjust the mx lookup implementation to run inside the cache
  getter, which applies thundering herd protection to the lookup.

These together will constrain the amount of queries being sent
to the upstream dns resolver and reduce the chances of it being
overwhelmed, especially if we are doing duplicate queries from
multiple concurrent contexts simultaneously.
2025-04-06 08:45:49 -07:00
Wez Furlong 5eb57e63d5 shaping.toml: disable dane for office365-dane
We cannot default it to enabled because a fully working
dane setup requires additional configuration in the resolver
and we cannot guarantee that that has happened here.
2025-04-06 07:47:00 -07:00
Wez Furlong e7ca5b4424 docs: update changelog to reflect more of kcli top's new features 2025-04-04 13:51:34 -07:00
Wez Furlong 0fc21cbbc6 kcli top: add vertical scrollbar
There are a lot of metrics these days, we need to scroll through them!
Use the arrow keys, page up/down and home/end for this purpose.

closes: https://github.com/KumoCorp/kumomta/issues/372
2025-04-03 14:00:59 -07:00
Wez Furlong c7fe9489c3 fix: failure to load ed25519 dkim private key
This was probably the casualty of some earlier refactoring
that has gone unnoticed until now.

Since we don't have explicit context on which key format to
parse in this helper function that is used in multiple places,
let's just make it try to parse both rsa and ed25519.

closes: #368
2025-04-03 10:11:24 -07:00
Edgar Vaitkevicius d0314c0f3a Updated Kafka producer docs
They mistakenly referred to AMQP and queues before.
2025-04-03 09:37:04 -07:00
Wez Furlong 7b9732d452 docs: mention systemd environment files in changelog 2025-04-03 07:35:02 -07:00
Wez Furlong 3b14587192 fix delayed shutdown for non-smtp delivery handlers
Occasionally we'll have someone report that systemd timed out
and sigkill'd their kumo on shutdown.

One possible scenario for this is a lua delivery handler that
is taking too long, presumably because the other end of it
(eg: webhook or other custom endpoint) is not responding in
a timely fashion.

The way that we handle shutdown is that we compute a maximum
theoretical timeout value by summing up all of the smtp client
timeout values.  Some of those can be several minutes in
duration because the are using default values derived from
a very conservative set of values suggested by the SMTP
RFCs from the '70s.

Those obviously should not apply to a custom delivery handler,
but also, in the context of an established SMTP session, we
should not add in the connection-establishment-specific values
when we're just waiting for a per-message send.

This commit addresses this situation on two fronts:

* Introduce a new system_shutdown_timeout value that allows the
  user to conveniently express their desired timeout value
  in a single option.  This is *not* set by default!
* The default value for system_shutdown_timeout is computed by
  summing the per-message-delivery smtp timeout options, which
  is a much more reasonable, and more importantly, shorter than
  our 300s TimeoutStopSec value in kumomta.service
2025-04-02 14:21:31 -07:00
Wez Furlong 7d3869d71f docs: fix links 2025-04-02 12:26:35 -07:00
Wez Furlong ff7f9eb666 move readyq maint into its own thread pool
Previously, we'd use the qmaint pool to spawn both the scheduled
and ready queue maintenance tasks.

This commit splits them apart in order to avoid the potential for
cross-task contention on the same threads if a scheduled queue
and ready queue pair are communicating with each other.
2025-04-02 10:36:46 -07:00
Wez Furlong 586d73744b tsa-daemon: increase soft nofile limit on startup
We recently observed a system where tsa-daemon run out of file
descriptors because it hit a systemd default of 1024 on the host system,
which had 192 cores.  We spawn a thread per core for internal processing
in tsa-daemon, and that has associated with it a number of kernel
objects that each have an fd.

1024 is an unreasonably small limit for the number of fds, so let's
just try to raise to match the normally much higher hard limit, just as
we do in kumod.
2025-04-01 06:46:54 -07:00
Wez Furlong 4b33354dee allow overriding available_parallelism value
We recently observed a system running on an over-committed VM that
reported 4x the actually available parallelism.

Since we scale our thread pool sizes from this value, it resulted
in an extra-over-committed configuration for kumod.

You may now set KUMO_AVAILABLE_PARALLELISM in the environment to
override the value that we see both interally and expose via
the lua function with the same name.
2025-04-01 06:37:12 -07:00
Wez Furlong 1e55d47b93 Add default TSA shaping config to shaping.toml
We've seen folks trip over this a couple of times, and it's
because we don't document this and include it in the defaults,
so here we go.
2025-03-31 12:02:54 -07:00
Wez Furlong ee52558f67 docs: format example in configure_resolver.md 2025-03-28 14:35:16 -07:00
Wez Furlong c07a595170 inspect-sched-q/inspect-message: include scheduling info
This is a quick and dirty export of the scheduling data from
the message and into the MessageInformation type that describes it.
2025-03-28 14:34:48 -07:00
Ryan Bonnell 8d5a604d4e Fix typo in name of new "Delayed" log record type 2025-03-26 05:15:45 -07:00
Wez Furlong 9d84a04d48 docs: note about hickory resolveropts schema change 2025-03-25 12:54:33 -07:00
Wez Furlong a95e78cfa7 docs: enable build w/ podman on apple silicon 2025-03-24 21:58:47 -07:00
Wez Furlong 617612a9cf deps: upgrade hickory to 0.25
There are a few breaking changes in the API that we need to tackle
here, but they're generally fine.

Since our libunbound crate uses hickory-proto, I had to upgrade
that dep over there and reference the updated git rev here in
this commit; we don't publish that to crates.io.

The main thing that stood out in the upgrade is that the zone
file parser used by the TestResolver now seems to create
records with varying FQDN-ness. This may just be that it is
now passing data through from the underlying zone data, but
it caused a number of the SPF and DKIM test cases to fail
without canonicalizing the names to FQDN.  I chose to do that
in the TestResolver rather than reviewing all the input zone
data, with the rationale being that it is least surprising
to have the test resolver fix that up than to puzzle over
records not resolving due to a missing trailing dot when
more tests are written in the future.

This commit doesn't try to take advantage of the improvements
to DNSSEC that are available in this version of hickory,
it's just upgrading to the API changes.

closes: https://github.com/KumoCorp/kumomta/pull/361
2025-03-24 07:54:34 -07:00
Wez Furlong 0534d888bb docs: redis: clarify the redis URL syntax that we support 2025-03-24 07:13:35 -07:00
Wez Furlong e422f56b5c smtp_server: add smtp_server_get_dynamic_parameters event
This helps to deploy IP-based virtual service.
2025-03-23 08:24:28 -07:00
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