Commit Graph

137 Commits

Author SHA1 Message Date
Wez Furlong 99fcfbc64e kumod: refresh queue_config periodically
This commit causes the scheduled queue maintainer to refresh
the queue config by calling the get_queue_config event approximately
every minute while the queue is alive.

In addition, we now thread the routing_domain through to get_queue_config
2023-08-12 06:22:54 -07:00
Wez Furlong d8a6bceef0 add kumo.digest lua module
Compute hashes
2023-08-11 21:44:40 -07:00
Wez Furlong e042e81de9 kumo.dns: add lookup_addr function
Resolves a hostname to its v4 and v6 addresses and returns them.

Fixes up a typo in the docs for lookup_mx that incorrectly
showed it as resolve_mx.
2023-08-11 16:51:54 -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 c9cd17d21f Automated doc formatting fix 2023-08-11 04:35:22 +00:00
Wez Furlong 675736aeb7 docs: add example of SMTP auth affecting relaying 2023-08-10 21:34:02 -07:00
Wez Furlong 7d450fdb41 add kumo.cidr module and kumo.cidr.make_map 2023-08-10 17:21:20 -07:00
Wez Furlong 3fd76dd45a introduce routing_domain concept
Augments our queue name format to be
`campaign:tenant@domain!routing_domain`.

The routing_domain is optional.  If the routing_domain is not set, its
effective value is that of the recipient domain.

You can `msg:set_meta('routing_domain', 'bar.com')` to set the
routing_domain for a message, so if the original recipient was
`user@foo.com`, that would cause the computed queue name for it to be
`foo.com!bar.com`.

The routing_domain is used when deciding on the ready_queue name
and destination MXs, so continuing our example, instead of resolving
`foo.com` MX records we'd resolve `bar.com` and deliver to that site.

The `get_egress_path_config` event `domain` parameter is redefined to be
the effective `routing_domain`.

The `get_queue_config` event `domain` parameter is the regular recipient
domain. The `routing_domain` is not currently made available to
`get_queue_config`. If/when we expose it, it will likely be via a
queue name object instead of adding an additional parameter. That would
be a breaking change.

The consequence of not exposing this parameter is that per-message
routing scenarios for the same domain (but different routing domains)
cannot vary the scheduled queue parmeters (eg: retry intervals). Even
though they would have separate scheduled queue instances, those
instances would have the same scheduled queue parameters.  If you need
to be able to do that, then explicitly setting the domain portion of the
queue name would be a way to do that: `msg:set_meta('queue',
'foo.com-via-bar.com!bar.com')`.  `get_queue_config` would then be
called with `domain='foo.com-via-bar.com'` and your policy could then
respond accordingly.
2023-08-10 08:43:20 -07:00
Wez Furlong bcd2946c53 make_queue_config: now supports protocol.smtp.mx_list for smart hosting
Previously, you would do either:
  `msg:set_meta('queue', 'smart.host.domain')`
or
  `msg:set_meta('queue', '[10.0.0.1]')`

to override the effective domain for a message and cause it to be routed
to somewhere other than the recipient domain.

That was OK for basic smart hosting, but limiting when you wanted to use
multiple candidate hosts.

This commit expands the queue config `protocol` field to support
specifying an explicit list of MX hosts that should be used instead.

The integration tests have been migrated away from the old style to this
new style.

While adding plumbing for this, I uncovered an inconsistency between the
queue name generated for the ready queue and the name used by suspension
handling. The inconsistency was introduced in
0842a0fc8b and related work.  This commit
resolves it.
2023-08-09 23:04:45 -07:00
Mike Hillyer dac5d9f6fa Initial draft of Traffic Shaping Automation documentation. 2023-08-08 14:44:51 -04:00
Wez Furlong 2890138d90 refine handling of suspend=true
and add docs
2023-08-04 11:05:08 -07:00
Wez Furlong b08c865bdb docs: include new tsa related info to the reference section 2023-08-04 11:05:08 -07:00
Cloud User c9a3a7a81c updates to using vault 2023-08-03 19:05:50 +00:00
Wez Furlong 87e0578a33 logging: add nodeid to the log record 2023-07-31 16:57:14 -07:00
M.L. Oelering effa1a6a16 Add doc for remove_all_named_headers 2023-07-06 14:29:59 -07:00
Wez Furlong 0c7978e341 breaking: configure_log_hook: add required name parameter
The name is passed through to should_enqueue_log_record as an additonal
parameter to make it possible to reason about whether a given record
should get queued for a specific log hook instance.

