Commit Graph
15 Commits
Author SHA1 Message Date
Wez Furlong 22451330f4 CLI: add kcli command for interacting with admin http endpoints
```console
$ kcli --help
KumoMTA CLI.

Full docs available at: <https://docs.kumomta.com>

Usage: kcli --endpoint <ENDPOINT> <COMMAND>

Commands:
  bounce
          Administratively bounce messages in matching queues
  set-log-filter
          Changes the diagnostic log filter
  help
          Print this message or the help of the given subcommand(s)

Options:
      --endpoint <ENDPOINT>
          URL to reach the KumoMTA HTTP API

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version
```

```console
$ kcli bounce --help
Administratively bounce messages in matching queues.

Each individual message that is bounced will generate a log record capturing the event and then be removed from the spool.

Make sure that you mean it, as there is no going back!

The bounce will be applied immediately to queued messages, and the directive will remain in effect for the duration specified, causing newly received messages or messages that were in a transient state at the time the directive was received, to also be bounced as they are placed back into the matching queue(s).

Usage: kcli --endpoint <ENDPOINT> bounce [OPTIONS] --reason <REASON>

Options:
      --domain <DOMAIN>
          The domain name to match. If omitted, any domains will match!

      --campaign <CAMPAIGN>
          The campaign name to match. If omitted, any campaigns will match!

      --tenant <TENANT>
          The tenant name to match. If omitted, any tenant will match!

      --reason <REASON>
          The reason to log in the delivery logs

      --everything
          Purge all queues

      --duration <DURATION>
          The duration over which matching messages will continue to bounce. The default is '5m'

  -h, --help
          Print help (see a summary with '-h')
```

```console
$ kcli set-log-filter --help
Changes the diagnostic log filter

See <https://docs.kumomta.com/reference/kumo/set_diagnostic_log_filter/> for more information about the log filter syntax.

Usage: kcli --endpoint <ENDPOINT> set-log-filter <FILTER>

Arguments:
  <FILTER>

Options:
  -h, --help  Print help
```

refs: https://github.com/KumoCorp/kumomta/issues/55
2023-06-07 12:09:07 -07:00
Wez Furlong beb120fda5 Add a SOCKS5 proxy server implementation
This is a pretty tight, lightweight implementation of SOCKS5
intended to be used to facilitate an MTA asking it to bind and
connect.

It uses the splice(2) syscall to avoid kernel/userspace copies
when passing data through, so it should be quite efficient.

refs: https://github.com/KumoCorp/kumomta/issues/45
2023-05-15 17:38:17 -07:00
Wez Furlong d3a5626180 Add log tailer utility
This commit adjusts the logger:

* When a log segment is finised, the `w` permission bits are removed.
  This is used to signal to the tailer that there will be no additional
  data written to that file.

* On startup, kumod will remove the `w` bits from all files in the
  configured log directories so that any that were left on by a prior
  incarnation will be considered closed when the new generation is
  started up.

* Add a `tailer` utility that will essentially `cat` all of the log
  files in a given directory in the appropriate order, then go into
  log tailing mode, where it will wait for new data to show up.

* When reading data, if it hits EOF, the tailer will wait around until
  more data shows up, or until the `w` bit is removed from the file
  that it is reading.

The idea is that, in a later commit, the tailer will be able to persist
a checkpoint file to record where it got to, and be able to dispatch
chunks of data to eg: a webhook push utility, advancing the checkpoint
only when the utility indicates success.

For now, running `cargo run -p tailer -- --tail /var/tmp/kumo-logs` is
a convenient way to tail the logs as they are written.
2023-03-30 14:01:46 -07:00
Wez Furlong 6477fc8a25 refactor: move CidrSet to its own crate 2023-03-12 06:46:54 -07:00
Wez Furlong 8989586c9b refactor: move version info to its own crate
Several crates depend on the config crate, which means that
several things needed to be rebuilt after committing/amending/syncing.

Separating it out reduces that impact.
2023-03-11 06:27:31 -07:00
Wez Furlong 86bdb39ea0 include line table debug info in release builds
This gives a higher quality panic stack trace at the cost of inflating
the executable size from ~50MB -> ~500MB.

Full debug info is a possibility, but the executable size is ~800MB,
which is high, but not completely crazy. I don't know if we'll really
need that, so going with line debug for now.
2023-03-09 18:50:24 -07:00
Wez Furlong 51d1408aa6 scaffolding for integration tests 2023-03-07 14:54:19 -07:00
Wez Furlong ef7fa59355 synthesize OOB log records from OOB reports
* When logging the reception of a message, if we can parse it
  as an rfc3464 oob report, then synthesize OOB records for
  each recipient
* Add config to allow relaying for domains for which bounces
  are received, so that we can accept their message content.
* If the domain config allows bounces but not relaying, then
  the message will not be spooled or queued after reception;
  it will be dropped with no additional logging.
2023-03-03 06:53:33 -07:00
Wez Furlong 74635be9fb Add extensible bounce classifier
The classifier can load and merge rules from multiple files.
A basic iana enhanced status codes ruleset is provided.
A deployment can define their own to augment that set.

This commit is just the core classifier functionality; it
is not yet connected to kumod.

The classification enum is a bit of an amalgam of categories
defined by other well-known vendors/products and the categories
defined by IANA.  Some classifications have no corresponding
rules at the current time.
2023-03-02 08:27:32 -07:00
Wez Furlong a65863bfc4 add throttle crate
This currently uses in-memory only throttles, but it uses literally
the same code that is used to implement the redis-cell based solution
we're planning to hit for sharing throttles across a cluster,
so it should be a fairly easy future code change to make it do that,
with no change in semantics.
2023-02-27 19:05:20 -07:00
Wez Furlong caf47d4c4e add traffic generator 2023-02-20 10:30:58 -07:00
Wez Furlong c4c206df1e Add rfc5321 protocol parser
This parses commands received by the server.
Can be expanded to responses from a server in the future.
2023-02-16 16:25:17 -07:00
Wez Furlong e4d4d7aeee add a spool implementation 2023-02-12 11:46:46 -07:00
Wez Furlong 6f5865e2b8 add timeq data structure 2023-02-11 23:07:48 -07:00
Wez Furlong 3287523d84 Skeleton tokio server for kumod 2023-02-10 16:44:10 -07:00