From 4b080dd8454516f6d330effe8a78a112e3fa3b10 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 23 Jul 2026 20:14:03 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20PSTN=5FCALLER=20extraction=20=E2=80=94=20?= =?UTF-8?q?CHANNEL(peername)=20isn't=20valid=20on=20this=20Asterisk=20buil?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confirmed live: "Unknown or unavailable item requested: 'peername'" left PSTN_CALLER empty, which made AST_CONFIG() error ("requires a category") and PSTN_TIER come back empty too — every call fell through to "no PSTN permission" and got busy-signaled regardless of the extension's actual tier. Replaced with CUT(CHANNEL,/,2) then CUT(...,-,1), extracting the endpoint name from the channel name itself (e.g. "PJSIP/201-00000006" -> "201") — a plain string operation with no dependency on which channel function items this particular Asterisk build supports. --- services/pstn-trunk.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/services/pstn-trunk.sh b/services/pstn-trunk.sh index 9f604a5..208e010 100644 --- a/services/pstn-trunk.sh +++ b/services/pstn-trunk.sh @@ -276,12 +276,13 @@ _pstn_write_dialplan_include() { ; reachable" rule, not something even a "full" tier extension can override, ; since "full" means "any US number," not "any NANP-shaped number." -exten => _1NXXNXXXXXX,1,NoOp(PSTN outbound call attempt from ${CHANNEL(peername)} to ${EXTEN}) +exten => _1NXXNXXXXXX,1,NoOp(PSTN outbound call attempt from ${CHANNEL} to ${EXTEN}) same => n,Set(PSTN_KILLED=${AST_CONFIG(pstn-trunk-killswitch.conf,state,tripped)}) same => n,GotoIf($["${PSTN_KILLED}" = "1"]?pstn_killed,1) same => n,Set(PSTN_AREA_CODE=${EXTEN:1:3}) same => n,GotoIf($[${REGEX("^(242|246|264|268|284|340|345|441|473|649|658|664|670|671|684|721|758|767|784|787|809|829|849|868|869|876|939)$" ${PSTN_AREA_CODE})} = 1]?pstn_intl_blocked,1) - same => n,Set(PSTN_CALLER=${CHANNEL(peername)}) + same => n,Set(PSTN_CALLER=${CUT(CHANNEL,/,2)}) + same => n,Set(PSTN_CALLER=${CUT(PSTN_CALLER,-,1)}) same => n,Set(PSTN_TIER=${AST_CONFIG(pstn-permissions.conf,${PSTN_CALLER},tier)}) same => n,GotoIf($["${PSTN_TIER}" = "full"]?pstn_check_busy,1) same => n,GotoIf($["${PSTN_TIER}" = "restricted"]?pstn_check_allow_out,1) @@ -318,10 +319,11 @@ __ALERT_KILLED_LINE__ ; admin-entered rate (pstn-intl-allowed.conf's allowed_rates), not the flat ; domestic RATE — still an estimate (rates you entered, not fetched live), ; but no longer blended across two very different rate scales. -exten => _011X.,1,NoOp(PSTN international outbound call attempt from ${CHANNEL(peername)} to ${EXTEN}) +exten => _011X.,1,NoOp(PSTN international outbound call attempt from ${CHANNEL} to ${EXTEN}) same => n,Set(PSTN_KILLED=${AST_CONFIG(pstn-trunk-killswitch.conf,state,tripped)}) same => n,GotoIf($["${PSTN_KILLED}" = "1"]?pstn_killed,1) - same => n,Set(PSTN_CALLER=${CHANNEL(peername)}) + same => n,Set(PSTN_CALLER=${CUT(CHANNEL,/,2)}) + same => n,Set(PSTN_CALLER=${CUT(PSTN_CALLER,-,1)}) same => n,Set(PSTN_TIER=${AST_CONFIG(pstn-permissions.conf,${PSTN_CALLER},tier)}) same => n,GotoIf($["${PSTN_TIER}" = "full"]?pstn_intl_check_country,1) same => n,NoOp(Denied intl - ${PSTN_CALLER} tier ${PSTN_TIER} not eligible for international calling)