Commit Graph
148 Commits
Author SHA1 Message Date
Wez Furlong 1e2765a1f8 fix packaging
I kinda lobbed things over the wall in df08d6bd15.

You can't strip a shell script.
And we need to explicitly add files to the list in the rpm spec file
2023-12-04 11:16:08 -07:00
Wez Furlong df08d6bd15 install accounting.sh to sbin 2023-11-30 10:41:04 -07:00
02504a06d5 queue helper: allow skipping get_queue_config hook (#101)
Adds expanded constructor method that allows bypassing the hook.
Exposes the config resolver method on the returned queue helper object.

Co-authored-by: ncai <ncai@chapsvision.com>
Co-authored-by: Wez Furlong <wez@wezfurlong.org>
2023-11-30 10:34:32 -07:00
Wez Furlong b5252a4175 ci: woodpecker uses a different env to indicate tagging 2023-11-28 11:55:29 -07:00
Wez Furlong fa51666051 add log_hooks:new_json shortcut
Basic usage is as simple as:

```lua
local log_hooks = require 'policy-extras.log_hooks'

log_hooks:new_json {
  name = "webhook",
  url = "http://10.0.0.1:4242/log",
}
```
2023-11-14 15:06:48 -07:00
Wez Furlong 4ac3b4e21b log_hooks: set retry_interval to 1m, with max 20m 2023-11-14 14:55:22 -07:00
ncai 9d0105e51d use logRecord reception_protocol to avoid loop 2023-11-07 13:11:59 -07:00
Wez Furlong 48d5e26a70 pre_init: fix dispatch
I didn't register this correct for multi-event setup,
so no pre_init event was ever triggered, causing the log_hooks
stuff to not register the log hook.
2023-11-06 20:55:37 -07:00
Wez Furlong d969f87571 multi hooks: use bare return rather than return nil
The way we test whether logs should continue is by looking for
an empty return statement, so we shouldn't `return nil` for these
otherwise we'll indicate that we definitively can't resolve the
queue configuration.
2023-11-06 14:39:37 -07:00
Wez Furlong 0ffbcf7ed0 queue.lua: fix typo 2023-11-06 11:03:06 -07:00
Wez Furlong 68b7979783 queue.lua: allow removing tenant and/or campaign header 2023-11-06 10:59:49 -07:00
Wez Furlong ac7ef32cd3 log_hooks: fix returning the module 2023-11-06 09:50:25 -07:00
Wez Furlong 1c25c0a59b shaping.lua: add extra_files to the TSA inline example 2023-11-06 08:53:34 -07:00
Wez Furlong 951cad53e8 log_hooks: simplify logic and comments a little 2023-11-06 08:46:35 -07:00
Wez Furlong dd93465870 log_hooks: a couple of minor fixes/tweaks 2023-11-06 08:39:31 -07:00
Wez Furlong af92443f7e policy-extras: add log_hooks helper
This should simplify the process of adding log hooks.
2023-11-06 08:31:52 -07:00
Wez Furlong e9838cd1a9 new: queue helper
This helps to configure tenant and campaign assignment and scheduled
queue configuration.

refs: https://github.com/KumoCorp/kumomta/issues/90
2023-11-03 13:44:13 -07:00
Wez Furlong 1872dc71a0 shaping: calling shaper.should_enqueue_log_record is no longer required
Allow multiple should_enqueue_log_record hooks to be registered,
and take advantage of that inside the shaping helper.

`shaper.should_enqueue_log_record` no longer needs to be explicitly
plumbed from the config, but we allow calling it still for compatibility
reasons.

We will remove that compatibility after the next stable release.
2023-11-03 08:52:40 -07:00
Wez Furlong 3d7007825a shaping: calling shaper.get_queue_config is no longer required
Take advantage of the ability to define multiple get_queue_config
callbacks by internalizing the TSA webhook queue configuration.

`shaper.get_queue_config` no longer needs to be called, and
that fragment of code will continue to "work" by simply not
having an effect so that we don't break folks on upgrade.

We'll remove this compatibility in the release following
the next stable release.
2023-11-02 18:11:17 -07:00
Wez Furlong 30731e480c unbreak integration tests
These were broken by 898e08aece
2023-10-26 17:02:30 -07:00
Mike Hillyer 898e08aece Update shaping.toml with feedback provided by mail.com 2023-10-26 08:35:42 -04:00
Wez Furlong 8efd4d5127 docs: clarify install-from-source docs
Avoid referencing implementation details that we may change
(install.sh).

Document what goes where with a bit of explanation.

Remove examples that show launching `kumod &` as we do not recommend
running the service in the background without some kind of supervision
(such as systemd).  Instead, show how how to run the process and leave
it to the reader to decide how they with to deploy it in their
environment.

closes: https://github.com/KumoCorp/kumomta/issues/72
2023-10-24 11:22:00 -07:00
Wez Furlong 39a046e07c docs: add missing routing_domain param to get_queue_config event examples 2023-10-18 06:56:01 -07:00
Wez Furlong 32f8060ecc docs: logging: flush after 10s, clarify in quickstart and tutorial
New users trip over the very conservative defaults on log flushing,
so let's make the `init.lua` that we populate for new installs
set the duration to 10 seconds by default, and adjust the language
in the docs to match that.

Clarify the logging documentation about how the logs are
chunked/flushed.
2023-10-12 21:27:39 -04:00
Wez Furlong 4c36489681 First pass at accounting db
This keeps track of the volume of receptions and deliveries over time.
2023-10-12 20:43:58 -04:00
drone f8674c3d63 Add woodpecker CI pipeline 2023-09-30 15:57:48 -07:00
drone 71bc9b0098 ci: fixup auto fix for doc builds 2023-09-19 10:29:15 -07:00
Wez Furlong 620470f5aa ci: add local checker
use the drone cli to check that the starlark is well-formed,
and to try to run a build.

Useful for sanity checking a pending CI commit.

Slim down the deps very slight on ubuntu systems.
2023-09-19 09:54:54 -07:00
Wez Furlong c6425b701f ci: add auto-format fixup 2023-09-18 10:24:47 -07:00
Wez Furlong 054127c076 ci: do my own gh-pages push
The drone plugin does stuff very strangely and is incompatible
with our approach.

Do it ourselves (with blackjack and ...), so that we can avoid
cloning and bloating the repo.
2023-09-18 07:50:21 -07:00
Wez Furlong 5f616bfb15 ci: retire these scripts
These were for working around constraints in GH actions and since
we aren't using it anymore for the main portion of our CI/CD,
we don't need them anymore.
2023-09-17 19:10:28 -07:00
Wez Furlong 5ae79dabe1 CI: maybe add aarch64 ubuntu 2023-09-16 16:00:48 -07:00
Wez Furlong d9a4a3823d ci: set source file mtime to match git
Should improve cache viability
2023-09-16 09:08:56 -07:00
Nathalie Cai 1aca4ae3a8 add dkim canonicalization to dkim helper 2023-09-08 06:51:04 -07:00
Nathalie CaiandNathalie Cai 6bb9ac387c add mx_list_ip_map to smtp protocole for tls connection (#80)
add mx_list_ip_map to smtp protocole for tls connection

Co-authored-by: Nathalie Cai <ncai@chapsvision.com>
2023-08-30 08:29:18 -07:00
Wez Furlong c99ff1665e Revert "CI: try using the system rocksdb"
This reverts commit 17bdf49a67.

it didn't work out, and I'm a big cagey about using different
versions of rocksdb on differen distros anyway.
2023-08-25 10:26:52 -07:00
Wez Furlong 17bdf49a67 CI: try using the system rocksdb
Hope is to slim down build times and disk space usage in the CI jobs
2023-08-25 09:40:15 -07:00
Wez Furlong bbe1cab88a CI: try to prune space while we're running 2023-08-18 10:16:46 -07:00
Wez Furlong a73912e7e1 rollup.lua: remove stray debug print 2023-08-12 07:24:29 -07:00
Wez Furlong 7aa80bc34a rollup.lua: add ip-based rollup
How it works:

* When the lowest preference MX host names match a pattern like
  `.mail.protection.outlook.com`, the message has its routing_domain
  set to a placeholder domain whose name ends with `.ip_rollup`.
* That results in a scheduled queue name like
  `foo.com!outlook.ip_rollup`, which makes it possible to know both the
  original domain and the fact that rollup is in use.
* `get_queue_config` can check to see if the routing_domain is set to
  something that ends with `.ip_rollup` to override the `mx_list`
  in the queue configuration with just the lowest preference IP
  addresses from the original domain.
* Now, instead of computing a site_name base around
  `foo-com.mail.protection.outlook.com`, which includes the individual
  original recipient domain, and would cause there to be a separate
  ready queue for each domain, the overridden mx_list causes
  the site_name to be eg: `mx_list:[104.47.24.36],[104.47.25.36]`.
  That same site_name will be used for every domain that shares those
  same IP addresses
* When `get_egress_path_config` is called to get shaping parameters,
  it is passed the routing domain `outlook.ip_rollup`. You can use that
  name with mx_rollup=false as the key in your shaping.toml, of if you
  are directly implementing `get_egress_path_config`, you can use that
  name to determine the appropriate configuration.

```lua
kumo.on('get_queue_config', function(domain, tenant, campaign, routing_domain)
  local params = {}
  rollup.apply_ip_rollup_to_queue_config(domain, routing_domain, params
  return kumo.make_queue_config(params)
end)

kumo.on('smtp_server_message_received', function(msg)
  rollup.reroute_using_ip_rollup(msg, {
    ['.mail.protection.outlook.com.'] = 'outlook.ip_rollup',
  })
end)
```

In your shaping.toml:

```toml
["outlook.ip_rollup"]
mx_rollup = false
 # shaping parameters here
```

Caveats:

* With this technique, we'll never try to use any of the lower
  priority/higher preference value MX records for any of the matching
  domains.
* The IP addresses to which the MX host names resolve can vary over time.
  We'll still queue the mail to the same scheduled queue (eg:
  `foo.com!outlook.ip_rollup`), but it's possible for there to be
  multiple ready queues with different names based on those changed
  IPs.  This is actually a feature: if the destination domain has
  an outage and are now publishing different IPs, we'll pick those up
  and use them.
* Since the ready queue names look like `mx_list:[104.47.24.36],[104.47.25.36]`
  it can be hard to intuit just from glancing at that name where those queues go.
2023-08-12 06:52:39 -07:00
Wez Furlong a08b780ab3 listener_domains.lua: add relay_from_authz option
This allows listing out authorization identities.
If the incoming client is authorized to act as one of the listed
`relay_from_authz` authorization identities, then the incoming
session will be added to the relay_from CIDR for the scope of
that connected session, and the result is that they will be allowed
to relay from the associated domain.

This is useful if you want to give a tenant SMTP auth credentials
but only want to allow them to send from the domain(s) that
they are permitted to send as/from.
2023-08-11 08:31:15 -07:00
Wez Furlong 67b71a8b83 policy-extras: add rollup.lua
This is a prototype of a means for dealing with rolling up microsoft's
domains so that shaping can be applied holistically over both eg:
hotmail.com and outlook.com.

Those domains don't work with our default automatic MX based rollup
because they don't return the same MX hostnames.

Checking this in to make it easier for others to test/evaluate.
In the future, we may find a way to integrate this with our main
shaping helpers.
2023-08-10 11:48:07 -07:00
Wez Furlong c5409a7145 tsa: add systemd service that starts by default 2023-08-03 11:53:34 -07:00
Wez Furlong c8a040dfc4 tsa: teach shaping.lua to pull from the tsa-daemon
Refine the egress path update logic as part of that, so that we wake
sleeping Dispatchers to have them notice when it changes.
2023-08-03 11:36:02 -07:00
Wez Furlong a327e3db0c ready_queue: periodically refresh path_config
To facilitate more dynamically updating the configuration, this commit:

* Introduces a ConfigHandle type to aid in building shared configuration
  objects that don't require full mutex interlock
* Switches ReadyQueue and Dispatcher to hold egress path config in a ConfigHandle
* ReadyQueue maintainer will now refresh, by calling
  get_egress_path_config, the value in the config handle
* shaping.lua now uses a ttl of 1 minute (which is the same as the
  ReadyQueue maintainer interval), so that the ready queues should
  reflect egress path configuration changes approximately every minute.
2023-08-03 08:20:40 -07:00
Wez Furlong 22b5f43f84 shaping.lua: fix typo 2023-08-02 09:10:01 -07:00
Wez Furlong 16ea223ae8 tsa: basic rule matching
This is plumbing to perform rule matching.
It doesn't do anything useful with matches yet.
2023-08-01 13:58:50 -07:00
Wez Furlong 0565daf790 tsa: load shaping data on startup 2023-08-01 10:12:43 -07:00
Wez Furlong b8721831c2 packaging: add new binaries to rpm 2023-08-01 08:13:14 -07:00
Wez Furlong 907d724f01 listener_domains: cache compiled domain_maps
Make use of our new ability to memoize the compiled domain map
so that we can avoid rebuilding it on each lua hook invocation.

This should improve performance for sites with large numbers of
listener domains.
2023-07-31 16:57:16 -07:00