mirror of
https://github.com/jambonz/sbc-outbound.git
synced 2026-01-25 02:07:59 +00:00
INVITE from gw should have register_from_domain if it's available
This commit is contained in:
@@ -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
|
* this is to make sure the outgoing From has the number in the incoming From
|
||||||
* and not the incoming PAI
|
* and not the incoming PAI
|
||||||
*/
|
*/
|
||||||
const createBLegFromHeader = (req, teams) => {
|
const createBLegFromHeader = (req, teams, register_from_domain = null) => {
|
||||||
const from = req.getParsedHeader('From');
|
const from = req.getParsedHeader('From');
|
||||||
const uri = parseUri(from.uri);
|
const uri = parseUri(from.uri);
|
||||||
let user = uri.user || 'anonymous';
|
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')) {
|
else if (req.has('X-Preferred-From-User') || req.has('X-Preferred-From-Host')) {
|
||||||
user = req.get('X-Preferred-From-User') || user;
|
user = req.get('X-Preferred-From-User') || user;
|
||||||
host = req.get('X-Preferred-From-Host') || host;
|
host = req.get('X-Preferred-From-Host') || host;
|
||||||
|
} else if (register_from_domain) {
|
||||||
|
host = register_from_domain;
|
||||||
}
|
}
|
||||||
if (from.name) {
|
if (from.name) {
|
||||||
return `${from.name} <sip:${user}@${host}>`;
|
return `${from.name} <sip:${user}@${host}>`;
|
||||||
@@ -295,7 +297,8 @@ class CallSession extends Emitter {
|
|||||||
name: vc.name,
|
name: vc.name,
|
||||||
diversion: vc.diversion,
|
diversion: vc.diversion,
|
||||||
hostport,
|
hostport,
|
||||||
protocol: o.protocol
|
protocol: o.protocol,
|
||||||
|
register_from_domain: vc.register_from_domain
|
||||||
};
|
};
|
||||||
if (vc.register_username && vc.register_password) {
|
if (vc.register_username && vc.register_password) {
|
||||||
obj.auth = {
|
obj.auth = {
|
||||||
@@ -410,6 +413,12 @@ class CallSession extends Emitter {
|
|||||||
'Diversion': div
|
'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})`);
|
else this.logger.info(`sending INVITE to ${uri} via proxy ${proxy})`);
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user