bugfix: PAI header on incoming call was being put in From header of outbound call

This commit is contained in:
Dave Horton
2020-04-03 11:09:27 -04:00
parent e4313fd5d3
commit d6bd607aee
+15
View File
@@ -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;