Commit Graph
223 Commits
Author SHA1 Message Date
Wez Furlong be5d5a8c23 run-lua-test: prefer local builds over installed build 2024-07-10 07:59:32 -07:00
Wez Furlong 97286058a1 run-lua-test: prefer debug kumod over release kumod
When we're running tests, we're generally running the debug build, so it
doesn't make sense to run the (potentially cached and not yet up to
date) release build.
2024-07-10 07:56:18 -07:00
Wez Furlong 8c06f7d462 kumod: add --script and --script-args parameters
These are primarily for my benefit; they make it a bit easier
to run kumod for one-off scripts without running the full service,
with less "noise" than you'd get for hacking around it as I was
doing previously in the resolve-site-name script and in the lua
test runner.

The idea is that you can now define a script like:

```lua
local kumo = require 'kumo'

kumo.on('main', function(domain)
  local mx = kumo.dns.lookup_mx(domain)
  print(mx.site_name)
end)
```

And (more) conveniently run it like this:

```
$ kumod --policy /path/to/script --script --script-args outlook.com
outlook-com.olc.protection.outlook.com
```
2024-07-10 07:39:35 -07:00
Wez Furlong ec795b71d3 mod-http: add client:close() method
Allows explicit closure of any cached connections in the client
object.

Make use of this in the log_hooks:new_json method.
2024-07-09 13:57:46 -07:00
Wez Furlong d70f87593e ci: shift release creation to woodpecker, upload pkgs to release 2024-07-04 17:03:12 -07:00
Wez Furlong 072fc2ea30 ci: add arch to deb filename, fixup gh release upload for arm 2024-07-04 16:45:51 -07:00
Wez Furlong af7d19cb91 ci: try uploading main builds to a new dev GH release
Might need to add a different token for this action to succeed,
but let's give this a go.
2024-07-04 15:42:15 -07:00
Wez Furlong 1e29c1b459 ci: add gpg explicitly
This is needed to install the gh cli
2024-07-04 14:23:17 -07:00
Wez Furlong 7ad26cdac9 ci: install GH cli in the ubuntu image
This time for real; I edited the wrong script last time
2024-07-04 12:31:56 -07:00
Wez Furlong 2a33ed1101 ci: install GH cli in the ubuntu image 2024-07-04 08:54:53 -07:00
Wez Furlong 007e234d9e Add toml2jsonc utility to convert toml to json with comments
The intended purpose is to use to auto-generate json representations
of example toml data files for the documentation.

refs: https://github.com/KumoCorp/kumomta/issues/212
2024-07-03 11:53:59 -07:00
Wez Furlong 91ce59628d ci: fixup run-lua-test for running in ci 2024-06-28 13:33:47 -07:00
Wez Furlong 9ddc15c7a1 sources.lua: Add typing and test
refs: #211
2024-06-28 13:06:51 -07:00
Wez Furlong 426b5b8d31 log_hooks: add typing
This will perform more explicit checks to make sure that the name
is defined and so on. It also now will check for conflicting
log hook names as well.

refs: #211
2024-06-28 12:31:49 -07:00
Wez Furlong e96dfcfe38 typing: refine error handling for _dynamic fields
Better distinguish between unknown and mismatched types for dynamic
fields, and show a better error message for them.

refs: #211
2024-06-28 10:06:27 -07:00
Wez Furlong 11bbd07f3f listener_domains: add typing and validation
refs: #211
2024-06-28 09:43:38 -07:00
Wez Furlong f0b91dd652 queue.lua: add typing
I regret optimizing the structure for toml when this module was
created, as it makes it difficult to define a regular schema.

This commit introduces typed records for the queue helper
data structure, and, unfortunately, a parsing layer to adapt
between the toml data and the well-defined types.

It also adjusts how lua tests are run; previously we'd co-opt the main
flow of parsing by looking at an env var, but since the modules can now
potentially require each other (especially the typing module) we need to
de-couple from that, otherwise what happens is that we'd only ever run
the typing module tests and exit. So we now have a script that imports
all the modules and runs their respective `:test()` methods.

