mirror of
https://github.com/mailscope/kumomta.git
synced 2026-08-22 04:18:21 +00:00
00f3131f7d
Closes: https://github.com/KumoCorp/kumomta/pull/525 Co-authored-by: Wez Furlong <wez@wezfurlong.org>
74 lines
1.9 KiB
Lua
74 lines
1.9 KiB
Lua
local kumo = require 'kumo'
|
|
package.path = '../../assets/?.lua;' .. package.path
|
|
local shaping = require 'policy-extras.shaping'
|
|
local utils = require 'policy-extras.policy_utils'
|
|
|
|
local TEST_DIR = os.getenv 'KUMOD_TEST_DIR'
|
|
local SINK_PORT = tonumber(os.getenv 'KUMOD_SMTP_SINK_PORT')
|
|
local TSA_URL =
|
|
string.format('http://127.0.0.1:%s', os.getenv 'KUMOD_TSA_PORT')
|
|
|
|
local shaper = shaping:setup_with_automation {
|
|
publish = { TSA_URL },
|
|
subscribe = { TSA_URL },
|
|
cache_ttl = '1 second',
|
|
no_default_files = true,
|
|
extra_files = { 'shaping.toml' },
|
|
pre_filter = true,
|
|
back_pressure = 128000,
|
|
-- Augment the default uninteresting set with Delivery, so that
|
|
-- successful delivery records do not reach TSA for matching.
|
|
additional_skip_log_record_types = { 'Delivery' },
|
|
}
|
|
|
|
kumo.on('init', function()
|
|
kumo.configure_accounting_db_path(TEST_DIR .. '/accounting.db')
|
|
|
|
kumo.start_esmtp_listener {
|
|
listen = '127.0.0.1:0',
|
|
relay_hosts = { '0.0.0.0/0' },
|
|
}
|
|
|
|
kumo.start_http_listener {
|
|
listen = '127.0.0.1:0',
|
|
}
|
|
|
|
kumo.configure_local_logs {
|
|
log_dir = TEST_DIR .. '/logs',
|
|
max_segment_duration = '1s',
|
|
max_file_size = 1,
|
|
}
|
|
|
|
kumo.define_spool {
|
|
name = 'data',
|
|
path = TEST_DIR .. '/data-spool',
|
|
}
|
|
|
|
kumo.define_spool {
|
|
name = 'meta',
|
|
path = TEST_DIR .. '/meta-spool',
|
|
}
|
|
shaper.setup_publish()
|
|
end)
|
|
|
|
kumo.on('get_listener_domain', function(domain, listener, conn_meta)
|
|
return kumo.make_listener_domain {
|
|
relay_to = true,
|
|
log_oob = true,
|
|
log_arf = true,
|
|
}
|
|
end)
|
|
|
|
kumo.on('smtp_server_message_received', function(msg)
|
|
msg:set_meta('routing_domain', 'localhost')
|
|
end)
|
|
|
|
kumo.on('get_egress_path_config', function(domain, egress_source, site_name)
|
|
local skip_make = true
|
|
local params =
|
|
shaper.get_egress_path_config(domain, egress_source, site_name, skip_make)
|
|
params.smtp_port = SINK_PORT
|
|
params.prohibited_hosts = {}
|
|
return kumo.make_egress_path(params)
|
|
end)
|