mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2025-12-19 04:37:43 +00:00
sip scheme in contact header of re-invite 200 OK should be same as initial 200 OK (#150)
This commit is contained in:
@@ -166,6 +166,8 @@ class CallSession extends Emitter {
|
||||
const obj = parseUri(this.req.uri);
|
||||
let proxy, host, uri;
|
||||
|
||||
const scheme = obj.scheme;
|
||||
|
||||
// replace host part of uri if its an ipv4 address, leave it otherwise
|
||||
if (/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(obj.host)) {
|
||||
debug(`replacing host: was ${obj.host} is ${featureServer}`);
|
||||
@@ -176,8 +178,8 @@ class CallSession extends Emitter {
|
||||
host = obj.host;
|
||||
proxy = `sip:${featureServer}`;
|
||||
}
|
||||
if (obj.user) uri = `${obj.scheme}:${obj.user}@${host}`;
|
||||
else uri = `${obj.scheme}:${host}`;
|
||||
if (obj.user) uri = `${scheme}:${obj.user}@${host}`;
|
||||
else uri = `${scheme}:${host}`;
|
||||
this.logger.info(`uri will be: ${uri}, proxy ${proxy}`);
|
||||
|
||||
try {
|
||||
@@ -223,25 +225,28 @@ class CallSession extends Emitter {
|
||||
// set Contact header based on scenario, and transport protocol
|
||||
let responseHeaders = {};
|
||||
if (isPrivateVoipNetwork(this.req.source_address)) {
|
||||
this.contactHeader = `<${scheme}:${this.privateSipAddress}>;transport=${this.req.protocol}`;
|
||||
responseHeaders = {
|
||||
...responseHeaders,
|
||||
'Contact':`<${obj.scheme}:${this.privateSipAddress}>;transport=${this.req.protocol}`
|
||||
'Contact': this.contactHeader
|
||||
};
|
||||
} else if (this.req.locals.msTeamsTenantFqdn) {
|
||||
Object.assign(headers, {'X-MS-Teams-Tenant-FQDN': this.req.locals.msTeamsTenantFqdn});
|
||||
|
||||
// for Microsoft Teams the Contact header must include the tenant FQDN
|
||||
this.contactHeader = `sip:${this.req.locals.msTeamsTenantFqdn}`;
|
||||
responseHeaders = {
|
||||
...responseHeaders,
|
||||
Allow: 'INVITE, ACK, OPTIONS, CANCEL, BYE, NOTIFY, UPDATE, PRACK',
|
||||
Contact: `sip:${this.req.locals.msTeamsTenantFqdn}`
|
||||
Contact: this.contactHeader
|
||||
};
|
||||
}
|
||||
else {
|
||||
const hostport = this.srf.locals.sbcPublicIpAddress[this.req.protocol];
|
||||
this.contactHeader = `<${scheme}:${hostport}>;transport=${this.req.protocol}`;
|
||||
responseHeaders = {
|
||||
...responseHeaders,
|
||||
'Contact':`<${obj.scheme}:${hostport}>;transport=${this.req.protocol}`
|
||||
'Contact': this.contactHeader
|
||||
};
|
||||
}
|
||||
if (this.req.locals.application_sid) {
|
||||
@@ -653,7 +658,12 @@ Duration=${payload.duration} `
|
||||
}
|
||||
else {
|
||||
this.logger.info('got a reINVITE with no SDP; just respond with our current offer');
|
||||
res.send(200, {body: dlg.local.sdp});
|
||||
res.send(200, {
|
||||
headers: {
|
||||
'Contact': this.contactHeader
|
||||
},
|
||||
body: dlg.local.sdp
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -706,7 +716,12 @@ Duration=${payload.duration} `
|
||||
res.send(488);
|
||||
throw new Error(`_onReinvite: rtpengine failed: ${JSON.stringify(response)}`);
|
||||
}
|
||||
res.send(200, {body: response.sdp});
|
||||
res.send(200, {
|
||||
headers: {
|
||||
'Contact': this.contactHeader
|
||||
},
|
||||
body: response.sdp
|
||||
});
|
||||
} catch (err) {
|
||||
res.send(err.status || 500);
|
||||
this.logger.error(err, 'Error handling reinvite');
|
||||
|
||||
Reference in New Issue
Block a user