Commit Graph
3298 Commits
Author SHA1 Message Date
Wez Furlong 17158cb960 deps: update a few more 2025-10-08 10:52:55 +01:00
Wez Furlong 687f83e42e deps: update criterion 2025-10-08 10:43:12 +01:00
Wez Furlong 2ac85f51ff deps: cargo update 2025-10-08 10:39:00 +01:00
Wez Furlong 8028a8aaf0 deps: update prometheus and metrics crates 2025-10-08 10:34:56 +01:00
Wez Furlong 8fc11713d8 deps: update axum and utoipa ecosystem crates
A "casualty" of this is that the client-ip crate, which we were using
for its InsecureClientIp type for informational purposes, has retired
the InsecureClientIp type because it wasn't trustworthy overall
(https://github.com/imbolc/axum-client-ip/issues/32).

What we do for the time being is configure that crate to use the direct
peer IP.  There isn't a way to automagically select the "best"
information available without building in some kind of middleware, and
we probably should make that configurable in order to be fully
trustworthy.

So for now, we're punting on that until someone shows up with some
requirements and sponsorship and we'll make it happen then.
2025-10-08 10:24:57 +01:00
Wez Furlong 4be75084e1 deps: paste -> pastey
The paste crate is unmaintainted, pastey is a maintained fork:
https://rustsec.org/advisories/RUSTSEC-2024-0436
2025-10-08 09:37:31 +01:00
Wez Furlong af8f61d06e ci: fixup flakey maildir_batch test
need to wait for all 5 messages to land in the maildir before
we stop the services
2025-10-07 15:32:55 +01:00
Wez Furlong 84179ebcbb ci: fixup builder image tag when publishing 2025-10-07 14:45:50 +01:00
Wez Furlong 5c98511c06 add new kumo.file_type module
This is useful for example when processing attachments as part of a
content scanning policy.
2025-10-07 12:12:46 +01:00
Wez Furlong 7f4a929ca2 message transfer (xfer) support
This commit implements a kumomta-specific message transfer
protocol that is intended to be used to migrate messages
from one kumomta node to another.

The transfer is carried out using an HTTP POST request
to the destination node's http listener.

The request includes the full message metadata and body,
in a compressed form.

An xfer request can be made via `kcli xfer` (and thus also via an HTTP API
endpoint).  It works similarly to a rebind operation; you specify the
criteria to be used to match scheduled queues, along with the target
node for the xfer, and kumomta will find matching queues, drain out the
messages, make an adjustment to the metadata to capture current
scheduling information, and then place the messages into an xfer queue.

The xfer queue has hard-coded scheduling queue configuration of its own,
with the base retry interval set to 10 seconds, which should be suitably
aggressive for the intended use case.

You may apply shaping to affect the number of concurrent requests in a
similar way to how TSA shaping is configured.

On the receiving side, the incoming xfer sanity check to prohibit
trying to xfer to itself.

The spool id of the Message is not suitable to be reused verbatim on
another node (spool ids include the local mac address and creation
timestamp information, as well as a random component), so the receiving
side will derive an id that should be suitable for use on that node.
The originating node id and spool id will be preserved in metadata to
aid in tracing.

It is possible for an xfer request to target an existing xfer queue, so
that you can correct/update the target in various circumstances. In that
situation the messages will be "simply" moved from the source queue to
the destination queue.

It is possible to cancel an xfer request via `kcli xfer-cancel` (and
thus also via an HTTP API endpoint).  You specify the target queue,
which must be an xfer queue, and it will have its messages drained and
the metadata changes that were applied when the xfer was initiated will
be reversed, allowing the messages to then be reinserted into their
originating queue.

refs: https://github.com/KumoCorp/kumomta/issues/311
2025-10-07 10:58:07 +01:00
Wez Furlong de6e3bd0de allow admin bounce and suspend to specify exact queue name 2025-10-07 08:43:16 +01:00
Wez Furlong 5b5145aec8 openapi: manually poke the version number
These changes have been amended and rebased over the past few
weeks, so the version numbers for the json file no longer
correlate to real commits or dates.
2025-10-07 08:36:41 +01:00
Wez Furlong 407d2bc332 docs: update for multi-recipient changes 2025-10-07 08:35:59 +01:00
Wez Furlong 550dca47c1 smtp_server: improve cleanup for partially failed transaction
If we already saved one or more messages that were split out
of a multi-recipient transaction, and then the subsequent save
fails, we would previously leave those earlier messages saved
in the spool and deliver them despite reporting a failure back
to the client.

This commit removes them from the spool and logs a Bounce record
for them.

This is still not an ideal outcome, but it will at least not
send a message for which we haven't claimed responsibility.
2025-10-07 07:53:15 +01:00
Wez Furlong 794113f0b0 smtp_dispatcher: add max_recipients_per_batch
This sets a client side shaping control to manage the maximum number of
RCPT TO commands issued in a single transaction.
2025-10-07 07:53:15 +01:00
Wez Furlong f968935315 add smtp_server_split_transaction event
This provides full control over how an incoming smtp transaction
will be split into batches.
2025-10-07 07:53:15 +01:00
Wez Furlong b157e2f617 add smtp_server_data event for per-txn message validation
Great for doing content scanning and recipient list modification!
2025-10-07 07:53:13 +01:00
Wez Furlong db5ebb88a7 message: expose recipient list to lua api
message:recipient() may now return an array style table
holding the recipient list, if there is more than a single
recipient on the message.

Since this can be somewhat ambiguous/frustrating to work with,
there is now also a message:recipient_list() that will always
return an array style table, even if it holds just a single
element.

The included helpers have been updated to use `message:recipient_list`.

message:set_recipient() will now optionally accept an array
style table holding the recipient list to be set.
2025-10-07 07:52:58 +01:00
Wez Furlong 18e55a6e91 smtp: handle "too many recipients" status more appropriately
This commit adds a test for exceeding the number of recipients
allowed in a transaction and fleshes out our handling of that
status so that we will immediately try the remaining recipients
of the batch, without delaying the message by eg: 20 minutes
in the default retry parameters.

As part of this, I noticed that we were returning the wrong
smtp status code in our server implementation, so this
commit fixes that up.
2025-10-07 07:52:58 +01:00
Wez Furlong 888928b60f WIP: basic batch relaying and end-to-end test
This makes a first pass over relaying a batch, with a test
to prove that it worked.

The logic in the smtp client likely needs to be enhanced
to handle hitting recipient-per-transaction limits; tests
for various scenarios need to be added in follow-on commits.
2025-10-07 07:52:57 +01:00
Wez Furlong 4255e02ffa WIP: smtp_server: scaffolding to support for batching by domain
This adds a `batch_handling` parameter that optionally allows splitting
up a recipient batch based on the destination domain.

The system does not yet have any support for correctly delivering such a
batch.
2025-10-07 07:52:57 +01:00
Wez Furlong 9079a9e569 WIP: more multi-recipient type changes
This commit updates the type signatures of some key structures
to allow for the possibility of a Message having multiple recipients:

 * Message (continuing from previous commit)
 * JsonLogRecord
 * MessageInformation

Some logic has been updated to account for multiple recipients,
but critically, nothing in the core will generate them, and none
of the queue management or delivery infrastructure is aware
of recipients beyond the first.
2025-10-07 07:52:57 +01:00
Wez Furlong 055a2d0086 message: allow for multiple recipients in metadata 2025-10-07 07:52:56 +01:00
Wez Furlong 206dc7c7fa optionally detect legacy 8-bit during check-fix 2025-10-07 07:50:46 +01:00
Wez Furlong 981de67f1c docs: update for 2025.10.06-5ec871ab release 2025-10-07 07:38:10 +01:00
Sophia J. TurnerandSophia Turner 5ec871ab04 Add support for dmarc pct (#424)
* Add support for dmarc pct
* address feedback

---------

Co-authored-by: Sophia Turner <sophiajt@users.noreply.github.com>
2025-10-06 23:26:16 -07:00
Wez Furlong 53a92c5cda ci: try to reduce flakiness for the lapin integration tests
This seems to flake out reasonably regularly in CI on PRs.
Let's see if adjusting the ordering of things a little bit
encourages a less flakey result.
2025-10-06 20:12:19 +01:00
Wez Furlong 307d0b3093 docs: changelog for #423
closes: https://github.com/KumoCorp/kumomta/issues/423
2025-10-06 19:41:53 +01:00
Wez Furlong f28aef0ab0 rfc5321: fixup norun attribute on doc comment 2025-10-06 07:02:19 +01:00
Wez Furlong 4ba41290a6 docs: format and fixup whitespace 2025-10-06 07:02:18 +01:00
Wez Furlong dba45cfa28 logging: allow * to match meta names
This uses the same scheme as allowed for matching header names
in logging.
2025-10-06 07:02:18 +01:00
Wez Furlong 38fceae7ea spf: apply dns lookup limits
Noticed that we weren't apply the limits specified by
https://datatracker.ietf.org/doc/html/rfc7208#section-4.6.4
2025-10-05 09:50:45 +01:00
Wez Furlong 2654ab373a spf: implement p macro
Refactor the ptr logic so that it can be re-used for 'p' macro
expansion.

refs: https://github.com/KumoCorp/kumomta/issues/423
2025-10-05 09:05:53 +01:00
Wez Furlong 2eb21bea96 spf: implement h and r macros
refs: https://github.com/KumoCorp/kumomta/issues/423
2025-10-05 08:14:55 +01:00
Wez Furlong 34622edbd2 spf: allow for underscores in domain names when including
Use the more relaxed form of Name parsing so that domains
with underscores (which are in common use with email) do
not generate an error at runtime when processing spf
include rules.
2025-10-05 07:02:46 +01:00
Wez Furlong d6e0dcbe58 spf: allow for extraneous spaces in spf records
They are present in the real world and shouldn't block
us from parsing those records.
2025-10-05 06:41:50 +01:00
kay ozaki e97ca47816 support ip4, ip6 with no subnet 2025-10-04 07:43:59 +01:00
Wez Furlong d4a79a0f27 rustfmt 2025-10-03 20:28:00 +01:00
Tom Mairs 873f9e524d Update sample code 2025-10-03 20:27:23 +01:00
Wez Furlong 0e9e9f6d44 http_server/auth: clarify Missing Authorization header message
It feels reasonable to include the peer ip in the error message,
to aid in debugging trusted host access
2025-10-03 20:09:49 +01:00
Wez Furlong 5228f794bb xclient: capture original via/from address in context
I can see someone wanting to know the raw physical connection
info at some point, regardless of the adjusted xclient values,
or in the future, the proxy protocol adjusted values.
2025-10-03 20:03:14 +01:00
ncai ce743133b0 fix typo in doc 2025-09-30 07:35:32 +01:00
Sophia Turner 19e80001cd Address feedback 2025-09-30 07:13:12 +01:00
Sophia Turner 3dedcd3226 add working dmarc alignment tests 2025-09-30 07:13:12 +01:00
Sophia Turner 1853f1be88 Initial DMARC support 2025-09-30 07:13:12 +01:00
Wez Furlong d9d3d14e3e enable XCLIENT support
Hooks up the parsed XCLIENT command to the smtp server.
We support just the address changing attributes; we don't
do anything special with the NAME attribute, and I'd like
to think a lot more about authentication before allowing
messing with the LOGIN attribute.

After applying changes to the metadata in the connection,
take care to re-evaluate the listener parameters and
dynamic parameters so that `via` and `peer` blocks can
match the new configuration.
2025-09-26 09:36:15 +01:00
Wez Furlong a806865e9a rfc5321: add support for parsing XCLIENT commands
This adds support only to the parser for recognizing an XCLIENT
command.

It does not implement XCLIENT in either the client or the server.
2025-09-25 14:57:09 +01:00
Wez Furlong 90dd172f6c wrap up 8BITMIME and SMTPUTF8 support
Finishes up support for these extensions by adding a send-time
check and error for the case where we have 8 bit content and
the appropriate extension is not advertised by the next hop.

A shaping option is provided to bypass this, both to facilitate
testing and as a way to bypass it for situations where the
operator knows best.

closes: https://github.com/KumoCorp/kumomta/issues/327
2025-09-25 12:37:11 +01:00
Wez Furlong 62dd76d3ae expand test_apply_supplemental_header.lua a bit
I meant to include an example to validate passing and parsing
the trace header parameters, so here it is.
2025-09-25 09:09:21 +01:00
Wez Furlong 33e1883d79 add kumo.apply_supplemental_trace_header
This allows manual and conditional control over whether and how this
header is added to a message.
2025-09-25 09:02:41 +01:00