Commit Graph
39 Commits
Author SHA1 Message Date
Wez Furlong a00e8d0f0a NEW: add tracing to smtp client, kcli trace-smtp-client
It is now possible to trace outbound SMTP sessions, filtering
by a variety of properties.

Details are in `kcli trace-smtp-client --help` and also in
the docs at /reference/kcli/trace-smtp-client.md

refs: #87
2024-07-11 08:56:25 -07:00
Wez Furlong 5b0d936ef7 docs: improve markdown output for the kcli help 2024-06-27 15:40:39 -07:00
Wez Furlong fa2c6225e8 docs: add kcli reference docs
These are automatically extracted from `kcli --help`.
2024-06-27 15:18:07 -07:00
Wez Furlong 6bb74f88da fix some warnings
These are all harmless; we do rely on printing these things
in Debug impls when under test.
2024-06-25 07:41:40 -07:00
Wez Furlong 785feb4510 cidr: update dep and revise error handling
The upstream cidr crate has a released a version that exposes the more
relaxed parser, so refactor the prior work from
7eb5bdcb5f (which was pointing to a
temporary development branch) to reference its "final form".

This is done by exposing a `parse_cidr` function from our cidr-map
crate, and standardizing all callers to route through that.

refs: https://github.com/stbuehler/rust-cidr/issues/8
2024-06-25 07:34:18 -07:00
Wez Furlong a2d76df7a9 NEW: rebind API and kcli subcommand
refs: https://github.com/KumoCorp/kumomta/issues/209
2024-06-24 12:26:06 -07:00
Wez Furlong 29e4ec312d provide helpful reminder that bouncing is async
closes: https://github.com/KumoCorp/kumomta/issues/191
2024-05-30 16:46:03 -07:00
Wez Furlong 138a1eab72 kcli top: clock the thread pool data during error states
I noticed that these were static while the other time series
were moving to the left, so let's fix that!
2024-05-07 14:14:30 -07:00
Wez Furlong 1554f1bf53 spool: add spoolin pool
This is so that we don't over-saturate the RUNTIME/localset pool during
startup.  I observed that we can block `kcli top` for some time with
the new defaults for localset size, because the spoolin logic was
assuming that it could spawn more tasks than there were localset
threads.

This commit includes some tweaks to allow a thread pool to be short
lived and tear itself down, and some also in `kcli top` so that
we can sanely present the thread pool finishing up and going away.
2024-05-07 12:09:21 -07:00
Wez Furlong 6b98eb1f4b kcli: add a default timeout to internal http requests 2024-05-07 08:46:25 -07:00
Wez Furlong 39dc6c73a7 kcli top: increase min width
Makes the titles look less cluttered when the terminal is large
2024-05-06 20:14:49 -07:00
Wez Furlong bef8baebc2 kcli top: improve layout, add metrics
Add permfail and thread pool utilization metrics.
Make the vertical layout work a bit better.
2024-05-06 20:06:34 -07:00
Wez Furlong 69aa8b9b7c rustfmt 2024-05-04 15:55:54 -07:00
Wez Furlong b8a0b26936 NEW: kcli top
This will shows some TUI sparkline charts of major system metrics
over time.
2024-05-04 13:13:09 -07:00
Wez Furlong e41b4297ea tsa: hook up websocket suspension stream
This commit connects the new websocket based suspension feed
up to shaping.lua. This allows ready-q suspensions to be
enacted in realtime, as well as sets things up to support
scheduled queue suspensions in a later commit.

refs: https://github.com/KumoCorp/kumomta/issues/113
2024-03-28 07:14:36 -07:00
Wez Furlong 584334e30b deps: make reqwest a workspace dependency 2024-03-26 06:46:07 -07:00
dependabot[bot] 10d14ed2c1 build(deps): bump the all group with 9 updates
Bumps the all group with 9 updates:

