feat: make all operational constants configurable via bouncer.toml

Replace hardcoded values across network, captcha, email, and cert
modules with BouncerConfig fields. All values have safe defaults
and are overridable in the [bouncer] section of the config file.

Configurable: probation_seconds, backoff_steps, nick_timeout,
rejoin_delay, http_timeout, captcha_poll_interval/timeout,
email_poll_interval/max_polls/request_timeout, cert_validity_days.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-21 16:33:08 +01:00
parent ed576b002d
commit d13d090e8e
14 changed files with 506 additions and 97 deletions

View File

@@ -123,3 +123,58 @@ tls = true
"""
cfg = load(_write_config(config))
assert cfg.networks["test"].port == 6697
def test_operational_defaults(self):
"""Ensure all operational values have sane defaults."""
cfg = load(_write_config(MINIMAL_CONFIG))
b = cfg.bouncer
assert b.probation_seconds == 45
assert b.backoff_steps == [5, 10, 30, 60, 120, 300]
assert b.nick_timeout == 10
assert b.rejoin_delay == 3
assert b.http_timeout == 15
assert b.captcha_api_key == ""
assert b.captcha_poll_interval == 3
assert b.captcha_poll_timeout == 120
assert b.email_poll_interval == 15
assert b.email_max_polls == 30
assert b.email_request_timeout == 20
assert b.cert_validity_days == 3650
def test_operational_overrides(self):
"""Configurable operational values are parsed from TOML."""
config = """\
[bouncer]
password = "x"
probation_seconds = 60
backoff_steps = [10, 30, 90]
nick_timeout = 20
rejoin_delay = 5
http_timeout = 30
captcha_api_key = "test-key"
captcha_poll_interval = 5
captcha_poll_timeout = 60
email_poll_interval = 10
email_max_polls = 20
email_request_timeout = 25
cert_validity_days = 365
[proxy]
[networks.test]
host = "irc.example.com"
"""
cfg = load(_write_config(config))
b = cfg.bouncer
assert b.probation_seconds == 60
assert b.backoff_steps == [10, 30, 90]
assert b.nick_timeout == 20
assert b.rejoin_delay == 5
assert b.http_timeout == 30
assert b.captcha_api_key == "test-key"
assert b.captcha_poll_interval == 5
assert b.captcha_poll_timeout == 60
assert b.email_poll_interval == 10
assert b.email_max_polls == 20
assert b.email_request_timeout == 25
assert b.cert_validity_days == 365