Skip to content

Commit

Permalink
Fix/invite use realm to registered trunk (#144)
Browse files Browse the repository at this point in the history
* special header X-Preferred-From-Host was ignored

* when sending INVITE to registered trunk with a sip realm, use realm in the uri and send via proxy as defined in outbound gateway
  • Loading branch information
davehorton authored Aug 29, 2024
1 parent a7406dd commit 503aa73
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/call-session.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const createBLegFromHeader = ({
if (teams) {
host = req.get('X-MS-Teams-Tenant-FQDN');
}
else if (req.has('X-Preferred-From-User')) {
else if (req.has('X-Preferred-From-Host')) {
host = req.get('X-Preferred-From-Host');
} else if (register_from_domain) {
host = register_from_domain;
Expand Down Expand Up @@ -312,7 +312,7 @@ class CallSession extends Emitter {
const prependPlus = vc.e164_leading_plus && !this.req.calledNumber.startsWith('0') ? '+' : '';
const scheme = transport === 'tls' && !process.env.JAMBONES_USE_BEST_EFFORT_TLS && o.use_sips_scheme ?
'sips' : 'sip';
const u = `${scheme}:${prefix}${prependPlus}${calledNumber}@${hostport};transport=${transport}`;
let u = `${scheme}:${prefix}${prependPlus}${calledNumber}@${hostport};transport=${transport}`;
const obj = {
name: vc.name,
diversion: vc.diversion,
Expand All @@ -327,6 +327,11 @@ class CallSession extends Emitter {
password: vc.register_password
};
}
if (vc.requires_register && vc.register_sip_realm?.length > 0) {
proxy = u;
u = `${scheme}:${prefix}${prependPlus}${calledNumber}@${vc.register_sip_realm};transport=${transport}`;
this.logger.debug({uri: u}, `using outbound proxy for this registered trunk: ${proxy}`);
}
mapGateways.set(u, obj);
uris.push(u);
this.logger.debug({gateway: o}, `pushed uri ${u}`);
Expand Down

0 comments on commit 503aa73

Please sign in to comment.