Commit Graph

609 Commits

Author SHA1 Message Date
Harsh Jha 00f3131f7d Allow configuring which records TSA skips
Closes: https://github.com/KumoCorp/kumomta/pull/525

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2026-05-29 15:02:31 +01:00
Aditya Ganti 7bfbbe720a fix(mod-aws-sigv4): apply Trimall, require host header, fix S3 content-sha256
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
Closes: https://github.com/KumoCorp/kumomta/pull/522
2026-05-29 10:16:06 +01:00
Wez Furlong 5fb9dd104d fix regression in serializing original_message in ARF
This got overlooked around the time that 7518ca6de was pushed.
The intent was to serialize as a string when possible, bytes otherwise.
2026-05-29 09:45:22 +01:00
Wez Furlong 06a26f4ba6 kumo-jsonl: make tailer more tolerant of errors
Two main cases:

 * If the user accidentally places files in the directory that
   are not kumo-jsonl compatible segments, then we won't trip
   over them and stop processing.

 * If the log segments are incomplete (eg: kumod was SIGKILL'd)
   then we log the issue and avance to the next segment
2026-05-29 08:57:47 +01:00
kay ozaki 1febfcc55e lua counter series using kumo-counter-series
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
closes: https://github.com/KumoCorp/kumomta/pull/507
2026-05-07 15:35:17 +01:00
Wez Furlong fcb0981c31 deps: update rust-openssl 2026-05-06 22:50:49 +01:00
Wez Furlong b0fa4275f3 cargo update
Note: need to pin hierarchical_hash_wheel_timer back because the latest
version requires a rustc upgrade, and current versions of mlua don't
build against it when the send feature is enabled.
2026-05-06 21:32:01 +01:00
Jack c4dbaa743b proxy-server: add tcp_keepalive option
Some upstream peers (e.g. QQ Mail's rate-limiter) silently hold a
proxied TCP connection open indefinitely — sending no data, FIN, or RST
— rather than cleanly refusing.  Without some kind of timeout
management, the two file descriptors for such a session remain open for
the lifetime of the process, slowly exhausting the kernel's
file-descriptor table and occupying proxy-server worker slots.

This commit configures kernel level keepalive options with reasonable
defaults to detect and close out this class of connection.

Co-authored-by: Wez Furlong <wez@wezfurlong.org>

Closes: https://github.com/KumoCorp/kumomta/pull/509
2026-05-06 21:09:10 +01:00
kay ozaki f2d98eaf62 psl: normalize domains before psl::domain_str / suffix_str lookups
The `psl` crate's domain_str / suffix_str do byte-exact lookups against
the public-suffix list, so uppercase or trailing-dot inputs (e.g.
"Example.COM" or "example.com." from a DNS Name) silently return None.
Several call sites were passing through user- or DNS-supplied domains
unmodified.

Add a small psl-utils crate that wraps the psl crate:

* normalize_domain(&str) -> Cow<str>: strips a single trailing dot and
  lowercases ASCII; borrows when the input is already normalized so
  the hot path (alignment loop) doesn't allocate.
* domain_str / suffix_str: thin re-exports for callers that have
  already normalized.

psl-utils becomes the only workspace crate that directly depends on
the psl crate; kumo-dmarc and mod-string switch to depending on
psl-utils instead.

Updated call sites:

* kumo-dmarc record.rs: is_relaxed_aligned / is_strict_aligned now
  normalize both inputs first. Replaces the prior eq_ignore_ascii_case
  comparisons.
* kumo-dmarc lib.rs: the organizational-domain fallback in
  DmarcContext::check now normalizes from_domain before calling
  domain_str and compares against the normalized form. Previously a
  mixed-case From: header would skip the _dmarc.<org> lookup entirely.
* mod-string lib.rs: the Lua-exposed string.psl_domain and
  string.psl_suffix bindings normalize their input. Behavior change:
  inputs that previously returned nil due to case or trailing dot now
  resolve.

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
Closes: https://github.com/KumoCorp/kumomta/pull/513
2026-05-06 13:34:15 +00:00
Wez Furlong 07814b08e1 update uuid dep 2026-04-29 08:17:59 +01:00
sophiajt 62b62560de Start of DMARC reporting
The start of reporting support for DMARC. We create the report from the
errors we encounter, though we do not yet have this wired into the email
reporting system.

Our main task is collecting the errors, though where we put them still
needs to be decided. Currently, a temporary file is used.

Once collected, the errors can be aggregated and built into the RFC 7489-compliant report.

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
Closes: https://github.com/KumoCorp/kumomta/pull/463
2026-04-29 08:07:55 +01:00
Wez Furlong f8bbf13255 rfc5321: improve consistency of EnvelopeAddress::Display
Drop the source route syntax to make round-tripping and improve
consistency with our other encoding functions for this type.
2026-04-09 15:42:40 +01:00
Wez Furlong 7518ca6de4 serialize bstring as utf8 string when possible
Add some tests to vet this in lua as well.

lua mime parsing functions now also accept bstring input.
2026-04-09 15:42:39 +01:00
Wez Furlong 90a98b64e6 refactor: eliminate message::EnvelopeAddress
Just use the inner rfc5321::EnvelopeAddress now.
2026-04-08 14:12:59 +01:00
Wez Furlong fe54ebfa52 rfc5321: change protocol parser from pest -> nom
This gives us more flexibility in how we can build our parser,
and is significantly easier to maintain.

Part of this change is allowing the command parser to recognize
the starting command verb in an otherwise failed command line
parse; the intent is to provide slightly better error codes
where SMTP defines them when we encounter such a thing.

This commit doesn't do that; it's already pretty huge.
2026-04-08 14:12:58 +01:00
kayozaki dc1cf4a93a Adding kumo.fs.stat to get file/dir meta data (#497) 2026-04-04 19:52:12 +01:00
Wez Furlong 35ce0674fb kumo-log-tailer -> kumo-jsonl 2026-04-04 10:45:36 +01:00
Wez Furlong db388e702c log-tailer: add a writer as well 2026-04-04 10:25:59 +01:00
Wez Furlong 8836f8f330 kumo-log-tailer: add lua bindings 2026-04-03 20:01:25 +01:00
Wez Furlong 8b641f6f57 tailer: switch to new kumo-log-tailer backend 2026-04-03 19:28:13 +01:00
Wez Furlong 6318b0c04e Add kumo-log-tailer crate 2026-04-03 19:15:38 +01:00
Wez Furlong 0ed20697a2 deps: update async-nats
This resolves a dependabot issue around the rustls-webpki crate
version that was previously used just by this crate.
2026-04-01 07:34:19 +01:00
Wez Furlong ea786a2585 deps: upgrade testcontainers
This resolves a minor (to us) dependabot alert for a dep that is used
only when we build and run integration tests.
2026-03-31 11:37:14 +01:00
Wez Furlong 787ee3f766 introduce kumo-counter-series crate
This crate implements an in memory ring-buffer based counter series.

It is intended to be used for bounded (and ideally small!) counter time
series.

The idea is that this should be the backing store employed by the
proposed https://github.com/KumoCorp/kumomta/pull/470

closes: https://github.com/KumoCorp/kumomta/pull/475
2026-03-31 11:30:28 +01:00
Wez Furlong 9c2fb0f183 refactor: extract nom_utils to its own crate 2026-03-31 11:16:11 +01:00
Wez Furlong edd7eb9ebb server-common: try to be more faithful when logging bytes
Previously, we'd use a lossy conversion that would replace
funky sequences with the unicode replacement character.

This commit will instead print the bad bytes as hex-escaped characters.

This can be useful when troubleshooting things in tests; this commit
also turns up info logging for the lua test runner so that we can see
that, although nothing else in this commit actually calls that.
I did use it while troubleshooting things just now though, so it is
generally useful.
2026-03-28 07:20:34 +00:00
Wez Furlong 8cb8b3fa7e new: kumo.encode.charset_decode/kumo.encode.charset_encode
These are more immediately useful to me for writing tests, but are
generally useful when you have a policy that might need to to deal
with legacy encoding schemes more directly.
2026-03-28 07:20:34 +00:00
Wez Furlong 56f3535a85 mailparsing: refactor: parsing functions return BString
This is ostensibly "just" making the nom parsing functions return
BString instead of String, but the fan-out makes the commit much larger,
as a number of surfaces (eg: as_unstructured) have now changed types.
2026-03-28 07:20:31 +00:00
Wez Furlong 4ede478688 mailparsing: refactor: MimeParameters -> BString 2026-03-28 07:20:30 +00:00
Wez Furlong 8a0d6c100e mailparsing: upgrade nom to 8.0 2026-03-28 07:20:28 +00:00
Wez Furlong 5f191700ae dkim: upgrade nom to 8.0 2026-03-28 07:20:28 +00:00
Wez Furlong 863c323c3a deps: upgrade nom to latest 7.x release 2026-03-28 07:20:27 +00:00
Wez Furlong 4b84181479 SharedString: remove deref to str, deal with fanout
Removes the deref to str as this is now a fallible operation that
can panic.

Process the fanout of this change, which is dealing with more
possibility that things might be binary in more places.

There are some transitional APIs introduced as deprecated so that I'm
nagged to remove them already: I want to get the bulk of the code aware
of the possibility of binary sorted before I tackle adjusting the
message parser for that, so that that particular commit is more
self-contained.
2026-03-28 07:20:27 +00:00
Wez Furlong 5a72795376 refactor: conceptually enable mimepart construction from binary
Enable constructing or replacing the body portion of a mime
part with binary content.
2026-03-28 07:20:27 +00:00
Wez Furlong 16f019794e kumo-wrap: enable operating on bytes 2026-03-28 07:20:26 +00:00
Wez Furlong 1ac2f0ee5b mailparsing: refactor SharedString for binary data
This is a step towards allowing non-UTF-8 data to be tracked
in the SharedString type.

It is not complete; some tests now panic with UTF-8 input where
they would previously implicitly perform a lossy conversion.
That will be resolved in subsequent commit(s).
2026-03-28 07:20:26 +00:00
dependabot[bot] 448d3d7e55 build(deps): bump quinn-proto from 0.11.13 to 0.11.14
Bumps [quinn-proto](https://github.com/quinn-rs/quinn) from 0.11.13 to 0.11.14.
- [Release notes](https://github.com/quinn-rs/quinn/releases)
- [Commits](https://github.com/quinn-rs/quinn/compare/quinn-proto-0.11.13...quinn-proto-0.11.14)

---
updated-dependencies:
- dependency-name: quinn-proto
  dependency-version: 0.11.14
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-16 14:40:39 +00:00
Wez Furlong 1c5221ba00 add /api/admin/task-dump api endpoint
This dumps out a trace of all tokio tasks.  It is quite expensive,
and currently unsettles the tokio runtime such that you need to
repeatedly call this endpoint in order for a subsequent graceful
shutdown to clock through and complete.
2026-03-11 15:19:23 +00:00
Wez Furlong c151016472 lruttl: add consistency/robustness check
In our thundering herd protection we intentionally limit the number of
pending lookups for a given key to just 1.  That is controlled via
a semaphore.

We have pre-existing logic that checks to see if the semaphore has been
closed (eg: by a task being cancelled), but despite this, we do
occasionally have reports from users with `timed out after 120s on
semaphore acquire while waiting for cache to populate` for the shaping
data cache.

This typically correlates with eg: long IO waits due to eg: a spike in
transient failures and usually some sort of logging of headers, but not
always.

The not always situation bothers me as we don't currently have a good
explanation of what might be causing the excessive delay.

This commit adds an additional sanity check: when a new lookup is
initiated, if the semaphore is still open (not cancelled), but has been
open for longer than the populate timeout, then we treat this similarly
to the semaphore being closed: we'll create a new semaphore, reset the
expiration and the caller will typically then promote itself to the task
that will satisfy the lookup.

The side effect of this all waiters should become unblocked and awake
either with an error status or with the result of the new lookup, which
should help to clear any persistent/recurring blocking state associated
with this.

This change doesn't provide more insight (I have something in mind for a
follow-on commit for that), but should help make forward progress.
2026-03-11 15:19:23 +00:00
Wez Furlong 2658c8616e refactor: move ShuttingDownError into lifecycle
This centralizes a little bit of logic and makes things a hair cleaner.
2026-03-11 15:19:23 +00:00
Wez Furlong 50dececf3c lifecycle: add label to Activity::get error case
Continuing thread from prior commit, improve the context we
show during shutdown.

Take the opportunity to switch Mutex to parking_lot which is
slightly faster and doesn't have the warty unwrap() API
surface.
2026-03-11 15:19:22 +00:00
Wez Furlong 8958935426 cargo update 2026-03-09 08:49:36 +00:00
Wez Furlong 57a7b5e425 update rust-openssl to dane-openssl-v0.10.75 2026-03-05 17:19:52 +00:00
Wez Furlong d489f738f3 fix an issue around mx_list and config refreshing
If you have two scheduled queues with the same mx_list and then one of
those domains is updated to use a different mx_list, depending on the
ordering of the updates and subsequent traffic, the changed domain may
continue to have traffic route through the old mx_list.

The reason for this is that protocol configuration for that egress path
comes from the scheduled queue configuration, and there is no explicit
dependency between the two pieces of configuration.

This commit resolves this by adding a sanity check that the protocol
information is consistent with the ready queue instance.  If it is no
longer consistent we'll remove the association between the rq name and
the instance, then wind down any associated dispatchers.
2026-03-02 15:13:01 +00:00
Aditya Ganti f0e48bdb27 dkim: fix wrapping issue
It was reported that AWS SES could mark the DKIM signature as failed
when using a specific combination of headers in the header list,
with specific lengths of the other fields.

The reason for this is that we had two passes of wrapping applied
to the header, and they might not agree on the formatting of
the header.

The solution is to remove the second pass and just take a bit more
care to emit the header in a wrapped form in the first instance,
that way there can be no discrepancy or conflict.

closes: https://github.com/KumoCorp/kumomta/pull/483
2026-02-28 08:17:09 +00:00
Wez Furlong 3bc3da882b cargo update 2026-02-24 13:03:44 +00:00
Wez Furlong d8a7b0170e add new cpu usage metrics
refs: https://github.com/KumoCorp/kumomta/issues/186
2026-02-24 12:19:54 +00:00
Wez Furlong 909b1190cd refactor: extract kumo-api-client from kcli
This enables reusing just the http client parts of kcli
in another module in the future.
2026-02-24 12:19:53 +00:00
Wez Furlong 9bd3a5da23 introduce kumo-machine-info crate
This crate queries machine/system information which is intended
to be used in system monitoring.

This information is not centrally collected or retained by kumocorp,
merely reported via an API endpoint which is accessible only to trusted
IPs.

Machine info tries to interrogate information about the running/hosting
cloud platform for the major cloud providers, as well as indicate
whether it is running in a container of some kind.

The full cloud information is not re-exported via the API endpoint at
this time, but a fingerprint that encodes things like the instance-id is
included.
2026-02-24 12:19:53 +00:00
Tobias Horst 719e140f0e mod_nats: integrate nats
Publish messages using the jetstream client.
Supports password and token authentication.

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
Closes: https://github.com/KumoCorp/kumomta/pull/449
2026-02-24 11:03:43 +00:00