diff --git a/lib/call-session.js b/lib/call-session.js index e4f94da..46f3085 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -11,7 +11,7 @@ const makeInviteInProgressKey = (callid) => `sbc-out-iip${callid}`; * this is to make sure the outgoing From has the number in the incoming From * and not the incoming PAI */ -const createBLegFromHeader = (req, teams) => { +const createBLegFromHeader = (req, teams, register_from_domain = null) => { const from = req.getParsedHeader('From'); const uri = parseUri(from.uri); let user = uri.user || 'anonymous'; @@ -22,6 +22,8 @@ const createBLegFromHeader = (req, teams) => { else if (req.has('X-Preferred-From-User') || req.has('X-Preferred-From-Host')) { user = req.get('X-Preferred-From-User') || user; host = req.get('X-Preferred-From-Host') || host; + } else if (register_from_domain) { + host = register_from_domain; } if (from.name) { return `${from.name} `; @@ -295,7 +297,8 @@ class CallSession extends Emitter { name: vc.name, diversion: vc.diversion, hostport, - protocol: o.protocol + protocol: o.protocol, + register_from_domain: vc.register_from_domain }; if (vc.register_username && vc.register_password) { obj.auth = { @@ -410,6 +413,12 @@ class CallSession extends Emitter { 'Diversion': div }; } + if (gw.register_from_domain) { + hdrs = { + ...hdrs, + 'From': createBLegFromHeader(this.req, teams, gw.register_from_domain) + }; + } } else this.logger.info(`sending INVITE to ${uri} via proxy ${proxy})`); try {