refs: #211
2024-06-28 08:54:46 -07:00
Wez Furlong fb2dad8b10 validation: check for ordering of get_queue_config events
refs: https://github.com/KumoCorp/kumomta/issues/211
2024-06-27 06:54:55 -07:00
Wez Furlong af99c0bb75 run-lua-test: factor out of Makefile
This makes the Makefile less verbose/boilerplate-y
2024-06-27 05:51:11 -07:00
Wez Furlong e63d1ca15c typing.lua: improve error reporting
Make the error messages a bit more regular and a bit easier
to read and trace.
2024-06-26 22:49:32 -07:00
Wez Furlong 245caaea6e dkim_sign.lua: make typing more succinct
This is a bit more legible
2024-06-26 17:48:33 -07:00
Wez Furlong aaaa96e7fb typing.lua: improve tests 2024-06-26 17:38:34 -07:00
Wez Furlong 7392ccf3d8 typing.lua: report errors from the caller's location
Don't attribute the error to the metamethods in the typing
module, attribute them to the calling code.
2024-06-26 17:04:28 -07:00
Wez Furlong b9dccf1cc3 add policy-extras.typing lua module
The primary purpose here is to allow defining typed records
for use in our helpers.

The dkim_sign module has been updated to make use of this
to ensure that the correct shape of data has been loaded.
2024-06-26 16:38:22 -07:00
Wez Furlong 39818c1e36 Add validation for dkim_sign helper
refs: https://github.com/KumoCorp/kumomta/issues/211
2024-06-25 12:08:37 -07:00
Wez Furlong 471b44ae02 sources.lua: fixup to iterate file names correctly when validating 2024-06-25 11:19:56 -07:00
Wez Furlong 3139be2cfd Add new kumod --validate flag
The purpose is to provide a deeper, offline validation pass
of the policy configuration, prior to deploying and making it
live.

The system behavior changes when in `--validate` mode:

* Listeners, spool and spawned tasks will be silently skipped;
  the parameters will be validated but the primary functions
  of those things will be skipped silently.
* After triggering the `init` event, an additional new `validate_config`
  event (which can be registered multiple times) will be triggered
  to allow lua modules to perform extended validation.
* A module can either raise an error via `error` to immediately report
  a problem, or instead call a new, preferred, `kumo.validation_failed()`
  function to flag validation as failed but allow additional validation
  to be performed and summarized all together.
* Once the `validate_config` event returns, the process will terminate
  with either exit code 0 for a successful validation, or non-zero
  to indicate that something failed.

Validation errors are reported in a human readable form.

This commit adds validate_config event handlers for the following
helper modules:

* `shaping` - any warnings reported by the underlying rust code
  will be reported here and cause validation to fail. This is
  functionally equivalent to using the `validate-shaping` binary,
  except that it will automatically be passed the set of shaping
  files defined by your `init.lua`

  If the `sources` helper is also configured, the list of sources
  referenced by the shaping config will be cross-checked against
  the sources data to confirm that all possible sources are defined.

* `sources` - each listed source and pool will be validated by
  calling `kumo.make_egress_source` or `kumo.make_egress_pool`
  respectively.

  Pool membership will be validated to confirm that every
  listed pool is defined in the sources data.

* `queues` - each domain and tenant that references an egress_pool
  will be cross-checked with the `sources` helper, if the sources
  helper has been configured.

It is now an error to attempt to setup any of the above helpers
more than once.

refs: https://github.com/KumoCorp/kumomta/issues/211
2024-06-25 11:05:04 -07:00
Wez Furlong 0f39f7e306 take a run at packaging the new resolve-site-name script 2024-06-19 13:30:34 -07:00
Wez Furlong ca048031ad Add script that can resolve and print the site-name
The guts of this hvae been shared on discord a couple of times.
Let's put this in a convenient script.
We should arrange to install this in our official packages,
but for now, let's get it in the repo.
2024-06-19 13:07:45 -07:00
Wez Furlong 4ad21257bd ci: fixup failure in PR mode
We need to avoid recursively copying any symlinks-to-dirs as
directories. We can do that with cp, but the parallel xcp utility
doesn't support the --no-dereference flag at this time.

