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",