From ceddde10069b9a745a27b24e80a69d4c7a8a780f Mon Sep 17 00:00:00 2001 From: oddsix Date: Tue, 30 Jun 2026 13:36:03 -0400 Subject: [PATCH] fix: use PAI sip: identity for auto-computed Referred-By header When referredBy is not explicitly provided, the code was using callingNumber (user part only) combined with the SBC's internal IP from dlg.remote.uri. This produced a Referred-By with an IP address (e.g. sip:+number@10.x.x.x) that carriers like Verizon reject. Instead, extract the full sip: name-addr from the P-Asserted-Identity header, which preserves both the display name and the original FQDN (e.g. "Cha Van" ). Falls back to the previous behavior when PAI is not available. Co-Authored-By: Claude Opus 4.6 --- lib/tasks/sip_refer.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/tasks/sip_refer.js b/lib/tasks/sip_refer.js index bac8e4c4..d9ca6fb4 100644 --- a/lib/tasks/sip_refer.js +++ b/lib/tasks/sip_refer.js @@ -122,8 +122,20 @@ class TaskSipRefer extends Task { } else this.referToIsUri = true; if (!referredBy) { - /* default */ - referredBy = cs.req?.callingNumber || dlg.local.uri; + /* default: extract the sip: identity from PAI, preserving the original domain */ + const paiHeader = cs.req?.has('p-asserted-identity') ? cs.req.get('p-asserted-identity') : null; + if (paiHeader) { + const parts = paiHeader.split(/,\s*(?=")/); + for (const part of parts) { + if (/