Commit Graph
15 Commits
Author SHA1 Message Date
Wez Furlong 0c70ab2c52 improve error message when converting lua -> rust types
refs: https://github.com/KumoCorp/kumomta/issues/56
2023-06-14 20:14:14 -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 ac4d645670 Basic plumbing for handling deliveries in lua
```lua
-- Constructs a connection object in lua
kumo.on('make.lua-sender', function(domain, tenant, campaign)
  print 'making lua sender'
  local sender = {}
  function sender:send(message)
    print('Sending a message!', message)

    -- To log a transient failure:
    -- kumo.reject(420, 'boo!')

    -- To log a permanent failure:
    -- kumo.reject(500, "perm fail")

    -- To log success, return a string with additional data
    -- to be logged
    return 'Super!'
  end
  return sender
end)

-- Make everything use the lua "connection":
kumo.on('get_queue_config', function(domain, tenant, campaign)
  return kumo.make_queue_config {
    protocol = {
      custom_lua = {
        constructor = 'make.lua-sender',
      }
    },
  }
end)
```
2023-05-04 13:51:37 -07:00
Wez Furlong 278bc81aa0 move shaping -> policy-extras/shaping, and deploy with package
The assets/policy-extras dir is now deployed to
`/opt/kumomta/share/policy-extras` and added to the require path,
so you can do:

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

to pull it into your policy.
2023-04-26 14:51:52 -07:00
Wez Furlong 4b9c2f5238 fix default policy and include path to match docs 2023-03-27 09:41:42 -07:00
Wez Furlong a0015424e4 add /opt/kumomta/policy to the default require path 2023-03-14 18:59:43 -07:00
Wez Furlong 8989586c9b refactor: move version info to its own crate
Several crates depend on the config crate, which means that
several things needed to be rebuilt after committing/amending/syncing.

Separating it out reduces that impact.
2023-03-11 06:27:31 -07:00
Wez Furlong 4b7cbf9299 build.rs: remove unused import 2023-03-08 17:42:33 -07:00
Wez Furlong 50a123a0e3 Add version info to kumod 2023-03-08 17:38:15 -07:00
Wez Furlong 55d3343ac5 config: implement pooling of lua contexts
and export some counters so that we can see into their usage
2023-03-08 16:53:04 -07:00
Wez Furlong eaaddbb6b6 add redis client 2023-03-05 09:57:03 -07:00
Wez Furlong 2cf3d2387c add sqlite data access
A bit of a big commit because I wanted sqlite queries to run
async and there isn't a sane way to tell in mlua whether a
given context is safe to yield for an await, which meant making
every case where we call into lua be fully async.

This adds a simple but powerful binding to sqlite that performs
its IO in a blocking tokio thread pool, and returns the results
back to lua.

There is no implicit caching of queries, and no implicit connection
pooling.
2023-03-04 18:07:31 -07:00
Wez Furlong 12f1637087 http: add https and some plumbing for auth
* Reuse the tls acceptor stuff from the smtp_server.
  We'll automatically generate self-signed certs when
  none are provided.
* Add trusted_hosts setting for the http server
* Add an auth middleware that will accept connections from
  trusted hosts as pre-authenticated. Other hosts must provide
  http authorization.
* Add lua hooks for the policy script to validate either http
  basic auth (user+pass), or bearer auth (token).

There's not currently an authentication storage subsystem, but
the lua hook allows for very basic stuff to be configured, and
could also be used to employ eg: looking things up from a database
once we add some lua utility functions for that purpose.

The `/metrics` endpoint will only respond to trusted IPs.

Other endpoints all require some kind of successful authentication.
2023-02-24 10:47:06 -07:00
Wez Furlong b25ff76118 add dkim signing
A fairly sprawling commit:

* Move config to its own crate to facilitate making things more modular
* Crates/modules can now provide a registration function that can be
  used to setup functions in the lua environment
* Message crate now has a dkim module with a signer type that can
  be loaded from lua; signers are cached (with ttl) and shareable
* Message now has a dkim_sign method that does the signing, as well
  as methods for appending and prepending headers that are necessary
  to support signing.
2023-02-21 21:18:49 -07:00