mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2025-12-19 04:37:43 +00:00
Feature/recent calls enhancement with sp (#47)
* write cdrs and alerts with service_provider_sid * update to latest @jambonz/http-authenticator which sends sip headers * add call_sid to cdr when call is connected * write call counts by SP as well as account, bugfix to allow digit '0' in dtmf-relay
This commit is contained in:
4
app.js
4
app.js
@@ -15,6 +15,7 @@ const opts = Object.assign({
|
||||
const logger = require('pino')(opts);
|
||||
const {
|
||||
writeCallCount,
|
||||
writeCallCountSP,
|
||||
queryCdrs,
|
||||
writeCdrs,
|
||||
writeAlerts,
|
||||
@@ -71,6 +72,7 @@ const {getRtpEngine, setRtpEngines} = require('@jambonz/rtpengine-utils')([], lo
|
||||
srf.locals = {...srf.locals,
|
||||
stats,
|
||||
writeCallCount,
|
||||
writeCallCountSP,
|
||||
queryCdrs,
|
||||
writeCdrs,
|
||||
writeAlerts,
|
||||
@@ -96,12 +98,14 @@ srf.locals = {...srf.locals,
|
||||
}
|
||||
};
|
||||
const {
|
||||
getSPForAccount,
|
||||
wasOriginatedFromCarrier,
|
||||
getApplicationForDidAndCarrier,
|
||||
getOutboundGatewayForRefer
|
||||
} = require('./lib/db-utils')(srf, logger);
|
||||
srf.locals = {
|
||||
...srf.locals,
|
||||
getSPForAccount,
|
||||
wasOriginatedFromCarrier,
|
||||
getApplicationForDidAndCarrier,
|
||||
getOutboundGatewayForRefer,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const Emitter = require('events');
|
||||
const SrsClient = require('@jambonz/siprec-client-utils');
|
||||
const {makeRtpEngineOpts, SdpWantsSrtp, makeCallCountKey} = require('./utils');
|
||||
const {makeRtpEngineOpts, SdpWantsSrtp, makeAccountCallCountKey, makeSPCallCountKey} = require('./utils');
|
||||
const {forwardInDialogRequests} = require('drachtio-fn-b2b-sugar');
|
||||
const {parseUri, stringifyUri, SipError} = require('drachtio-srf');
|
||||
const debug = require('debug')('jambonz:sbc-inbound');
|
||||
@@ -49,7 +49,8 @@ class CallSession extends Emitter {
|
||||
this.activeCallIds = this.srf.locals.activeCallIds;
|
||||
|
||||
this.decrKey = req.srf.locals.realtimeDbHelpers.decrKey;
|
||||
this.callCountKey = makeCallCountKey(req.locals.account_sid);
|
||||
this.callCountKey = makeAccountCallCountKey(req.locals.account_sid);
|
||||
this.callCountKeySP = makeSPCallCountKey(req.locals.service_provider_sid);
|
||||
this._mediaReleased = false;
|
||||
}
|
||||
|
||||
@@ -283,11 +284,13 @@ class CallSession extends Emitter {
|
||||
const tags = ['accepted:yes', 'sipStatus:200', `originator:${this.req.locals.originator}`];
|
||||
this.stats.increment('sbc.terminations', tags);
|
||||
this.activeCallIds.set(this.req.get('Call-ID'), this);
|
||||
const call_sid = uac.res?.get('X-Call-Sid');
|
||||
if (this.req.locals.cdr) {
|
||||
this.req.locals.cdr = {
|
||||
...this.req.locals.cdr,
|
||||
answered: true,
|
||||
answered_at: callStart,
|
||||
...(call_sid && {call_sid}),
|
||||
trace_id: uac.res?.get('X-Trace-ID') || '00000000000000000000000000000000'
|
||||
};
|
||||
}
|
||||
@@ -303,15 +306,25 @@ class CallSession extends Emitter {
|
||||
} catch (err) {}
|
||||
this.unsubscribeDTMF(this.logger, this.req.get('Call-ID'), this.rtpEngineOpts.uas.tag);
|
||||
if (process.env.JAMBONES_HOSTING || process.env.JAMBONES_TRACK_ACCOUNT_CALLS) {
|
||||
const {account_sid} = this.req.locals;
|
||||
this.decrKey(this.callCountKey)
|
||||
.then((count) => {
|
||||
this.logger.info(
|
||||
{key: this.callCountKey},
|
||||
`after hangup there are ${count} active calls for this account`);
|
||||
return this.req.srf.locals.writeCallCount({account_sid, calls_in_progress: count});
|
||||
const {account_sid, service_provider_sid} = this.req.locals;
|
||||
const {writeCallCount, writeCallCountSP} = this.req.srf.locals;
|
||||
|
||||
this.logger.info('going to decrement call count');
|
||||
|
||||
Promise.all([
|
||||
this.decrKey(this.callCountKey),
|
||||
this.decrKey(this.callCountKeySP)
|
||||
])
|
||||
.then(([calls, callsSP]) => {
|
||||
this.logger.info({calls, callsSP}, 'decremented call counts after call completion');
|
||||
return Promise.all([
|
||||
writeCallCount(account_sid, calls),
|
||||
writeCallCountSP(service_provider_sid, callsSP)
|
||||
]);
|
||||
})
|
||||
.catch((err) => this.logger.error({err}, 'Error decrementing call count'));
|
||||
.catch((err) => {
|
||||
this.logger.error({err}, 'error decrementing call counts after call completion');
|
||||
});
|
||||
}
|
||||
|
||||
/* write cdr for connected call */
|
||||
@@ -320,13 +333,23 @@ class CallSession extends Emitter {
|
||||
const trunk = ['trunk', 'teams'].includes(this.req.locals.originator) ?
|
||||
this.req.locals.carrier :
|
||||
this.req.locals.originator;
|
||||
const cdr = {...this.req.locals.cdr,
|
||||
terminated_at: now,
|
||||
termination_reason: dlg.type === 'uas' ? 'caller hungup' : 'called party hungup',
|
||||
sip_status: 200,
|
||||
duration: Math.floor((now - callStart) / 1000),
|
||||
trunk
|
||||
};
|
||||
this.logger.info({cdr}, 'going to write a cdr now..');
|
||||
this.writeCdrs({...this.req.locals.cdr,
|
||||
terminated_at: now,
|
||||
termination_reason: dlg.type === 'uas' ? 'caller hungup' : 'called party hungup',
|
||||
sip_status: 200,
|
||||
duration: Math.floor((now - callStart) / 1000),
|
||||
trunk
|
||||
}).catch((err) => this.logger.error({err}, 'Error writing cdr for completed call'));
|
||||
})
|
||||
.then(() => this.logger.debug('successfully wrote cdr'))
|
||||
.catch((err) => this.logger.error({err}, 'Error writing cdr for completed call'));
|
||||
}
|
||||
/* de-link the 2 Dialogs for GC */
|
||||
dlg.removeAllListeners();
|
||||
@@ -633,7 +656,7 @@ Duration=${payload.duration} `
|
||||
}
|
||||
}
|
||||
else if (dlg.type === 'uas' && ['application/dtmf-relay', 'application/dtmf'].includes(contentType)) {
|
||||
const arr = /Signal=\s*([1-9#*])/.exec(req.body);
|
||||
const arr = /Signal=\s*([0-9#*])/.exec(req.body);
|
||||
if (!arr) {
|
||||
this.logger.info({body: req.body}, '_onInfo: invalid INFO dtmf request');
|
||||
throw new Error(`_onInfo: no dtmf in body for ${contentType}`);
|
||||
|
||||
@@ -3,6 +3,8 @@ const CIDRMatcher = require('cidr-matcher');
|
||||
const {parseUri} = require('drachtio-srf');
|
||||
const {normalizeDID} = require('./utils');
|
||||
|
||||
const sqlSelectSPForAccount = 'SELECT service_provider_sid FROM accounts WHERE account_sid = ?';
|
||||
|
||||
const sqlSelectAllCarriersForAccountByRealm =
|
||||
`SELECT sg.sip_gateway_sid, sg.voip_carrier_sid, vc.name, vc.account_sid,
|
||||
vc.application_sid, sg.inbound, sg.outbound, sg.is_active, sg.ipv4, sg.netmask
|
||||
@@ -68,6 +70,12 @@ module.exports = (srf, logger) => {
|
||||
const {pool} = srf.locals.dbHelpers;
|
||||
const pp = pool.promise();
|
||||
|
||||
const getSPForAccount = async(account_sid) => {
|
||||
const [r] = await pp.query(sqlSelectSPForAccount, [account_sid]);
|
||||
if (0 === r.length) return null;
|
||||
return r[0].service_provider_sid;
|
||||
};
|
||||
|
||||
const getOutboundGatewayForRefer = async(voip_carrier_sid) => {
|
||||
try {
|
||||
const [r] = await pp.query(sqlSelectOutboundGatewayForCarrier, [voip_carrier_sid]);
|
||||
@@ -115,10 +123,12 @@ module.exports = (srf, logger) => {
|
||||
const [r] = await pp.query(sqlCarriersForAccountBySid,
|
||||
[process.env.SBC_ACCOUNT_SID, req.source_address, req.source_port]);
|
||||
if (0 === r.length) return failure;
|
||||
const service_provider_sid = await getSPForAccount(process.env.SBC_ACCOUNT_SID);
|
||||
return {
|
||||
fromCarrier: true,
|
||||
gateway: r[0],
|
||||
account_sid: process.env.SBC_ACCOUNT_SID
|
||||
account_sid: process.env.SBC_ACCOUNT_SID,
|
||||
service_provider_sid
|
||||
};
|
||||
}
|
||||
else {
|
||||
@@ -147,6 +157,7 @@ module.exports = (srf, logger) => {
|
||||
return {
|
||||
fromCarrier: true,
|
||||
gateway: matches[0],
|
||||
service_provider_sid: accounts[0].service_provider_sid,
|
||||
account_sid: accounts[0].account_sid,
|
||||
account: accounts[0]
|
||||
};
|
||||
@@ -158,6 +169,7 @@ module.exports = (srf, logger) => {
|
||||
return {
|
||||
fromCarrier: true,
|
||||
gateway,
|
||||
service_provider_sid: accounts[0].service_provider_sid,
|
||||
account_sid: r[0].account_sid,
|
||||
application_sid: r[0].application_sid,
|
||||
account: accounts[0]
|
||||
@@ -178,6 +190,7 @@ module.exports = (srf, logger) => {
|
||||
return {
|
||||
fromCarrier: true,
|
||||
gateway: selected,
|
||||
service_provider_sid: a[0].service_provider_sid,
|
||||
account_sid: a[0].account_sid,
|
||||
application_sid: selected.application_sid,
|
||||
account: a[0]
|
||||
@@ -189,6 +202,7 @@ module.exports = (srf, logger) => {
|
||||
return {
|
||||
wasOriginatedFromCarrier,
|
||||
getApplicationForDidAndCarrier,
|
||||
getOutboundGatewayForRefer
|
||||
getOutboundGatewayForRefer,
|
||||
getSPForAccount
|
||||
};
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ const debug = require('debug')('jambonz:sbc-inbound');
|
||||
const assert = require('assert');
|
||||
const Emitter = require('events');
|
||||
const parseUri = require('drachtio-srf').parseUri;
|
||||
const {makeCallCountKey} = require('./utils');
|
||||
const {makeAccountCallCountKey, makeSPCallCountKey} = require('./utils');
|
||||
const msProxyIps = process.env.MS_TEAMS_SIP_PROXY_IPS ?
|
||||
process.env.MS_TEAMS_SIP_PROXY_IPS.split(',').map((i) => i.trim()) :
|
||||
[];
|
||||
@@ -30,10 +30,10 @@ module.exports = function(srf, logger) {
|
||||
stats.histogram('app.hook.response_time', rtt, ['hook_type:auth', `status:${status}`]);
|
||||
})
|
||||
.on('error', async(err, req) => {
|
||||
const {account_sid} = req.locals;
|
||||
const {account_sid, account} = req.locals;
|
||||
const {writeAlerts, AlertType} = req.srf.locals;
|
||||
if (account_sid) {
|
||||
let opts = {account_sid};
|
||||
let opts = {account_sid, service_provider_sid: account.service_provider_sid};
|
||||
if (err.code === 'ECONNREFUSED') {
|
||||
opts = {...opts, alert_type: AlertType.WEBHOOK_CONNECTION_FAILURE, url: err.hook};
|
||||
}
|
||||
@@ -134,12 +134,13 @@ module.exports = function(srf, logger) {
|
||||
const identifyAccount = async(req, res, next) => {
|
||||
try {
|
||||
const {siprec, callId} = req.locals;
|
||||
const {wasOriginatedFromCarrier, getApplicationForDidAndCarrier} = req.srf.locals;
|
||||
const {getSPForAccount, wasOriginatedFromCarrier, getApplicationForDidAndCarrier} = req.srf.locals;
|
||||
const {
|
||||
fromCarrier,
|
||||
gateway,
|
||||
account_sid,
|
||||
application_sid,
|
||||
service_provider_sid,
|
||||
account
|
||||
} = await wasOriginatedFromCarrier(req);
|
||||
/**
|
||||
@@ -173,6 +174,7 @@ module.exports = function(srf, logger) {
|
||||
gateway,
|
||||
voip_carrier_sid: gateway.voip_carrier_sid,
|
||||
application_sid: sid || gateway.application_sid,
|
||||
service_provider_sid,
|
||||
account_sid,
|
||||
account,
|
||||
...req.locals
|
||||
@@ -188,12 +190,13 @@ module.exports = function(srf, logger) {
|
||||
res.send(404, {headers: {'X-Reason': 'no configured application'}});
|
||||
return req.srf.endSession(req);
|
||||
}
|
||||
|
||||
const service_provider_sid = await getSPForAccount(app.account_sid);
|
||||
req.locals = {
|
||||
originator: 'teams',
|
||||
carrier: 'Microsoft Teams',
|
||||
msTeamsTenantFqdn: uri.host,
|
||||
account_sid: app.account_sid,
|
||||
service_provider_sid,
|
||||
...req.locals
|
||||
};
|
||||
}
|
||||
@@ -219,18 +222,21 @@ module.exports = function(srf, logger) {
|
||||
return req.srf.endSession(req);
|
||||
}
|
||||
req.locals = {
|
||||
service_provider_sid: account.service_provider_sid,
|
||||
account_sid: account.account_sid,
|
||||
account,
|
||||
webhook_secret: account.webhook_secret,
|
||||
...req.locals
|
||||
};
|
||||
}
|
||||
assert(req.locals.service_provider_sid);
|
||||
assert(req.locals.account_sid);
|
||||
req.locals.cdr.account_sid = req.locals.account_sid;
|
||||
|
||||
if (!req.locals.account) {
|
||||
req.locals.account = await lookupAccountBySid(req.locals.account_sid);
|
||||
}
|
||||
req.locals.cdr.service_provider_sid = req.locals.account?.service_provider_sid;
|
||||
|
||||
if (!req.locals.account.is_active) {
|
||||
stats.increment('sbc.terminations', ['sipStatus:503']);
|
||||
@@ -242,7 +248,11 @@ module.exports = function(srf, logger) {
|
||||
delete req.locals.cdr;
|
||||
}
|
||||
|
||||
req.locals.logger = logger.child({callId: req.get('Call-ID'), account_sid: req.locals.account_sid});
|
||||
req.locals.logger = logger.child({
|
||||
callId: req.get('Call-ID'),
|
||||
service_provider_sid: req.locals.service_provider_sid,
|
||||
account_sid: req.locals.account_sid
|
||||
});
|
||||
|
||||
next();
|
||||
} catch (err) {
|
||||
@@ -256,32 +266,35 @@ module.exports = function(srf, logger) {
|
||||
if (!process.env.JAMBONES_HOSTING && !process.env.JAMBONES_TRACK_ACCOUNT_CALLS) return next(); // skip
|
||||
|
||||
const {incrKey, decrKey} = req.srf.locals.realtimeDbHelpers;
|
||||
const {logger, account_sid} = req.locals;
|
||||
const {writeCallCount, writeAlerts, AlertType} = req.srf.locals;
|
||||
const {logger, account_sid, account, service_provider_sid} = req.locals;
|
||||
const {writeCallCount, writeCallCountSP, writeAlerts, AlertType} = req.srf.locals;
|
||||
assert(account_sid);
|
||||
const key = makeCallCountKey(account_sid);
|
||||
assert(service_provider_sid);
|
||||
const keyAccount = makeAccountCallCountKey(account_sid);
|
||||
const keySP = makeSPCallCountKey(service_provider_sid);
|
||||
|
||||
/* decrement count if INVITE is later rejected */
|
||||
res.once('end', ({status}) => {
|
||||
res.once('end', async({status}) => {
|
||||
if (status > 200) {
|
||||
decrKey(key)
|
||||
.then((count) => {
|
||||
logger.info({key}, `after rejection there are ${count} active calls for this account`);
|
||||
debug({key}, `after rejection there are ${count} active calls for this account`);
|
||||
return count;
|
||||
})
|
||||
.then((count) => writeCallCount({account_sid, calls_in_progress: count}))
|
||||
.catch((err) => logger.error({err}, 'checkLimits: decrKey err'));
|
||||
try {
|
||||
const [calls, callsSP] = await Promise.all([decrKey(keyAccount), decrKey(keySP)]);
|
||||
logger.info({calls, callsSP}, `decremented call counts after ${status} response`);
|
||||
} catch (err) {
|
||||
logger.info({err}, 'Error decrementing call count');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
/* increment the call count */
|
||||
const calls = await incrKey(key);
|
||||
writeCallCount({account_sid, calls_in_progress: calls})
|
||||
.then(() => logger.info(`checkLimits: after incrementing there are ${calls} active calls for this account`))
|
||||
.catch((err) => logger.error({err}, 'checkLimits: error writing call count'));
|
||||
if (!process.env.JAMBONES_HOSTING) return next();
|
||||
const [calls, callsSP] = await Promise.all([incrKey(keyAccount), incrKey(keySP)]);
|
||||
logger.info({calls, callsSP}, 'incremented call counts');
|
||||
|
||||
/* write the call counts to the database for both account and service provider */
|
||||
Promise.all([
|
||||
writeCallCount(account_sid, calls),
|
||||
writeCallCountSP(service_provider_sid, callsSP)
|
||||
]).catch((err) => logger.error({err}, 'Error writing call counts'));
|
||||
|
||||
/* compare to account's limit, though avoid db hit when call count is low */
|
||||
const minLimit = process.env.MIN_CALL_LIMIT ?
|
||||
@@ -290,21 +303,26 @@ module.exports = function(srf, logger) {
|
||||
logger.debug(`checkLimits: call count is now ${calls}, limit is ${minLimit}`);
|
||||
if (calls <= minLimit) return next();
|
||||
|
||||
const capacities = await lookupAccountCapacitiesBySid(account_sid);
|
||||
const limit = capacities.find((c) => c.category == 'voice_call_session');
|
||||
if (!limit) throw new Error('no account_capacities found');
|
||||
const limit_sessions = limit.quantity;
|
||||
if (calls > limit_sessions) {
|
||||
debug(`checkLimits: limits exceeded: call count ${calls}, limit ${limit_sessions}`);
|
||||
logger.info({calls, limit_sessions}, 'checkLimits: limits exceeded');
|
||||
writeAlerts({
|
||||
alert_type: AlertType.CALL_LIMIT,
|
||||
account_sid,
|
||||
count: limit_sessions
|
||||
}).catch((err) => logger.info({err}, 'checkLimits: error writing alert'));
|
||||
res.send(503, 'Maximum Calls In Progress');
|
||||
return req.srf.endSession(req);
|
||||
const accountCapacities = await lookupAccountCapacitiesBySid(account_sid);
|
||||
const accountLimit = accountCapacities.find((c) => c.category == 'voice_call_session');
|
||||
if (accountLimit) {
|
||||
/* check account limit */
|
||||
const limit_sessions = accountLimit.quantity;
|
||||
if (calls > limit_sessions) {
|
||||
debug(`checkLimits: limits exceeded: call count ${calls}, limit ${limit_sessions}`);
|
||||
logger.info({calls, limit_sessions}, 'checkLimits: limits exceeded');
|
||||
writeAlerts({
|
||||
alert_type: AlertType.ACCOUNT_CALL_LIMIT,
|
||||
service_provider_sid: account.service_provider_sid,
|
||||
account_sid,
|
||||
count: limit_sessions
|
||||
}).catch((err) => logger.info({err}, 'checkLimits: error writing alert'));
|
||||
res.send(503, 'Maximum Calls In Progress');
|
||||
return req.srf.endSession(req);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: implement service provider limits
|
||||
next();
|
||||
} catch (err) {
|
||||
stats.increment('sbc.terminations', ['sipStatus:500']);
|
||||
|
||||
@@ -43,7 +43,8 @@ const SdpWantsSrtp = (sdp) => {
|
||||
return /m=audio.*SAVP/.test(sdp);
|
||||
};
|
||||
|
||||
const makeCallCountKey = (sid) => `${sid}:incalls`;
|
||||
const makeAccountCallCountKey = (sid) => `${sid}:incalls:account`;
|
||||
const makeSPCallCountKey = (sid) => `${sid}:incalls:sp`;
|
||||
|
||||
const normalizeDID = (tel) => {
|
||||
const regex = /^\+(\d+)$/;
|
||||
@@ -87,7 +88,8 @@ module.exports = {
|
||||
SdpWantsSrtp,
|
||||
getAppserver,
|
||||
makeRtpEngineOpts,
|
||||
makeCallCountKey,
|
||||
makeAccountCallCountKey,
|
||||
makeSPCallCountKey,
|
||||
normalizeDID,
|
||||
equalsIgnoreOrder,
|
||||
systemHealth,
|
||||
|
||||
112
package-lock.json
generated
112
package-lock.json
generated
@@ -10,13 +10,13 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jambonz/db-helpers": "^0.6.18",
|
||||
"@jambonz/http-authenticator": "^0.2.1",
|
||||
"@jambonz/http-authenticator": "^0.2.2",
|
||||
"@jambonz/http-health-check": "^0.0.1",
|
||||
"@jambonz/realtimedb-helpers": "^0.4.29",
|
||||
"@jambonz/rtpengine-utils": "^0.3.1",
|
||||
"@jambonz/siprec-client-utils": "^0.1.4",
|
||||
"@jambonz/stats-collector": "^0.1.6",
|
||||
"@jambonz/time-series": "^0.1.12",
|
||||
"@jambonz/time-series": "^0.2.1",
|
||||
"aws-sdk": "^2.1152.0",
|
||||
"bent": "^7.3.12",
|
||||
"cidr-matcher": "^2.1.1",
|
||||
@@ -27,7 +27,7 @@
|
||||
"pino": "^7.11.0",
|
||||
"sdp-transform": "^2.14.1",
|
||||
"uuid": "^8.3.2",
|
||||
"verify-aws-sns-signature": "^0.0.7",
|
||||
"verify-aws-sns-signature": "^0.1.0",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -584,9 +584,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@jambonz/http-authenticator": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/http-authenticator/-/http-authenticator-0.2.1.tgz",
|
||||
"integrity": "sha512-AwWyUTaw2gi364xytXMttYl8VyDkO3SESUK2DAH21Mo3yCQUnE9vdiTafeYljmrKMHwOJTb75p8UxUlXlT/Xrw==",
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/http-authenticator/-/http-authenticator-0.2.2.tgz",
|
||||
"integrity": "sha512-yl6CajF8c8BOTrXEB/AbTXgqrT6XeymwVZbJWeJG8HZA21UXkKCcM26b8f0P9qqokSvFj0ObjCk22Ks2ytSLNg==",
|
||||
"dependencies": {
|
||||
"bent": "^7.3.12",
|
||||
"debug": "^4.3.1",
|
||||
@@ -710,9 +710,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@jambonz/time-series": {
|
||||
"version": "0.1.12",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.1.12.tgz",
|
||||
"integrity": "sha512-TmCG4jcI8oK3NXOc4/PbdRhhMVLEr5FOyG4IIWpNlwB0vbjAGLY3K+O5PF4fXK+UcNYnIrUcrd2C0J9z3+YBxw==",
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.1.tgz",
|
||||
"integrity": "sha512-uAoeZ3ibS7kEOGdT+vaY8BB8hOV4q38eEaF+d5OvLQaHCrPonNiwB8tWhhXDwtYdDompfqVRUy/plNA9fyS7Vw==",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.1",
|
||||
"influx": "^5.9.3"
|
||||
@@ -3021,14 +3021,6 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-ssh": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz",
|
||||
"integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==",
|
||||
"dependencies": {
|
||||
"protocols": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/is-stream": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz",
|
||||
@@ -3709,17 +3701,6 @@
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/normalize-url": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz",
|
||||
"integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A==",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/nyc": {
|
||||
"version": "15.1.0",
|
||||
"resolved": "https://registry.npmjs.org/nyc/-/nyc-15.1.0.tgz",
|
||||
@@ -3930,22 +3911,19 @@
|
||||
}
|
||||
},
|
||||
"node_modules/parse-path": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-path/-/parse-path-5.0.0.tgz",
|
||||
"integrity": "sha512-qOpH55/+ZJ4jUu/oLO+ifUKjFPNZGfnPJtzvGzKN/4oLMil5m9OH4VpOj6++9/ytJcfks4kzH2hhi87GL/OU9A==",
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz",
|
||||
"integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==",
|
||||
"dependencies": {
|
||||
"protocols": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/parse-url": {
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/parse-url/-/parse-url-7.0.2.tgz",
|
||||
"integrity": "sha512-PqO4Z0eCiQ08Wj6QQmrmp5YTTxpYfONdOEamrtvK63AmzXpcavIVQubGHxOEwiIoDZFb8uDOoQFS0NCcjqIYQg==",
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz",
|
||||
"integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==",
|
||||
"dependencies": {
|
||||
"is-ssh": "^1.4.0",
|
||||
"normalize-url": "^6.1.0",
|
||||
"parse-path": "^5.0.0",
|
||||
"protocols": "^2.0.1"
|
||||
"parse-path": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/parseurl": {
|
||||
@@ -5105,12 +5083,12 @@
|
||||
}
|
||||
},
|
||||
"node_modules/verify-aws-sns-signature": {
|
||||
"version": "0.0.7",
|
||||
"resolved": "https://registry.npmjs.org/verify-aws-sns-signature/-/verify-aws-sns-signature-0.0.7.tgz",
|
||||
"integrity": "sha512-j/yePIQvLqRGshOwuEs9VT7jGh++1hBoOjjt+Rl4aAffJTu+22GwTPfAD9fLY9VqRrR4Cuiid3eNHOkmxE3TNg==",
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/verify-aws-sns-signature/-/verify-aws-sns-signature-0.1.0.tgz",
|
||||
"integrity": "sha512-giPj4dIrhounlQA+AAy0CZmqARrT2o4WjIcv1GKcnQiKBDmDpJyGIaHu/ESwOGVcZf68aLHFPrEzhudXSp4Krw==",
|
||||
"dependencies": {
|
||||
"bent": "^7.3.12",
|
||||
"parse-url": "^7.0.2"
|
||||
"parse-url": "^8.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/verror": {
|
||||
@@ -5785,9 +5763,9 @@
|
||||
}
|
||||
},
|
||||
"@jambonz/http-authenticator": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/http-authenticator/-/http-authenticator-0.2.1.tgz",
|
||||
"integrity": "sha512-AwWyUTaw2gi364xytXMttYl8VyDkO3SESUK2DAH21Mo3yCQUnE9vdiTafeYljmrKMHwOJTb75p8UxUlXlT/Xrw==",
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/http-authenticator/-/http-authenticator-0.2.2.tgz",
|
||||
"integrity": "sha512-yl6CajF8c8BOTrXEB/AbTXgqrT6XeymwVZbJWeJG8HZA21UXkKCcM26b8f0P9qqokSvFj0ObjCk22Ks2ytSLNg==",
|
||||
"requires": {
|
||||
"bent": "^7.3.12",
|
||||
"debug": "^4.3.1",
|
||||
@@ -5881,9 +5859,9 @@
|
||||
}
|
||||
},
|
||||
"@jambonz/time-series": {
|
||||
"version": "0.1.12",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.1.12.tgz",
|
||||
"integrity": "sha512-TmCG4jcI8oK3NXOc4/PbdRhhMVLEr5FOyG4IIWpNlwB0vbjAGLY3K+O5PF4fXK+UcNYnIrUcrd2C0J9z3+YBxw==",
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/time-series/-/time-series-0.2.1.tgz",
|
||||
"integrity": "sha512-uAoeZ3ibS7kEOGdT+vaY8BB8hOV4q38eEaF+d5OvLQaHCrPonNiwB8tWhhXDwtYdDompfqVRUy/plNA9fyS7Vw==",
|
||||
"requires": {
|
||||
"debug": "^4.3.1",
|
||||
"influx": "^5.9.3"
|
||||
@@ -7655,14 +7633,6 @@
|
||||
"call-bind": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"is-ssh": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz",
|
||||
"integrity": "sha512-x7+VxdxOdlV3CYpjvRLBv5Lo9OJerlYanjwFrPR9fuGPjCiNiCzFgAWpiLAohSbsnH4ZAys3SBh+hq5rJosxUQ==",
|
||||
"requires": {
|
||||
"protocols": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"is-stream": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz",
|
||||
@@ -8199,11 +8169,6 @@
|
||||
"resolved": "https://registry.npmjs.org/nonce/-/nonce-1.0.4.tgz",
|
||||
"integrity": "sha512-FVPu+tMZPP91HDwiq1DNhn9WIhg4/uo6mXR0xXAn0IMOxDmjJOkgbH0tm7qtowvAFZofWZRX+9KWZpNURrgtSA=="
|
||||
},
|
||||
"normalize-url": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-6.1.0.tgz",
|
||||
"integrity": "sha512-DlL+XwOy3NxAQ8xuC0okPgK46iuVNAK01YN7RueYBqqFeGsBjV9XmCAzAdgt+667bCl5kPh9EqKKDwnaPG1I7A=="
|
||||
},
|
||||
"nyc": {
|
||||
"version": "15.1.0",
|
||||
"resolved": "https://registry.npmjs.org/nyc/-/nyc-15.1.0.tgz",
|
||||
@@ -8363,22 +8328,19 @@
|
||||
}
|
||||
},
|
||||
"parse-path": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-path/-/parse-path-5.0.0.tgz",
|
||||
"integrity": "sha512-qOpH55/+ZJ4jUu/oLO+ifUKjFPNZGfnPJtzvGzKN/4oLMil5m9OH4VpOj6++9/ytJcfks4kzH2hhi87GL/OU9A==",
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-path/-/parse-path-7.0.0.tgz",
|
||||
"integrity": "sha512-Euf9GG8WT9CdqwuWJGdf3RkUcTBArppHABkO7Lm8IzRQp0e2r/kkFnmhu4TSK30Wcu5rVAZLmfPKSBBi9tWFog==",
|
||||
"requires": {
|
||||
"protocols": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"parse-url": {
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/parse-url/-/parse-url-7.0.2.tgz",
|
||||
"integrity": "sha512-PqO4Z0eCiQ08Wj6QQmrmp5YTTxpYfONdOEamrtvK63AmzXpcavIVQubGHxOEwiIoDZFb8uDOoQFS0NCcjqIYQg==",
|
||||
"version": "8.1.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-url/-/parse-url-8.1.0.tgz",
|
||||
"integrity": "sha512-xDvOoLU5XRrcOZvnI6b8zA6n9O9ejNk/GExuz1yBuWUGn9KA97GI6HTs6u02wKara1CeVmZhH+0TZFdWScR89w==",
|
||||
"requires": {
|
||||
"is-ssh": "^1.4.0",
|
||||
"normalize-url": "^6.1.0",
|
||||
"parse-path": "^5.0.0",
|
||||
"protocols": "^2.0.1"
|
||||
"parse-path": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"parseurl": {
|
||||
@@ -9269,12 +9231,12 @@
|
||||
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg=="
|
||||
},
|
||||
"verify-aws-sns-signature": {
|
||||
"version": "0.0.7",
|
||||
"resolved": "https://registry.npmjs.org/verify-aws-sns-signature/-/verify-aws-sns-signature-0.0.7.tgz",
|
||||
"integrity": "sha512-j/yePIQvLqRGshOwuEs9VT7jGh++1hBoOjjt+Rl4aAffJTu+22GwTPfAD9fLY9VqRrR4Cuiid3eNHOkmxE3TNg==",
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/verify-aws-sns-signature/-/verify-aws-sns-signature-0.1.0.tgz",
|
||||
"integrity": "sha512-giPj4dIrhounlQA+AAy0CZmqARrT2o4WjIcv1GKcnQiKBDmDpJyGIaHu/ESwOGVcZf68aLHFPrEzhudXSp4Krw==",
|
||||
"requires": {
|
||||
"bent": "^7.3.12",
|
||||
"parse-url": "^7.0.2"
|
||||
"parse-url": "^8.1.0"
|
||||
}
|
||||
},
|
||||
"verror": {
|
||||
|
||||
@@ -20,19 +20,19 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node app",
|
||||
"test": "NODE_ENV=test HTTP_PORT=3050 JAMBONES_NETWORK_CIDR='127.0.0.1/32' JAMBONES_HOSTING=1 SBC_ACCOUNT_SID=ed649e33-e771-403a-8c99-1780eabbc803 JAMBONES_TIME_SERIES_HOST=127.0.0.1 JAMBONES_MYSQL_HOST=127.0.0.1 JAMBONES_MYSQL_USER=jambones_test JAMBONES_MYSQL_PASSWORD=jambones_test JAMBONES_MYSQL_DATABASE=jambones_test JAMBONES_REDIS_HOST=localhost JAMBONES_REDIS_PORT=16379 JAMBONES_LOGLEVEL=info DRACHTIO_SECRET=cymru DRACHTIO_HOST=127.0.0.1 DRACHTIO_PORT=9060 JAMBONES_RTPENGINES=127.0.0.1:12222 JAMBONES_FEATURE_SERVERS=172.38.0.11 node test/ ",
|
||||
"test": "NODE_ENV=test HTTP_PORT=3050 JAMBONES_NETWORK_CIDR='127.0.0.1/32' JAMBONES_HOSTING=1 SBC_ACCOUNT_SID=ed649e33-e771-403a-8c99-1780eabbc803 JAMBONES_TIME_SERIES_HOST=127.0.0.1 JAMBONES_MYSQL_HOST=127.0.0.1 JAMBONES_MYSQL_USER=jambones_test JAMBONES_MYSQL_PASSWORD=jambones_test JAMBONES_MYSQL_DATABASE=jambones_test JAMBONES_REDIS_HOST=localhost JAMBONES_REDIS_PORT=16379 JAMBONES_LOGLEVEL=error DRACHTIO_SECRET=cymru DRACHTIO_HOST=127.0.0.1 DRACHTIO_PORT=9060 JAMBONES_RTPENGINES=127.0.0.1:12222 JAMBONES_FEATURE_SERVERS=172.38.0.11 node test/ ",
|
||||
"coverage": "./node_modules/.bin/nyc --reporter html --report-dir ./coverage npm run test",
|
||||
"jslint": "eslint app.js lib"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jambonz/db-helpers": "^0.6.18",
|
||||
"@jambonz/http-authenticator": "^0.2.1",
|
||||
"@jambonz/http-authenticator": "^0.2.2",
|
||||
"@jambonz/http-health-check": "^0.0.1",
|
||||
"@jambonz/realtimedb-helpers": "^0.4.29",
|
||||
"@jambonz/rtpengine-utils": "^0.3.1",
|
||||
"@jambonz/siprec-client-utils": "^0.1.4",
|
||||
"@jambonz/stats-collector": "^0.1.6",
|
||||
"@jambonz/time-series": "^0.1.12",
|
||||
"@jambonz/time-series": "^0.2.1",
|
||||
"aws-sdk": "^2.1152.0",
|
||||
"bent": "^7.3.12",
|
||||
"cidr-matcher": "^2.1.1",
|
||||
@@ -43,7 +43,7 @@
|
||||
"pino": "^7.11.0",
|
||||
"sdp-transform": "^2.14.1",
|
||||
"uuid": "^8.3.2",
|
||||
"verify-aws-sns-signature": "^0.0.7",
|
||||
"verify-aws-sns-signature": "^0.1.0",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -58,7 +58,7 @@ test('incoming call tests', async(t) => {
|
||||
t.pass('handles in-dialog requests');
|
||||
|
||||
await sippUac('uac-pcap-carrier-max-call-limit.xml', '172.38.0.20');
|
||||
t.pass('rejects incoming call with 503 when max calls reached')
|
||||
t.pass('rejects incoming call with 503 when max calls per account reached')
|
||||
|
||||
await waitFor(10);
|
||||
const res = await queryCdrs({account_sid: 'ed649e33-e771-403a-8c99-1780eabbc803'});
|
||||
|
||||
Reference in New Issue
Block a user