This is a breaking change, but it can be easily resolved by adding
the name parameter to the `configure_log_hook` call.
2023-07-03 08:45:58 -07:00
Wez Furlong 4298698377 docs: some updates for #41 2023-06-30 18:55:39 -07:00
Wez Furlong d3ba5ccd2c connection_limit: implement using leases
To support distributed connection limits, adjust the way that
connection limits are handled.

Previously, we'd do a simple in-memory comparison with the limit to
guide whether we had reached the limit.

In a distributed/clustered scenario we need a shared understanding
of the state of the connections, so we're moving to a lease-based
model.

Each connection is associated with a UUID.
Each egress path maintains a set of connections and their UUIDs.

When attempting to make a new connection, we can only proceed if the
number of connections associated with an egress path is below the limit.

When a connection is closed, its UUID is removed from the associated
set.

To handle crashes, kills and netsplits, the path -> uuid association is
also accompanied by an expiration time beyond which it can be assumed
that the lease is no longer valid.  We compute that time based on the
worst case timeout value for a single message send on the given pathway.
Each time a connection is ready to obtain a new message, it will try
to extend its lease by that same duration.

This commit introduces these concepts and models them using an in-memory
store for the single node case, and using redis for the cluster case.
When your policy enables `kumo.configure_redis_throttles`, that same
redis configuration is used to back to the connection limiting
functionality.

refs: https://github.com/KumoCorp/kumomta/issues/41
2023-06-30 15:39:09 -07:00
Tom Mairs e45c82a3ec update Inject content example 2023-06-30 05:48:24 +00:00
Tom Mairs 2b617a8c65 fix typo 2023-06-30 05:20:35 +00:00
Wez Furlong f65e985e64 docs: add since macro. document connection metadata object 2023-06-28 13:52:15 -07:00
Wez Furlong 5d39928acf add docs for new bounce APIs
and briefly show how to use `kcli` with them
2023-06-22 12:59:36 -07:00
Wez Furlong 6ef093fbc7 docs: explain more about max_ready tradeoffs 2023-06-20 14:33:40 -07:00
Wez Furlong 192c051227 docs: note the default value for max_ready 2023-06-20 14:23:17 -07:00
Wez Furlong 020626360b docs: document enable_tls = 'Disabled' 2023-06-20 08:23:36 -07:00
Wez Furlong d60c961479 increase lua pool limits, allow configuring it 2023-06-16 10:03:49 -07:00
Wez Furlong a2feac004f actually add ehlo_domain to make_egress_source
Enable that field and add it to the fallback used by the
smtp_dispatcher.  The ehlo_domain configured for the pathway
takes precedence, then we'll take the value from the source,
then fallback to the local hostname.

refs: https://github.com/KumoCorp/kumomta/issues/59
2023-06-16 08:43:54 -07:00
Wez Furlong 2992e42138 add received_from and received_via meta values
We don't set received_via for http because axum/hyper make it a
bit weird to access that information and it will require some
effort to figure out how to get that without breaking the
existing proxy-aware client IP determination.
2023-06-13 15:18:06 -07:00
Wez Furlong e8a049cc83 document listener parameter to get_listener_domain update helpers
Allow per-listener listener-domain configuration
2023-05-31 15:46:12 -07:00
Wez Furlong ce7dece927 move domains out of listener, replace with get_listener_domain event
This commit also includes a policy helper
`policy_extras.listener_domains` to make it convenient to define
listener domains in toml and/or json files.

To facilitate this, the DomainMap rust structure has been exposed
to lua code via the new `kumo.domain_map.new` function.
2023-05-31 12:29:44 -07:00
Wez Furlong b7c557c31a define_egress_(pool|source) -> make_egress_(pool|source)
Switch the configuration plumbing for pools and sources to be pull-based
rather than push based.

In other words, rather than defining them in the `init` event,
you now need to supply them to the new `get_egress_pool` and
`get_egress_source` events.

