From 6b0e37812349168dcc7849a89758961ebf005c62 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 21 Jul 2026 23:37:27 +0000 Subject: [PATCH] Rework PSTN trunk: role-based permissions, ring-groups, ntfy spend alerts Renames services/voipms-trunk.sh to services/pstn-trunk.sh and generalizes it away from VoIP.ms specifics - any IP-authenticated SIP provider works, VoIP.ms is just the suggested default. Adds: - Role-based outbound permission: a configurable allow-list of extensions that may dial PSTN numbers (regex-gated on CHANNEL(peername)), separate from internal extension-to-extension dialing which stays open to everyone regardless. Blank list preserves the original "everyone can dial out" behavior. - Inbound ring-group: rings a configurable list of extensions instead of a single hardcoded one. - ntfy alerts: immediate on denied (unauthorized extension) or rejected (concurrency cap hit) calls, plus an hourly cron-driven check that alerts once per month when estimated spend crosses a threshold and every hour call volume looks like a burst. Uses a self-contained pipe-delimited call log rather than Asterisk's CDR, to avoid depending on CDR module availability and CSV comma-quoting. - Settings persisted to .pstn-trunk.env so "update in place" reapplies everything from that file instead of fragile re-parsing out of generated Asterisk config (which had a real bug: update mode was extracting the wrong Dial(PJSIP/...) line). Tested end-to-end against a sandboxed copy of the real vendor files: permission-gate regex, ring-group dial-string construction, ntfy line injection/removal, and the usage-alert script's threshold/burst/monthly- dedup logic all verified with synthetic data. Caught and fixed a sed `&` escaping bug in the ring-group substitution before it shipped (RING_DIAL contains literal `&` join characters, which sed's replacement syntax otherwise treats as "insert the match"). --- services/{voipms-trunk.sh => pstn-trunk.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename services/{voipms-trunk.sh => pstn-trunk.sh} (100%) diff --git a/services/voipms-trunk.sh b/services/pstn-trunk.sh similarity index 100% rename from services/voipms-trunk.sh rename to services/pstn-trunk.sh