mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-10-04 02:04:22 +00:00
Compare commits
4
Commits
v0.9.3-rc5
...
fix/163
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae8a906538 | ||
|
|
66c5d120fa | ||
|
|
cef0be86c9 | ||
|
|
b9d789c1bf |
+16
-7
@@ -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
@@ -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
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user