From 14d3bc97ac56b1d7b2030f56ccbdb707f16cf7f7 Mon Sep 17 00:00:00 2001 From: John Coffey Date: Tue, 17 Nov 2026 20:35:33 -0700 Subject: [PATCH] Relays: how many port 25 connections at once inbuxa-server 27.1-rc.28 gave the relay a relay-wide cap on port 25 sessions, maxSmtpSessions (default 1000), settable only over JMAP until now. The relay settings form shows it under Taking mail in, sends it only when changed, and refuses 0 or anything but a whole number. A relay on a server before 27.1-rc.28 has no such setting, and the field stays hidden. Test: model.test.ts reads 1000, sends 250, refuses 0 and text, and leaves an older relay alone; failed before (no maxSmtpSessions in the form), passes now. --- src/features/relays/RelaysPage.tsx | 5 +++++ src/features/relays/model.test.ts | 17 +++++++++++++++++ src/features/relays/model.ts | 9 +++++++++ src/help/texts.ts | 2 ++ src/i18n/en.json | 3 ++- 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/features/relays/RelaysPage.tsx b/src/features/relays/RelaysPage.tsx index 28f9230..b5e283f 100644 --- a/src/features/relays/RelaysPage.tsx +++ b/src/features/relays/RelaysPage.tsx @@ -661,6 +661,11 @@ function SettingsDialog({ + {relay.settings.maxSmtpSessions !== undefined && ( + + {input('maxSmtpSessions', { inputMode: 'numeric' })} + + )} {input('dnsbl', { placeholder: 'zen.example.org' })} diff --git a/src/features/relays/model.test.ts b/src/features/relays/model.test.ts index 5fb99c2..963e6e0 100644 --- a/src/features/relays/model.test.ts +++ b/src/features/relays/model.test.ts @@ -294,6 +294,23 @@ describe('plain forms', () => { }); }); + it('reads and sends the relay-wide session cap, and leaves it alone on an older relay', () => { + const withCap = { ...SETTINGS, maxSmtpSessions: 1000 }; + const before = toForm(withCap); + expect(before.maxSmtpSessions).toBe('1000'); + expect(settingsPatch(before, before, withCap)).toEqual({ patch: {} }); + expect(settingsPatch(before, { ...before, maxSmtpSessions: ' 250 ' }, withCap)).toEqual({ + patch: { 'settings/maxSmtpSessions': 250 }, + }); + expect(settingsPatch(before, { ...before, maxSmtpSessions: '0' }, withCap)).toEqual({ invalid: 'maxSmtpSessions' }); + expect(settingsPatch(before, { ...before, maxSmtpSessions: 'lots' }, withCap)).toEqual({ invalid: 'maxSmtpSessions' }); + const old = toForm(SETTINGS); + expect(old.maxSmtpSessions).toBe(''); + expect(settingsPatch(old, { ...old, hostname: 'mx2.example.com' }, SETTINGS)).toEqual({ + patch: { 'settings/hostname': 'mx2.example.com' }, + }); + }); + it('names the field that doesn’t read', () => { const before = toForm(SETTINGS); expect(settingsPatch(before, { ...before, maxRecipients: 'many' }, SETTINGS)).toEqual({ diff --git a/src/features/relays/model.ts b/src/features/relays/model.ts index df19abc..d4c439d 100644 --- a/src/features/relays/model.ts +++ b/src/features/relays/model.ts @@ -58,6 +58,8 @@ export interface RelaySettings { outboundTls: 'opportunistic' | 'required'; /** Absent from servers before RL-33: who may dial the link; empty is anyone. */ linkAllowFrom?: string[]; + /** Absent from servers before 27.1-rc.28: port 25 sessions at once, relay-wide. */ + maxSmtpSessions?: number; } export interface Relay { @@ -317,6 +319,7 @@ export interface SettingsForm { connectionsPerMinute: string; messagesPerMinute: string; concurrentSessions: string; + maxSmtpSessions: string; dnsbl: string; liveVerdictTimeout: string; heldMaxAge: string; @@ -340,6 +343,7 @@ export function toForm(s: RelaySettings): SettingsForm { connectionsPerMinute: String(s.rateLimits.connectionsPerMinute), messagesPerMinute: String(s.rateLimits.messagesPerMinute), concurrentSessions: String(s.rateLimits.concurrentSessions), + maxSmtpSessions: s.maxSmtpSessions === undefined ? '' : String(s.maxSmtpSessions), dnsbl: s.dnsbl.join(', '), liveVerdictTimeout: formatDuration(s.liveVerdictTimeout), heldMaxAge: String(s.heldMaxAge), @@ -390,6 +394,11 @@ export function settingsPatch( concurrentSessions: read('concurrentSessions', whole(after.concurrentSessions)), }; } + if (changed('maxSmtpSessions')) { + const cap = read('maxSmtpSessions', whole(after.maxSmtpSessions)); + if (!cap) throw 'maxSmtpSessions'; + patch['settings/maxSmtpSessions'] = cap; + } if (changed('dnsbl')) patch['settings/dnsbl'] = parseList(after.dnsbl); if (changed('liveVerdictTimeout')) patch['settings/liveVerdictTimeout'] = read('liveVerdictTimeout', parseDuration(after.liveVerdictTimeout)); diff --git a/src/help/texts.ts b/src/help/texts.ts index 6d98fdd..b5d4cbb 100644 --- a/src/help/texts.ts +++ b/src/help/texts.ts @@ -70,6 +70,8 @@ export const FIELD_HELP: Record = { 'inbuxa:Relay.maxRecipients': 'How many recipients one message may have at the relay.', 'inbuxa:Relay.rateLimits': 'How fast one sending address may connect and send to the relay, so a flood stops at the edge.', + 'inbuxa:Relay.maxSmtpSessions': + 'How many servers may be connected to the relay on port 25 at once, from all addresses together. Past it, the next one is asked to try again later. 1000 unless you change it.', 'inbuxa:Relay.dnsbl': 'Blocklists the relay checks connecting servers against while this server is unreachable. Empty checks none.', 'inbuxa:Relay.liveVerdictTimeout': diff --git a/src/i18n/en.json b/src/i18n/en.json index 686da62..542f0db 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -2423,7 +2423,8 @@ "smtpCertificate": "Certificate chain (PEM)", "smtpPrivateKey": "Private key (PEM)", "linkAllowFrom": "Who may link", - "certificateId": "Use" + "certificateId": "Use", + "maxSmtpSessions": "Connections at once, all senders" }, "cancel": "Cancel", "addGo": "Add", -- 2.54.0