Data is cached by default for 1 minute. This allows for new sources
to come into being on-demand, and for data to age out and change
over time, without requiring that the server be restarted.

This commit updates the reference section, but there is some content
in the user guide that refers to the old style of configuration that
will need to be updated.

refs: https://github.com/KumoCorp/kumomta/issues/13
2023-05-30 14:08:07 -07:00
Wez Furlong 9b1d82275c add spool_message_enumerated event
closes: #42
2023-05-30 10:14:37 -07:00
Mike Hillyer 0eefbccd5d Typo fix. 2023-05-18 16:44:32 -04:00
Mike Hillyer 0d85aea133 Adding SMTP AUTH to the user guide. 2023-05-17 17:39:23 -04:00
Wez Furlong 9d3411431f Add outbound SMTP auth support
refs: https://github.com/KumoCorp/kumomta/issues/10
2023-05-15 17:38:17 -07:00
Wez Furlong db0c042cef Add amqp client
refs: https://github.com/KumoCorp/kumomta/issues/31
2023-05-15 17:24:15 -07:00
Mike Hillyer 3e3483b281 Automated doc formatting fix 2023-05-10 17:44:47 +00:00
Mike Hillyer 88390291b3 Adding Webhook section to the configuration chapter. 2023-05-10 13:42:38 -04:00
Wez Furlong 6fdee41600 Add HA Proxy support
I used a config like this for testing:

```
global
    log stdout  format raw  local0  debug

defaults
    timeout connect 10s
    timeout client 30s
    timeout server 30s
    log global

listen outboundsmtp
    log global
    bind 0:2526 accept-proxy
    mode tcp
    use-server v4 if { src 0.0.0.0/0 }
    use-server v6 if { src ::/0 }
    server v4 0.0.0.0 source 0.0.0.0 usesrc clientip
    server v6 ::: source ::: usesrc clientip
```

Launched via:

```console
$ sudo haproxy -f assets/haproxy.conf -V
```

with the source:

```lua
  kumo.define_egress_source {
    name = 'w00t',
    ha_proxy_server = '127.0.0.1:2526',
    ha_proxy_source_address = '192.168.1.92',
  }
```

refs: #19
2023-05-10 09:50:06 -07:00
Wez Furlong 14291df014 docs: fix missing note admonish 2023-05-09 11:06:01 -07:00
Wez Furlong 927721fc0c Add toml parsing/encoding functions to lua
refs: https://github.com/KumoCorp/kumomta/issues/43
2023-05-09 08:40:37 -07:00
Wez Furlong 757ddbcf22 Automated doc formatting fix 2023-05-09 15:28:01 +00:00
Wez Furlong 992cae1409 Allow loading a key source directly from lua
This makes it easier to compose secret management with a variety
of lua functions without having to build that directly into each
of them.

In particular: one can now use vaults or other secret stores that
we add in the future to manage credentials for HTTP clients.
2023-05-09 08:25:54 -07:00
Wez Furlong f0e0ffe828 add message:set_force_sync
refs: https://github.com/KumoCorp/kumomta/issues/6
2023-05-08 17:37:54 -07:00
Wez Furlong c738ce2985 Automated doc formatting fix 2023-05-08 22:07:27 +00:00
Wez Furlong 0211b03060 http: add helpers for constructing form data
refs: https://github.com/KumoCorp/kumomta/issues/36
2023-05-08 15:06:09 -07:00
Wez Furlong cceaccf06a docs: webhook/lua delivery reference
refs: https://github.com/KumoCorp/kumomta/issues/36
refs: https://github.com/KumoCorp/kumomta/issues/18
2023-05-08 13:51:06 -07:00
Wez Furlong 65c7a9e5a6 Add reception and delivery protocol to log record
closes: https://github.com/KumoCorp/kumomta/issues/38
2023-05-08 08:39:40 -07:00
Wez Furlong c61d6aaa04 docs for kumo.http 2023-05-05 15:08:48 -07:00
Wez Furlong dade11ef22 dns: make it easy to detect and react to domain literals in lua
Add an is_domain_literal field to the resolve of kumo.dns.lookup_mx
2023-05-05 10:57:40 -07:00