Compare commits

...
4 Commits
Author SHA1 Message Date
Dave Horton ae8a906538 on REFER from fs, remove incoming Contact header before sending onward 2024-10-03 10:35:59 -04:00
Dave Horton 66c5d120fa wip 2024-09-25 15:26:55 -04:00
Dave Horton cef0be86c9 detect wss transport 2024-09-25 15:24:34 -04:00
Dave Horton b9d789c1bf fix for #163 2024-09-19 10:36:42 -04:00
2 changed files with 23 additions and 8 deletions
+16 -7
View File
@@ -7,7 +7,8 @@ const {
nudgeCallCounts,
roundTripTime,
parseConnectionIp,
isPrivateVoipNetwork
isPrivateVoipNetwork,
isWSS,
} = require('./utils');
const {forwardInDialogRequests} = require('drachtio-fn-b2b-sugar');
@@ -68,6 +69,10 @@ class CallSession extends Emitter {
this.service_provider_sid = req.locals.service_provider_sid;
this.srsClients = [];
this.recordingNoAnswerTimeout = (process.env.JAMBONES_RECORDING_NO_ANSWER_TIMEOUT || 2) * 1000;
this.isUsingPrivateNetwork = isPrivateVoipNetwork(this.req.source_address);
this.protocol = isWSS(req) ? 'wss' : req.protocol;
}
get isFromMSTeams() {
@@ -187,7 +192,7 @@ class CallSession extends Emitter {
...this.rtpEngineOpts.common,
...this.rtpEngineOpts.uac.mediaOpts,
'from-tag': this.rtpEngineOpts.uas.tag,
direction: [isPrivateVoipNetwork(this.req.source_address) ? 'private' : 'public', 'private'],
direction: [this.isUsingPrivateNetwork ? 'private' : 'public', 'private'],
sdp
};
const startAt = process.hrtime();
@@ -224,8 +229,8 @@ 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}>`;
if (this.isUsingPrivateNetwork) {
this.contactHeader = `<${scheme}:${this.privateSipAddress};transport=${this.protocol}>`;
responseHeaders = {
...responseHeaders,
'Contact': this.contactHeader
@@ -242,8 +247,8 @@ class CallSession extends Emitter {
};
}
else {
const hostport = this.srf.locals.sbcPublicIpAddress[this.req.protocol];
this.contactHeader = `<${scheme}:${hostport};transport=${this.req.protocol}>`;
const hostport = this.srf.locals.sbcPublicIpAddress[this.protocol];
this.contactHeader = `<${scheme}:${hostport};transport=${this.protocol}>`;
responseHeaders = {
...responseHeaders,
'Contact': this.contactHeader
@@ -994,15 +999,19 @@ Duration=${payload.duration} `
// eslint-disable-next-line no-unused-vars
'content-length':contentlength, 'refer-to':_referto, 'referred-by':_referredby,
// eslint-disable-next-line no-unused-vars
'X-Refer-To-Leave-Untouched': _leave,
'X-Refer-To-Leave-Untouched': _leave, 'contact':_contact,
...customHeaders
} = req.headers;
if (this.isUsingPrivateNetwork && this.privateSipAddress) {
u.host = this.privateSipAddress;
}
const response = await this.uas.request({
method: 'REFER',
headers: {
'Refer-To': `<${stringifyUri(uri)}>`,
'Referred-By': `<${stringifyUri(u)}>`,
...(this.contactHeader && {'Contact': this.contactHeader}),
...customHeaders
}
});
+7 -1
View File
@@ -9,6 +9,11 @@ const isWSS = (req) => {
return req.getParsedHeader('Via')[0].protocol.toLowerCase().startsWith('ws');
};
const localSipPort = (req) => {
const arr = /:(\d+)$/.exec(req.receivedOn);
return arr ? arr[1] : '5060';
};
const getAppserver = (srf) => {
const len = srf.locals.featureServers.length;
return srf.locals.featureServers[idx++ % len];
@@ -262,6 +267,7 @@ module.exports = {
parseConnectionIp,
isMSTeamsCIDR,
isPrivateVoipNetwork,
parseHostPorts
parseHostPorts,
localSipPort
};