security-dashboard: add Calls & Texts tab for PSTN calls and SIP/SMS texts

Surfaces pstn-trunk.sh's existing pstn-trunk-calls.log (already recording
every PSTN call's numbers, just never shown on the dashboard) plus two new
metadata-only logs: sip-messages.log for internal SIP MESSAGE
deliveries/denials (asterisk.sh) and pstn-sms.log for SMS-over-SIP arrivals
(pstn-trunk.sh). No message bodies are ever logged. The dashboard reads all
three via a new /api/pstn-calls and /api/comms-texts pair, sharing a common
bounded tail helper with the Security Log parser.
This commit is contained in:
Claude
2026-08-08 02:32:42 +00:00
parent 048ed4af8e
commit d4ca8277a6
3 changed files with 288 additions and 34 deletions
+9
View File
@@ -379,6 +379,12 @@ _pstn_write_sms_inbound_dialplan() {
; docker exec <container> asterisk -rx "core set verbose 5"
; (send the text)
; check the console/full log for the "SMS-over-SIP MESSAGE received" line
;
; pstn-sms.log (epoch|in|from|to) feeds the Security Dashboard's Texts table
; — from/to prefer the X-ANVEO-SMS-* headers (the documented mechanism) and
; fall back to MESSAGE(from)/MESSAGE(to) if a header is empty, same
; unconfirmed-until-a-real-text caveat as everything else in this context.
; No message body is ever written to this file.
[pstn-sms-inbound]
exten => _X.,1,NoOp(SMS-over-SIP MESSAGE received — dialplan EXTEN=${EXTEN})
same => n,Set(SMS_HDR_FROM=${PJSIP_HEADER(read,X-ANVEO-SMS-FROM)})
@@ -387,6 +393,9 @@ exten => _X.,1,NoOp(SMS-over-SIP MESSAGE received — dialplan EXTEN=${EXTEN})
same => n,Set(SMS_MSG_TO=${MESSAGE(to)})
same => n,Set(SMS_BODY=${MESSAGE(body)})
same => n,NoOp(DIAGNOSTIC (not yet routed) -- X-ANVEO-SMS-FROM=[${SMS_HDR_FROM}] X-ANVEO-SMS-TO=[${SMS_HDR_TO}] MESSAGE(from)=[${SMS_MSG_FROM}] MESSAGE(to)=[${SMS_MSG_TO}] EXTEN=[${EXTEN}] body=[${SMS_BODY}])
same => n,Set(SMS_FROM=${IF($["${SMS_HDR_FROM}"!=""]?${SMS_HDR_FROM}:${SMS_MSG_FROM})})
same => n,Set(SMS_TO=${IF($["${SMS_HDR_TO}"!=""]?${SMS_HDR_TO}:${SMS_MSG_TO})})
same => n,System(printf '%s|in|%s|%s\n' "${EPOCH}" "${SMS_FROM}" "${SMS_TO}" >> /var/log/asterisk/pstn-sms.log)
same => n,Hangup()
EOF
}