Skip to content

Commit

Permalink
INVITE from gw should have register_from_domain if it's available
Browse files Browse the repository at this point in the history
  • Loading branch information
xquanluu committed Dec 13, 2023
1 parent eb0de5b commit 771aa9d
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/call-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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} <sip:${user}@${host}>`;
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 771aa9d

Please sign in to comment.