This help transitions to a cheaper email parser, that doesn't need to
parse the entire MIME structure
Note that as part of this, I found that several tests were running
against email messages using unix line endings instead of canonical
CRLF.
This was silently being masked and an empty or otherwise incorrect byte
slice was being hashed; I've updated the affected tests and their test
expectations accordingly, as well as made this error bubble up at the
time of parsing the email, rather than silently squashing it in the
depths of the hasher.
This doesn't totally eliminate them, but for the body at least,
we can stream and hash the data and avoid making potentially
very many very large allocations in a busy signing application.
This is a much more efficient implementation with ~20% improved
throughput and latency with the simple signing benchmark.
signing/sign time: [1.3024 ms 1.3050 ms 1.3076 ms]
thrpt: [2.2886 MiB/s 2.2933 MiB/s 2.2978 MiB/s]
change:
time: [-19.016% -18.855% -18.691%] (p = 0.00 < 0.05)
thrpt: [+22.987% +23.237% +23.482%]
Performance has improved.
We don't set received_via for http because axum/hyper make it a
bit weird to access that information and it will require some
effort to figure out how to get that without breaking the
existing proxy-aware client IP determination.
Entries now have a uuid that identifies them within a given instance
(NOT within a cluster). The id is returned when the entry is
established:
```console
$ kcli --endpoint http://127.0.0.1:8000 bounce --everything --reason boop
{
"id": "9a946198-9351-4e0e-b460-fc84e066878a",
"bounced": {},
"total_bounced": 0
}
```
You can list entries with their remaining duration:
```console
$ kcli --endpoint http://127.0.0.1:8000 bounce-list
[
{
"id": "9a946198-9351-4e0e-b460-fc84e066878a",
"campaign": null,
"tenant": null,
"domain": null,
"reason": "boop",
"duration": "4m 57s 313ms 891us 882ns"
}
]
```
and cancel them:
```console
$ kcli --endpoint http://127.0.0.1:8000 bounce-cancel --id 9a946198-9351-4e0e-b460-fc84e066878a
removed 9a946198-9351-4e0e-b460-fc84e066878a
```
and the error case if you try it again:
```console
$ kcli --endpoint http://127.0.0.1:8000 bounce-cancel --id 9a946198-9351-4e0e-b460-fc84e066878a
Error: bounce entry 9a946198-9351-4e0e-b460-fc84e066878a not found
```
This doesn't do anything in the current milestone, but I wanted
to get it in there ready for work for the next milestone,
where I plan to make it possible to list and remove/cancel
a bounce, as well as persist them across a restart.
It is rather difficult to reuse the Signer in a dynamic application with
the lifetime present in the struct.
This commit removes the lifetime to make it easier to cache and reuse.
The logger has also been removed from the API for the signer. It was
used only in one place to log a single debug line, and it is a bit of an
imposition on the embedding application to require the use of the `slog`
crate just for that, and its removal helps with the goal of removing
lifetimes from the struct as well.
Some builder methods have been made a little more ergonomic by accepting
values that are convertible to String rather than requiring str
references.
Since this commit changes the API signature, it also bumps the version
from 0.2 to 0.3.
The mail-auth crate doesn't support 1024 bit RSA keys, which are
currently the dominant size of key used by senders at scale.
It is not possible to even configure a 2048 bit RSA key in some DNS
providers, which blocks widespread adoption of larger key sizes.
This commit pulls in the cfdkim crate as an alternative implementation.
I'm not happy with this implementation because the API of the crate
defeats some caching optimizations, doesn't support certain signing
attributes that are supported by mail-auth and the generated header isn't
nicely wrapped.
We'll likely "do something" to resolve this in a future commit.
For now, this implementation is enabled by setting `use_cf = true`
in the signing parameters.