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" <sip:+number@ims.lte.wal.verizon.com>). Falls back
to the previous behavior when PAI is not available.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
oddsix
2026-06-30 13:36:03 -04:00
parent 521a89e5f3
commit ceddde1006
+14 -2
View File
@@ -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 (/<sips?:/.test(part)) {
referredBy = part.trim();
break;
}
}
}
if (!referredBy) {
referredBy = cs.req?.callingNumber || dlg.local.uri;
}
this.logger.info({referredBy}, 'setting referredby');
}
if (!referredByDisplayName) {