| Package | From | To |
| --- | --- | --- |
| [tempfile](https://github.com/Stebalien/tempfile) | `3.10.0` | `3.10.1` |
| [strum](https://github.com/Peternator7/strum) | `0.26.1` | `0.26.2` |
| [chrono](https://github.com/chronotope/chrono) | `0.4.34` | `0.4.35` |
| [clap](https://github.com/clap-rs/clap) | `4.5.1` | `4.5.2` |
| [reqwest](https://github.com/seanmonstar/reqwest) | `0.11.24` | `0.11.25` |
| [env_logger](https://github.com/rust-cli/env_logger) | `0.11.2` | `0.11.3` |
| [log](https://github.com/rust-lang/log) | `0.4.20` | `0.4.21` |
| [pest](https://github.com/pest-parser/pest) | `2.7.7` | `2.7.8` |
| [pest_derive](https://github.com/pest-parser/pest) | `2.7.7` | `2.7.8` |


Updates `tempfile` from 3.10.0 to 3.10.1
- [Changelog](https://github.com/Stebalien/tempfile/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Stebalien/tempfile/compare/v3.10.0...v3.10.1)

Updates `strum` from 0.26.1 to 0.26.2
- [Release notes](https://github.com/Peternator7/strum/releases)
- [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Peternator7/strum/commits)

Updates `chrono` from 0.4.34 to 0.4.35
- [Release notes](https://github.com/chronotope/chrono/releases)
- [Changelog](https://github.com/chronotope/chrono/blob/main/CHANGELOG.md)
- [Commits](https://github.com/chronotope/chrono/compare/v0.4.34...v0.4.35)

Updates `clap` from 4.5.1 to 4.5.2
- [Release notes](https://github.com/clap-rs/clap/releases)
- [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md)
- [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.1...v4.5.2)

Updates `reqwest` from 0.11.24 to 0.11.25
- [Release notes](https://github.com/seanmonstar/reqwest/releases)
- [Changelog](https://github.com/seanmonstar/reqwest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seanmonstar/reqwest/compare/v0.11.24...v0.11.25)

Updates `env_logger` from 0.11.2 to 0.11.3
- [Release notes](https://github.com/rust-cli/env_logger/releases)
- [Changelog](https://github.com/rust-cli/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-cli/env_logger/compare/v0.11.2...v0.11.3)

Updates `log` from 0.4.20 to 0.4.21
- [Release notes](https://github.com/rust-lang/log/releases)
- [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/log/compare/0.4.20...0.4.21)

Updates `pest` from 2.7.7 to 2.7.8
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.7...v2.7.8)

Updates `pest_derive` from 2.7.7 to 2.7.8
- [Release notes](https://github.com/pest-parser/pest/releases)
- [Commits](https://github.com/pest-parser/pest/compare/v2.7.7...v2.7.8)

---
updated-dependencies:
- dependency-name: tempfile
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: strum
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: chrono
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: clap
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: reqwest
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: env_logger
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: log
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: pest
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: pest_derive
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-11 07:01:49 -07:00
dependabot[bot] 113eeb5380 build(deps): bump the all group with 13 updates
Bumps the all group with 13 updates:

| Package | From | To |
| --- | --- | --- |
| [strum](https://github.com/Peternator7/strum) | `0.25.0` | `0.26.1` |
| [k9](https://github.com/aaronabramov/k9) | `0.11.6` | `0.12.0` |
| [lipsum](https://github.com/mgeisler/lipsum) | `0.8.2` | `0.9.0` |
| [zstd](https://github.com/gyscos/zstd-rs) | `0.12.4` | `0.13.0` |
| [tungstenite](https://github.com/snapview/tungstenite-rs) | `0.20.1` | `0.21.0` |
| [async-channel](https://github.com/smol-rs/async-channel) | `1.9.0` | `2.1.1` |
| [flume](https://github.com/zesterer/flume) | `0.10.14` | `0.11.0` |
| [metrics](https://github.com/metrics-rs/metrics) | `0.20.1` | `0.22.0` |
| [env_logger](https://github.com/rust-cli/env_logger) | `0.10.2` | `0.11.1` |
| [notify](https://github.com/notify-rs/notify) | `5.2.0` | `6.1.1` |
| [zstd-safe](https://github.com/gyscos/zstd-rs) | `6.0.6` | `7.0.0` |
| [which](https://github.com/harryfei/which-rs) | `4.4.2` | `6.0.0` |
| [git2](https://github.com/rust-lang/git2-rs) | `0.16.1` | `0.18.1` |


Updates `strum` from 0.25.0 to 0.26.1
- [Release notes](https://github.com/Peternator7/strum/releases)
- [Changelog](https://github.com/Peternator7/strum/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Peternator7/strum/commits/v0.26.1)

Updates `k9` from 0.11.6 to 0.12.0
- [Commits](https://github.com/aaronabramov/k9/commits)

Updates `lipsum` from 0.8.2 to 0.9.0
- [Release notes](https://github.com/mgeisler/lipsum/releases)
- [Commits](https://github.com/mgeisler/lipsum/compare/0.8.2...0.9.0)

Updates `zstd` from 0.12.4 to 0.13.0
- [Release notes](https://github.com/gyscos/zstd-rs/releases)
- [Commits](https://github.com/gyscos/zstd-rs/compare/v0.12.4...v0.13.0)

Updates `tungstenite` from 0.20.1 to 0.21.0
- [Changelog](https://github.com/snapview/tungstenite-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/snapview/tungstenite-rs/compare/v0.20.1...v0.21.0)

Updates `async-channel` from 1.9.0 to 2.1.1
- [Release notes](https://github.com/smol-rs/async-channel/releases)
- [Changelog](https://github.com/smol-rs/async-channel/blob/master/CHANGELOG.md)
- [Commits](https://github.com/smol-rs/async-channel/compare/v1.9.0...v2.1.1)

Updates `flume` from 0.10.14 to 0.11.0
- [Changelog](https://github.com/zesterer/flume/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zesterer/flume/commits)

Updates `metrics` from 0.20.1 to 0.22.0
- [Changelog](https://github.com/metrics-rs/metrics/blob/main/release.toml)
- [Commits](https://github.com/metrics-rs/metrics/compare/metrics-v0.20.1...metrics-v0.22.0)

Updates `env_logger` from 0.10.2 to 0.11.1
- [Release notes](https://github.com/rust-cli/env_logger/releases)
- [Changelog](https://github.com/rust-cli/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-cli/env_logger/compare/v0.10.2...v0.11.1)

Updates `notify` from 5.2.0 to 6.1.1
- [Release notes](https://github.com/notify-rs/notify/releases)
- [Changelog](https://github.com/notify-rs/notify/blob/main/CHANGELOG.md)
- [Commits](https://github.com/notify-rs/notify/commits/notify-6.1.1)

Updates `zstd-safe` from 6.0.6 to 7.0.0
- [Release notes](https://github.com/gyscos/zstd-rs/releases)
- [Commits](https://github.com/gyscos/zstd-rs/compare/zstd-safe-6.0.6...zstd-safe-7.0.0)

Updates `which` from 4.4.2 to 6.0.0
- [Release notes](https://github.com/harryfei/which-rs/releases)
- [Changelog](https://github.com/harryfei/which-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/harryfei/which-rs/compare/4.4.2...6.0.0)

Updates `git2` from 0.16.1 to 0.18.1
- [Changelog](https://github.com/rust-lang/git2-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/git2-rs/compare/0.16.1...git2-0.18.1)

---
updated-dependencies:
- dependency-name: strum
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: k9
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: lipsum
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: zstd
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: tungstenite
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: async-channel
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all
- dependency-name: flume
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: metrics
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: env_logger
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: notify
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all
- dependency-name: zstd-safe
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all
- dependency-name: which
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: all
- dependency-name: git2
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-06 19:23:23 -07:00
Wez Furlong e6973c2a04 slim down some deps
This helps to remove "false" deps on things like openssl; now that
is linked in only to those components that need it (eg: things that
use unbound for dnssec, or the smtp client for DANE).

This makes the binaries other than kumod (which still has max deps)
a few MB smaller; not a massive win, but nice all the same.
2023-12-22 10:24:30 -07:00
Wez Furlong c40f86e039 Add suppress-logging option to admin bounces
closes: https://github.com/KumoCorp/kumomta/issues/75
2023-11-23 08:36:07 -07:00
Wez Furlong 4dadafe31d deps: uuid->1.4, cargo update 2023-08-25 09:00:43 -07:00
Wez Furlong d843579d1e refactor: control some dep versions via workspace Cargo.toml
This makes it easier to upgrade the version holistically later.
2023-08-17 10:49:25 -07:00
Wez Furlong 5bea1013da trace_smtp_server: add colorized output
Makes it easier to see the sent vs. received data
2023-08-13 16:57:00 -07:00
Wez Furlong 4f53566fde trace_smtp_server: show meta keys one per line
This makes it easier to read and see what changed
2023-08-13 16:40:04 -07:00
Wez Furlong c3e6a4fce7 trace_smtp_server: add timestamp to trace events 2023-08-13 15:34:28 -07:00
Wez Furlong 81ff4043e3 add kcli trace-smtp-server subcommand
This allows tracing incoming SMTP sessions.

Sessions are traced through to the cli in realtime.

The implementation is via a websocket, which makes this also potentially
pluggable into a webui in the future, although care must be taken to
ensure that only authorized system operators can enable this, as it can
reveal authentication secrets in the traced dialog, as well as the
content of messages.

This commit doesn't include documentation on the shape of the websocket
JSON at this time.

refs: https://github.com/KumoCorp/kumomta/issues/44

```
; ./target/debug/kcli trace-smtp-server
[127.0.0.1:51778->127.0.0.1:2025] === Connected {"received_from":"127.0.0.1:51778","received_via":"127.0.0.1:2025","reception_protocol":"ESMTP"}
[127.0.0.1:51778->127.0.0.1:2025] <-  220 foo Welcome to KumoMTA!
[127.0.0.1:51778->127.0.0.1:2025]  -> EHLO foo.lan
[127.0.0.1:51778->127.0.0.1:2025] === smtp_server_ehlo: Ok
[127.0.0.1:51778->127.0.0.1:2025] <-  250-foo Aloha foo.lan
[127.0.0.1:51778->127.0.0.1:2025] <-  250-PIPELINING
[127.0.0.1:51778->127.0.0.1:2025] <-  250-ENHANCEDSTATUSCODES
[127.0.0.1:51778->127.0.0.1:2025] <-  250 STARTTLS
[127.0.0.1:51778->127.0.0.1:2025]  -> STARTTLS
[127.0.0.1:51778->127.0.0.1:2025] <-  220 Ready to Start TLS
[127.0.0.1:51778->127.0.0.1:2025]  -> EHLO foo.lan
[127.0.0.1:51778->127.0.0.1:2025] === smtp_server_ehlo: Ok
[127.0.0.1:51778->127.0.0.1:2025] <-  250-foo Aloha foo.lan
[127.0.0.1:51778->127.0.0.1:2025] <-  250-PIPELINING
[127.0.0.1:51778->127.0.0.1:2025] <-  250-ENHANCEDSTATUSCODES
[127.0.0.1:51778->127.0.0.1:2025] <-  250 AUTH PLAIN
[127.0.0.1:51778->127.0.0.1:2025]  -> AUTH PLAIN AHNjb3R0AHRpZ2Vy
[127.0.0.1:51778->127.0.0.1:2025] === smtp_server_auth_plain: Ok: Bool(true)
[127.0.0.1:51778->127.0.0.1:2025] <-  235 2.7.0 AUTH OK!
[127.0.0.1:51778->127.0.0.1:2025] === conn_meta updated to {"authn_id":"scott","authz_id":"scott","received_from":"127.0.0.1:51778","received_via":"127.0.0.1:2025","reception_protocol":"ESMTP"}
[127.0.0.1:51778->127.0.0.1:2025]  -> MAIL FROM:<wez@example.com>
[127.0.0.1:51778->127.0.0.1:2025] === smtp_server_mail_from: Ok
[127.0.0.1:51778->127.0.0.1:2025] <-  250 OK EnvelopeAddress(\"wez@example.com\")
[127.0.0.1:51778->127.0.0.1:2025]  -> RCPT TO:<wez@wezfurlong.org>
[127.0.0.1:51778->127.0.0.1:2025] === smtp_server_rcpt_to: Ok
[127.0.0.1:51778->127.0.0.1:2025] <-  250 OK EnvelopeAddress(\"wez@wezfurlong.org\")
[127.0.0.1:51778->127.0.0.1:2025]  -> DATA
[127.0.0.1:51778->127.0.0.1:2025] <-  354 Send body; end with CRLF.CRLF
[127.0.0.1:51778->127.0.0.1:2025]  -> Date: Sun, 13 Aug 2023 10:10:40 -0700
[127.0.0.1:51778->127.0.0.1:2025]  -> To: wez@wezfurlong.org
[127.0.0.1:51778->127.0.0.1:2025]  -> From: wez@example.com
[127.0.0.1:51778->127.0.0.1:2025]  -> Subject: test Sun, 13 Aug 2023 10:10:40 -0700
[127.0.0.1:51778->127.0.0.1:2025]  -> Message-Id: <20230813101040.1426417@foo>
[127.0.0.1:51778->127.0.0.1:2025]  -> X-Mailer: swaks v20201014.0 jetmore.org/john/code/swaks/
[127.0.0.1:51778->127.0.0.1:2025]  ->
[127.0.0.1:51778->127.0.0.1:2025]  -> This is a test mailing
[127.0.0.1:51778->127.0.0.1:2025]  ->
[127.0.0.1:51778->127.0.0.1:2025]  ->
[127.0.0.1:51778->127.0.0.1:2025]  -> .
[127.0.0.1:51778->127.0.0.1:2025] === smtp_server_message_received: Ok
[127.0.0.1:51778->127.0.0.1:2025] === Message from=wez@example.com to=wez@wezfurlong.org id=5465de7739fc11ee8af250ebf67f93bd
[127.0.0.1:51778->127.0.0.1:2025] === Message queue=wezfurlong.org relay=true log_arf=false log_oob=false
[127.0.0.1:51778->127.0.0.1:2025] === Message meta: {"authn_id":"scott","authz_id":"scott","received_from":"127.0.0.1:51778","received_via":"127.0.0.1:2025","reception_protocol":"ESMTP"}
[127.0.0.1:51778->127.0.0.1:2025] <-  250 OK ids=5465de7739fc11ee8af250ebf67f93bd
[127.0.0.1:51778->127.0.0.1:2025]  -> QUIT
[127.0.0.1:51778->127.0.0.1:2025] <-  221 So long, and thanks for all the fish!
[127.0.0.1:51778->127.0.0.1:2025] === Closed
```
2023-08-13 10:17:04 -07:00
Wez Furlong 29ce975970 kcli: add routing_domain support to bounce API and commands 2023-08-10 22:02:07 -07:00
Wez Furlong fbb140026d kcli queue-summary: use stop emoji rather than pause emoji
It looks clearer and easier to understand than the pause emoji,
especially at normal terminal font sizes.
2023-08-07 08:06:39 -07:00
Wez Furlong 927e18dd58 kcli queue-summary: use emoji to indicate suspensions and bounces
Use the pause emoji for suspensions, and the wastebasket emoji for
bounces.  These are shown in the final column of the respective
sections.

Note that for bounces there will only be a short time window where you
will see a bounced domain show up in the list because the bounce will
remove it from the system fairly quickly.
2023-08-05 13:43:58 -07:00
Wez Furlong 93423f7778 kcli queue-summary: parallelize domain resolution with --domain
Resolve them all concurrently
2023-08-05 10:27:00 -07:00
Wez Furlong 5e966f4571 kcli queue-summary: use natural sort for names
So that `source10` sorts after `source9` rather than `source1`
2023-08-05 09:57:51 -07:00
Wez Furlong 7b63f7d80d kcli queue-summary: add --domain option
Allows filtering the results to just those queues associated
with the requested domain.  Uses site names to map domains
to their associated ready queues.
2023-08-04 22:57:46 -07:00
Wez Furlong 6b8a6b8435 kcli: add queue-summary command
Helpful for an at-a-glance idea of what's happening
2023-08-04 20:19:45 -07:00
Wez Furlong 8e0d7b2c07 kcli: add default for --endpoint, and allow reading from env 2023-08-04 18:19:22 -07:00
Wez Furlong dde4b29fba api/cli: add inspect-message API for looking at a message by id
More detailed docs will follow once some other similar APIs are
completed.
2023-07-18 11:22:57 -07:00
Wez Furlong eb6232f582 Add basic suspension of scheduled and ready queues
These are two different groups of queues, so there are two different
sets of things to manage them.

kcli now has `suspend(-list|cancel)?` and
`suspend-ready-q(-list|cancel)?` subcommands for establishing a
suspension, listing the suspensions and cancelling a suspension
in the scheduled-q and ready-q namespaces respectively.

The names of the ready queues can be derived from the metrics API:

```console
$ curl -s 'http://localhost:8000/metrics.json'  | jq .
...
  "ready_count": {
    "help": "number of messages in the ready queue",
    "type": "gauge",
    "value": {
      "service": {
        "smtp_client:source2->(in1-smtp|in2-smtp).messagingengine.com": 0.0
      }
    }
  },
...
```

From the above, `source2->(in1-smtp|in2-smtp).messagingengine.com` is
the name of the underlying ready queue.

We can and probably should add something to `kcli` to make that slightly
easier to review and manage for the operator.

refs: https://github.com/KumoCorp/kumomta/issues/51
2023-06-23 07:50:56 -07:00
Wez Furlong 9e83e72500 kcli: centralize request making and resolving, improve error messaging
Previously, an authentication issue could manifest as an opaque and
confusing error message like

```
Error: error decoding response body: expected value at line 1 column 1
```

now we show it like:

```
Error: request status 401: Unauthorized. Response body: Missing Authorization header
```
2023-06-22 09:55:59 -07:00
Wez Furlong 0249bd0d4d kcli: you may now list and cancel admin bounce entries
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
```
2023-06-12 10:11:53 -07:00
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