From d6bd607aeeb2b6d085ab3c0b72ea25d40bb3d33a Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Fri, 3 Apr 2020 11:09:27 -0400 Subject: [PATCH] bugfix: PAI header on incoming call was being put in From header of outbound call --- lib/call-session.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/call-session.js b/lib/call-session.js index 8cfeab9..fc1d229 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -2,8 +2,20 @@ const Emitter = require('events'); const {makeRtpEngineOpts} = require('./utils'); const {forwardInDialogRequests} = require('drachtio-fn-b2b-sugar'); const {SipError} = require('drachtio-srf'); +const {parseUri} = require('drachtio-srf'); const debug = require('debug')('jambonz:sbc-outbound'); +/** + * this is to make sure the outgoing From has the number in the incoming From + * and not the incoming PAI + */ +const createBLegFromHeader = (req) => { + const from = req.getParsedHeader('From'); + const uri = parseUri(from.uri); + if (uri && uri.user) return `sip:${uri.user}@localhost`; + return 'sip:anonymous@localhost'; +}; + class CallSession extends Emitter { constructor(logger, req, res) { super(); @@ -86,6 +98,9 @@ class CallSession extends Emitter { passFailure: false, proxyRequestHeaders: ['all'], proxyResponseHeaders: ['all'], + headers: { + 'From': createBLegFromHeader(this.req) + }, localSdpB: response.sdp, localSdpA: async(sdp, res) => { this.toTag = res.getParsedHeader('To').params.tag;