refs: https://github.com/tarka/xcp/issues/52
2024-06-19 08:34:22 -07:00
Wez Furlong 3e398c1a29 ci: force non-incremental builds in CI 2024-06-12 12:24:24 -07:00
Wez Furlong c9b98adc10 ci: cache target dir directly 2024-06-12 12:19:29 -07:00
Wez Furlong c5428dd5c8 ci: add xcp (parallel cp) to builder image 2024-06-12 09:15:22 -07:00
Wez Furlong df2eb1ed1b ci: another run at sccache in the builder image 2024-06-11 11:27:33 -07:00
Wez Furlong 555bfded56 use arm-specific URL for nextest 2024-06-06 18:01:16 -07:00
Wez Furlong 9c20b9fbc4 ci: build builder images on wp
This is essentially a refactoring of the stuff that we've been running
on GH, but broken out to run on our woodpecker instance.

I've removed sccache from the image; it's actually been failing the
build on amazonlinux:2, but the GH action version of the build has
been showing up as green(!)
2024-06-06 17:33:37 -07:00
Wez Furlong 25ef5fcf70 tsa_init.lua: remove debug bits
These were accidentally checked in as part of be80391239
2024-05-02 10:35:49 -07:00
Wez Furlong 84c88f2eff ci: add sccache to builder image 2024-04-20 08:09:18 -07:00
Wez Furlong 1cc78033d7 ci: add jq to builder, build builder when builder changes 2024-04-20 07:24:59 -07:00
Wez Furlong c3f2d1a584 ci: use matrix build for images 2024-04-20 00:02:41 -07:00
Wez Furlong b4aa4a38ec http: allow controlling some timeout and diagnostics on the client
Adds a couple of options that provide more control over the default
timeouts and logging.

These are exposed to the shaping helper as `publish_timeout`,
`publish_pool_idle_timeout` and `publish_connection_verbose`.
2024-04-19 07:44:19 -07:00
Wez Furlong 415d4fc19c tsa: make the default queue config for tsa-daemon more aggressive
while troubleshooting a situation where the
http://127.0.0.1:8008.tsa.kumomta queue is backing up, I noticed that
we're using the default queue configuration for this queue.

Let's make it more inline with the defaults for webhooks; give it a
1 minute base retry with a 20 minute max.

These parameters are configurable; you can pass in `tsa_queue_config` to
the setup_with_automation call to specify your preferred values for the
scheduled queue config.
2024-04-10 14:17:23 -07:00
Wez Furlong a230e78ce6 add helper script for analyzing stack traces 2024-04-03 07:54:09 -07:00
Mike Hillyer c3cf0d4666 Update shaping based on Comcast documents, add stack trace information to the documentation. 2024-04-03 10:08:43 -04:00
Wez Furlong e94506fd96 Add new Rejection log event
We skip logging the 421 we generate while shutting down because
it feels a bit redundant; you'll see the server shutting down
in the journal anyway.

refs: https://github.com/KumoCorp/kumomta/issues/88
2024-03-29 16:37:37 -07:00
Wez Furlong 0c5794ba31 TSA: Add SuspendTenant, SuspendCampaign
refs: https://github.com/KumoCorp/kumomta/issues/113
2024-03-28 13:08:45 -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 be80391239 add kumo.http.connect_websocket
refs: https://github.com/KumoCorp/kumomta/issues/113
2024-03-28 07:14:35 -07:00
Wez Furlong f6f8c55ea4 listener_domains: fix fallback issue
This commit refactors listener_domains.lua to facilitate unit testing
and adds a couple of basic test cases.

The functional change here is that we were missing an explicit
fallback step in the case where no listener or domain matches
the provided values directly; we need to explicitly add a check
against the `*` listener AND `*` domain for the final step.
Previously, we would only look at the `*` listener for the final
step.

closes: #128
2024-03-22 09:48:18 -07:00
Wez Furlong f83b838a37 queue helper: add routing_domain option
This commit allows:

```toml
[queue.'my.own.hostname']
routing_domain = '[10.0.0.1]'
```

The effect of this is that, if the recipient domain matches a `queue`
block with a `routing_domain`, the value of that entry will be assigned
as the `routing_domain` meta field of the message.

The intent is for this to be used when DNS routes mail to the current
instance, but for when it is desirable to relay the mail onto some
location that is not visible in DNS.

refs: https://github.com/KumoCorp/kumomta/issues/141
2024-03-21 14:24:14 -07:00