mirror of
https://github.com/jambonz/sbc-outbound.git
synced 2026-10-04 02:04:19 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0911032146 | ||
|
|
121ae75b39 | ||
|
|
57bc073ea3 | ||
|
|
84bce56766 | ||
|
|
d053b94e71 | ||
|
|
a50ed56b36 | ||
|
|
8fdcc8cbc4 | ||
|
|
b882c0de2d |
@@ -34,6 +34,7 @@ build/Release
|
||||
node_modules
|
||||
|
||||
.DS_Store
|
||||
.vscode
|
||||
|
||||
examples/*
|
||||
CLAUDE.md
|
||||
+14
-7
@@ -110,6 +110,7 @@ class CallSession extends Emitter {
|
||||
this.decrKey = req.srf.locals.realtimeDbHelpers.decrKey;
|
||||
this.addKey = req.srf.locals.realtimeDbHelpers.addKey;
|
||||
this.retrieveKey = req.srf.locals.realtimeDbHelpers.retrieveKey;
|
||||
this.retrieveHash = req.srf.locals.realtimeDbHelpers.retrieveHash;
|
||||
|
||||
const {
|
||||
lookupOutboundCarrierForAccount,
|
||||
@@ -351,7 +352,8 @@ class CallSession extends Emitter {
|
||||
* like a rare use case -- encryption is usually an all or nothing requirement.
|
||||
*/
|
||||
this.logger.info({u}, `using SRTP for outbound call, pad crypto: ${o.pad_crypto ? 'yes' : 'no'}`);
|
||||
this.rtpEngineOpts = makeRtpEngineOpts(this.req, false, true, o.pad_crypto, true);
|
||||
// eslint-disable-next-line max-len
|
||||
this.rtpEngineOpts = makeRtpEngineOpts(this.req, false, true, o.pad_crypto, true, o.remove_ice, o.dtls_off);
|
||||
encryptedMedia = true;
|
||||
}
|
||||
});
|
||||
@@ -723,10 +725,13 @@ class CallSession extends Emitter {
|
||||
if (this.req.locals.cdr) {
|
||||
const now = Date.now();
|
||||
const day = new Date();
|
||||
const recordAllCalls = this.req.locals.record_all_calls;
|
||||
// eslint-disable-next-line max-len
|
||||
const {hasRecording = false} = await this.retrieveHash(`call:${this.account_sid}:${this.req.locals.cdr.call_sid}`) ?? {};
|
||||
const recordAllCalls = this.req.locals.record_all_calls || hasRecording;
|
||||
const record_format = this.req.locals.account.record_format || 'mp3';
|
||||
let recording_url = `/Accounts/${this.account_sid}/RecentCalls/${this.req.locals.cdr.call_sid}/record`;
|
||||
recording_url += `/${day.getFullYear()}/${(day.getMonth() + 1).toString().padStart(2, '0')}`;
|
||||
recording_url += `/${day.getDate().toString().padStart(2, '0')}/${recordAllCalls}`;
|
||||
recording_url += `/${day.getDate().toString().padStart(2, '0')}/${record_format}`;
|
||||
this.writeCdrs({...this.req.locals.cdr,
|
||||
terminated_at: now,
|
||||
termination_reason: dlg.type === 'uas' ? 'caller hungup' : 'called party hungup',
|
||||
@@ -1208,7 +1213,6 @@ Duration=${payload.duration} `
|
||||
...(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 uac = await this.srf.createUAC(referTo.uri, {localSdp: dlg.local.sdp, headers});
|
||||
this.uas = uac;
|
||||
uac.type = 'uas';
|
||||
@@ -1217,7 +1221,7 @@ Duration=${payload.duration} `
|
||||
uac.on('info', this._onInfo.bind(this, uac));
|
||||
uac.on('modify', this._onReinvite.bind(this, uac));
|
||||
uac.on('refer', this._onFeatureServerTransfer.bind(this, uac));
|
||||
uac.on('destroy', () => {
|
||||
uac.on('destroy', async() => {
|
||||
this.logger.info('call ended with normal termination');
|
||||
this.rtpEngineResource.destroy();
|
||||
this.activeCallIds.delete(this.req.get('Call-ID'));
|
||||
@@ -1226,10 +1230,13 @@ Duration=${payload.duration} `
|
||||
if (this.req.locals.cdr) {
|
||||
const now = Date.now();
|
||||
const day = new Date();
|
||||
const recordAllCalls = this.req.locals.record_all_calls;
|
||||
// eslint-disable-next-line max-len
|
||||
const {hasRecording = false} = await this.retrieveHash(`call:${this.account_sid}:${this.req.locals.cdr.call_sid}`) ?? {} ;
|
||||
const recordAllCalls = this.req.locals.record_all_calls || hasRecording;
|
||||
const record_format = this.req.locals.account.record_format || 'mp3';
|
||||
let recording_url = `/Accounts/${this.account_sid}/RecentCalls/${this.req.locals.cdr.call_sid}/record`;
|
||||
recording_url += `/${day.getFullYear()}/${(day.getMonth() + 1).toString().padStart(2, '0')}`;
|
||||
recording_url += `/${day.getDate().toString().padStart(2, '0')}/${recordAllCalls}`;
|
||||
recording_url += `/${day.getDate().toString().padStart(2, '0')}/${record_format}`;
|
||||
this.writeCdrs({...this.req.locals.cdr,
|
||||
terminated_at: now,
|
||||
termination_reason: 'caller hungup',
|
||||
|
||||
+10
-1
@@ -5,7 +5,8 @@ const CIDRMatcher = require('cidr-matcher');
|
||||
const dns = require('dns');
|
||||
const sdpTransform = require('sdp-transform');
|
||||
|
||||
function makeRtpEngineOpts(req, srcIsUsingSrtp, dstIsUsingSrtp, padCrypto, teams) {
|
||||
// eslint-disable-next-line max-len
|
||||
function makeRtpEngineOpts(req, srcIsUsingSrtp, dstIsUsingSrtp, padCrypto, teams, remove_ice = false, dtls_off = false) {
|
||||
const from = req.getParsedHeader('from');
|
||||
const rtpCopy = JSON.parse(JSON.stringify(rtpCharacteristics));
|
||||
const srtpCopy = JSON.parse(JSON.stringify(srtpCharacteristics));
|
||||
@@ -16,6 +17,14 @@ function makeRtpEngineOpts(req, srcIsUsingSrtp, dstIsUsingSrtp, padCrypto, teams
|
||||
}
|
||||
|
||||
const srtpOpts = teams ? srtpCopy['teams'] : srtpCopy['default'];
|
||||
|
||||
if (remove_ice) {
|
||||
srtpOpts.ICE = 'remove';
|
||||
}
|
||||
if (dtls_off) {
|
||||
srtpOpts.DTLS = 'off';
|
||||
}
|
||||
|
||||
const dstOpts = JSON.parse(JSON.stringify(dstIsUsingSrtp ? srtpOpts : rtpCopy));
|
||||
const srcOpts = JSON.parse(JSON.stringify(srcIsUsingSrtp ? srtpOpts : rtpCopy));
|
||||
|
||||
|
||||
Generated
+585
-499
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "sbc-outbound",
|
||||
"version": "0.9.5",
|
||||
"version": "0.9.6",
|
||||
"main": "app.js",
|
||||
"engines": {
|
||||
"node": ">= 18.0.0"
|
||||
"node": ">= 20.0.0"
|
||||
},
|
||||
"keywords": [
|
||||
"sip",
|
||||
@@ -39,7 +39,7 @@
|
||||
"cidr-matcher": "^2.1.1",
|
||||
"debug": "^4.4.3",
|
||||
"drachtio-fn-b2b-sugar": "^0.2.1",
|
||||
"drachtio-srf": "^5.0.12",
|
||||
"drachtio-srf": "^5.0.20",
|
||||
"express": "^4.21.2",
|
||||
"pino": "^10.1.0",
|
||||
"sdp-transform": "^2.15.0"
|
||||
@@ -48,7 +48,7 @@
|
||||
"bent": "^7.3.12",
|
||||
"eslint": "^9.17.0",
|
||||
"eslint-plugin-promise": "^7.2.1",
|
||||
"nyc": "^15.1.0",
|
||||
"tape": "^5.7.5"
|
||||
"nyc": "^17.1.0",
|
||||
"tape": "^5.9.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user