Commit Graph
10 Commits
Author SHA1 Message Date
Wez Furlong e4594e8550 sources.lua: fix defining empty egress pools
The example in the FAQ does this but it did not validate because the
associated structure was not defined, because there were no sources
in the pool!

Fix up the logic to allow creating an empty pool.

https://docs.kumomta.com/faq/how_do_i_create_an_always_suspended_queue/
2026-03-05 16:57:51 +00:00
Wez Furlong f1f5d27591 sources.lua: surface socks5_proxy_source_address issues better
This field only accepts IP addresses; it is an error to use
a DNS name with it.

The sources helper was swallowing the helpful part of the context
about the issue with that field.

This commit ensures that we do surface it.
2025-03-11 06:55:44 -07:00
Wez Furlong 0ab606cfee memoize: make epoch-based invalidation optional
It is not always desirable to invalidate with the epoch,
so allow opting in instead of always invalidating that way.
2025-02-06 11:06:25 -07:00
Wez Furlong 9ddc15c7a1 sources.lua: Add typing and test
refs: #211
2024-06-28 13:06:51 -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 1d5180a221 sources.lua: tolerate empty pool or source sections in a file
We can compose multiple files, so it is OK for there to not
be any sources or pools in any given file.
2023-06-16 08:46:35 -07:00
Wez Furlong 261f68078f sources.lua make_egress_poll typo -> make_egress_pool 2023-06-15 08:19:16 -07:00
Wez Furlong 420dade8fb sources.lua: fixup initialization of name
refs: https://github.com/KumoCorp/kumomta/issues/56
2023-06-14 19:56:16 -07:00
Wez Furlong 7db243025e add policy helper for sources and pools 2023-06-01 13:08:05 -07:00