Compare commits

...
22 Commits
Author SHA1 Message Date
Dave Horton 6d593cbc7d add optional env var to specify udp localPort to bind to 2022-12-30 10:41:39 -05:00
Dave Horton 35b15c1f2c update deps 2022-12-29 09:58:44 -05:00
Dave Horton 7f1d1d61db update to drachtio-srf@4.5.21 with some perf fixes 2022-12-29 09:52:06 -05:00
Dave Horton 20c17fd723 update drachtio-srf 2022-12-28 11:10:15 -06:00
Dave Horton da6fa1da1b bump version 2022-12-24 12:07:10 -06:00
Dave Horton f74dff3b59 bugfix: when releasing media we were restarting ICE which we dont want to do 2022-12-19 21:28:43 -05:00
Dave Horton d9c4e01c36 add env JAMBONES_RECORD_ALL_CALLS to enable global call recording 2022-12-02 13:53:29 -05:00
Dave Horton 3d902c65a4 minor logging 2022-12-01 14:05:23 -05:00
Dave Horton d641504797 fix test 2022-11-29 13:05:51 -05:00
Dave Horton b871812a70 bugfix: was incorrectly making additional attempts after caller hung up or other failures on first attempt 2022-11-28 16:45:21 -05:00
Guilherme RauenandGuilherme Rauen e123a2ef88 update node image to the latest and most secure (#56)
Co-authored-by: Guilherme Rauen <g.rauen@cognigy.com>
2022-11-11 11:26:42 -05:00
Dave Horton 775e63518a include application_sid in cdr 2022-11-07 18:34:13 -05:00
Dave Horton 307cf9bd65 update deps 2022-11-02 13:38:02 -04:00
Dave Horton f48ca4821e update db-helpers 2022-11-01 21:22:55 -04:00
Dave Horton 43ed2bafe1 strip X-Preferred-From-User and X-Preferred-From-Host from outgoing call 2022-10-26 09:35:11 -04:00
Dave Horton 5ee041bdee feature: specify user or host part of From on outdial 2022-10-23 15:27:03 -04:00
Dave Horton 5bbe6a8752 update package-lock.json 2022-10-23 12:20:12 -04:00
Dave Horton 2e5d609bab update rtpengine-utils again 2022-10-23 11:27:34 -04:00
Dave Horton 8f598bf7b0 update to latest rtpengine-utils 2022-10-22 22:26:02 -04:00
Markus FrindtandMarkus Frindt c7d717b3ee [snyk] fix vulnerability (#55)
Co-authored-by: Markus Frindt <m.frindt@cognigy.com>
2022-10-20 21:36:07 -04:00
Dave Horton e9209b37ca include X-Account-Sid header when moving call between FS 2022-10-15 10:59:29 -04:00
Dave Horton 3b98dc6ec2 Bugfix/release media investigation (#54)
* added logging

* when releasing media, include asymettric flag on offer

* update package-lock.json

* remove media handover flag when releasing media
2022-10-14 12:46:14 -04:00
7 changed files with 3481 additions and 1211 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 node:18.8.0-alpine as base
FROM --platform=linux/amd64 node:18.12.1-alpine3.16 as base
RUN apk --update --no-cache add --virtual .builds-deps build-base python3
+1 -2
View File
@@ -102,7 +102,7 @@ const {initLocals, checkLimits, route} = require('./lib/middleware')(srf, logger
const ngProtocol = process.env.JAMBONES_NG_PROTOCOL || 'udp';
const ngPort = process.env.RTPENGINE_PORT || ('udp' === ngProtocol ? 22222 : 8080);
const {getRtpEngine, setRtpEngines} = require('@jambonz/rtpengine-utils')([], logger, {
emitter: stats,
//emitter: stats,
dtmfListenPort: process.env.DTMF_LISTEN_PORT || 22225,
protocol: ngProtocol
});
@@ -184,7 +184,6 @@ if ('test' !== process.env.NODE_ENV) {
}
const lookupRtpServiceEndpoints = (lookup, serviceName) => {
logger.debug(`dns lookup for ${serviceName}..`);
lookup(serviceName, {family: 4, all: true}, (err, addresses) => {
if (err) {
logger.error({err}, `Error looking up ${serviceName}`);
+34 -14
View File
@@ -13,10 +13,17 @@ const makeInviteInProgressKey = (callid) => `sbc-out-iip${callid}`;
*/
const createBLegFromHeader = (req, teams) => {
const from = req.getParsedHeader('From');
const host = teams ? req.get('X-MS-Teams-Tenant-FQDN') : 'localhost';
const uri = parseUri(from.uri);
if (uri && uri.user) return `sip:${uri.user}@${host}`;
return `sip:anonymous@${host}`;
let user = uri.user || 'anonymous';
let host = 'localhost';
if (teams) {
host = req.get('X-MS-Teams-Tenant-FQDN');
}
else if (req.has('X-Preferred-From-User') || req.has('X-Preferred-From-Host')) {
user = req.get('X-Preferred-From-User') || user;
host = req.get('X-Preferred-From-Host') || host;
}
return `sip:${user}@${host}`;
};
const createBLegToHeader = (req, teams) => {
const to = req.getParsedHeader('To');
@@ -33,11 +40,13 @@ const initCdr = (srf, req) => {
const to = arr ? arr[1] : req.calledNumber;
arr = regex.exec(req.callingNumber);
const from = arr ? arr[1] : req.callingNumber;
const applicationSid = req.get('X-Application-Sid');
return {
account_sid: req.get('X-Account-Sid'),
call_sid: req.get('X-Call-Sid'),
sip_callid: req.get('Call-ID'),
...(applicationSid && {application_sid: applicationSid}),
from,
to,
duration: 0,
@@ -315,13 +324,14 @@ class CallSession extends Emitter {
'-X-MS-Teams-FQDN',
'-X-MS-Teams-Tenant-FQDN',
'-X-Trace-ID',
'X-CID',
'-Allow',
'-Session-Expires',
'-X-Requested-Carrier-Sid',
'-X-Jambonz-Routing',
'-X-Jambonz-FS-UUID',
'Min-SE'
'-X-Preferred-From-User',
'X-Preferred-From-Host',
'-X-Jambonz-FS-UUID',
],
proxyResponseHeaders: [
'all',
@@ -421,6 +431,7 @@ class CallSession extends Emitter {
sip_status: status
}).catch((err) => this.logger.error({err}, 'Error writing cdr for call failure'));
}
return;
}
else {
this.logger.info(`got ${err.status}, cranking back to next destination`);
@@ -560,11 +571,17 @@ Duration=${payload.duration} `
async _onReinvite(dlg, req, res) {
try {
const reason = req.get('X-Reason');
const isReleasingMedia = reason && dlg.type === 'uas' && ['release-media', 'anchor-media'].includes(reason);
const fromTag = dlg.type === 'uas' ? this.rtpEngineOpts.uas.tag : this.rtpEngineOpts.uac.tag;
const toTag = dlg.type === 'uas' ? this.rtpEngineOpts.uac.tag : this.rtpEngineOpts.uas.tag;
const offerMedia = dlg.type === 'uas' ? this.rtpEngineOpts.uac.mediaOpts : this.rtpEngineOpts.uas.mediaOpts;
const answerMedia = dlg.type === 'uas' ? this.rtpEngineOpts.uas.mediaOpts : this.rtpEngineOpts.uac.mediaOpts;
const direction = dlg.type === 'uas' ? ['private', 'public'] : ['public', 'private'];
if (isReleasingMedia) {
if (!offerMedia.flags.includes('port latching')) offerMedia.flags.push('port latching');
if (!offerMedia.flags.includes('asymmetric')) offerMedia.flags.push('asymmetric');
offerMedia.flags = offerMedia.flags.filter((f) => f !== 'media handover');
}
let opts = {
...this.rtpEngineOpts.common,
...offerMedia,
@@ -573,21 +590,24 @@ Duration=${payload.duration} `
direction,
sdp: req.body,
};
if (reason && opts.flags && !opts.flags.includes('reset')) opts.flags.push('reset');
// DH: this was restarting ICE, which we don't want to do
//if (reason && opts.flags && !opts.flags.includes('reset')) opts.flags.push('reset');
let response = await this.offer(opts);
if ('ok' !== response.result) {
res.send(488);
throw new Error(`_onReinvite: rtpengine failed: offer: ${JSON.stringify(response)}`);
}
this.logger.debug({opts, response}, 'CallSession:_onReinvite: (offer)');
/* if this is a re-invite from the FS to change media anchoring, avoid sending the reinvite out */
let sdp;
if (reason && dlg.type === 'uas' && ['release-media', 'anchor-media'].includes(reason)) {
if (isReleasingMedia) {
this.logger.info(`got a reinvite from FS to ${reason}`);
sdp = dlg.other.remote.sdp;
answerMedia.flags = ['asymmetric', 'port latching'];
if (!answerMedia.flags.includes('port latching')) answerMedia.flags.push('port latching');
if (!answerMedia.flags.includes('asymmetric')) answerMedia.flags.push('asymmetric');
answerMedia.flags = answerMedia.flags.filter((f) => f !== 'media handover');
this._mediaReleased = 'release-media' === reason;
}
else {
@@ -606,7 +626,7 @@ Duration=${payload.duration} `
res.send(488);
throw new Error(`_onReinvite: rtpengine failed: ${JSON.stringify(response)}`);
}
this.logger.info({sdp: response.sdp}, 'CallSession:_onReinvite: sending back upstream');
this.logger.debug({opts, sdp: response.sdp}, 'CallSession:_onReinvite: (answer) sending back upstream');
res.send(200, {body: response.sdp});
} catch (err) {
this.logger.error(err, 'Error handling reinvite');
@@ -795,10 +815,10 @@ Duration=${payload.duration} `
res.send(202);
// invite to new fs
const headers = {};
if (req.has('X-Retain-Call-Sid')) {
Object.assign(headers, {'X-Retain-Call-Sid': req.get('X-Retain-Call-Sid')});
}
const headers = {
...(req.has('X-Retain-Call-Sid') && {'X-Retain-Call-Sid': req.get('X-Retain-Call-Sid')}),
...(req.has('X-Account-Sid') && {'X-Account-Sid': req.get('X-Account-Sid')})
};
const dlg = await this.srf.createUAC(referTo.uri, {localSdp: dlg.local.sdp, headers});
this.uas = dlg;
this.uas.other = this.uac;
+2 -1
View File
@@ -17,7 +17,8 @@ function makeRtpEngineOpts(req, srcIsUsingSrtp, dstIsUsingSrtp, teams = false) {
}
const common = {
'call-id': req.get('Call-ID'),
'replace': ['origin', 'session-connection']
'replace': ['origin', 'session-connection'],
'record call': process.env.JAMBONES_RECORD_ALL_CALLS ? 'yes' : 'no'
};
return {
common,
+3436 -1186
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "sbc-outbound",
"version": "v0.7.6",
"version": "v0.7.8",
"main": "app.js",
"engines": {
"node": ">= 12.0.0"
@@ -27,18 +27,18 @@
"jslint": "eslint app.js lib"
},
"dependencies": {
"@jambonz/db-helpers": "^0.6.19",
"@jambonz/db-helpers": "^0.7.3",
"@jambonz/realtimedb-helpers": "^0.5.7",
"@jambonz/http-health-check": "^0.0.1",
"@jambonz/mw-registrar": "0.2.2",
"@jambonz/realtimedb-helpers": "^0.4.29",
"@jambonz/rtpengine-utils": "^0.3.5",
"@jambonz/siprec-client-utils": "^0.1.4",
"@jambonz/rtpengine-utils": "^0.4.2",
"@jambonz/siprec-client-utils": "^0.2.0",
"@jambonz/stats-collector": "^0.1.6",
"@jambonz/time-series": "^0.2.5",
"cidr-matcher": "^2.1.1",
"debug": "^4.3.4",
"drachtio-fn-b2b-sugar": "^0.0.12",
"drachtio-srf": "^4.5.1",
"drachtio-srf": "^4.5.21",
"express": "^4.18.1",
"pino": "^7.11.0",
"sdp-transform": "^2.14.1"
+1 -1
View File
@@ -84,7 +84,7 @@ test('sbc-outbound tests', async(t) => {
const res = await queryCdrs({account_sid: 'ed649e33-e771-403a-8c99-1780eabbc803'});
//console.log(`cdrs: ${JSON.stringify(res)}`);
t.ok(res.total === 6, 'wrote 6 cdrs');
t.ok(res.total === 5, 'wrote 5 cdrs');
srf.disconnect();
} catch (err) {