mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-10-04 02:04:22 +00:00
reject calls on hosted jambonz with no active subscriptions (#191)
This commit is contained in:
+5
-2
@@ -295,7 +295,6 @@ module.exports = function(srf, logger) {
|
|||||||
logger.debug(`checkLimits: call count is now ${calls}, limit is ${minLimit}`);
|
logger.debug(`checkLimits: call count is now ${calls}, limit is ${minLimit}`);
|
||||||
if (calls <= minLimit) return next();
|
if (calls <= minLimit) return next();
|
||||||
|
|
||||||
if (process.env.JAMBONES_HOSTING) {
|
|
||||||
const accountCapacities = await lookupAccountCapacitiesBySid(account_sid);
|
const accountCapacities = await lookupAccountCapacitiesBySid(account_sid);
|
||||||
const accountLimit = accountCapacities.find((c) => c.category == 'voice_call_session');
|
const accountLimit = accountCapacities.find((c) => c.category == 'voice_call_session');
|
||||||
if (accountLimit) {
|
if (accountLimit) {
|
||||||
@@ -314,7 +313,6 @@ module.exports = function(srf, logger) {
|
|||||||
return req.srf.endSession(req);
|
return req.srf.endSession(req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (trackingOn) {
|
else if (trackingOn) {
|
||||||
const {account_limit, sp_limit} = await queryCallLimits(service_provider_sid, account_sid);
|
const {account_limit, sp_limit} = await queryCallLimits(service_provider_sid, account_sid);
|
||||||
if (process.env.JAMBONES_TRACK_ACCOUNT_CALLS && account_limit > 0 && calls > account_limit) {
|
if (process.env.JAMBONES_TRACK_ACCOUNT_CALLS && account_limit > 0 && calls > account_limit) {
|
||||||
@@ -333,6 +331,11 @@ module.exports = function(srf, logger) {
|
|||||||
});
|
});
|
||||||
return req.srf.endSession(req);
|
return req.srf.endSession(req);
|
||||||
}
|
}
|
||||||
|
if (!account_limit && !sp_limit && process.env.JAMBONES_HOSTING) {
|
||||||
|
logger.info(`checkLimits: no active subscription found for account ${account_sid}, rejecting call`);
|
||||||
|
res.send(503, 'No Active Subscription');
|
||||||
|
return req.srf.endSession(req);
|
||||||
|
}
|
||||||
if (process.env.JAMBONES_TRACK_SP_CALLS && sp_limit > 0 && callsSP > sp_limit) {
|
if (process.env.JAMBONES_TRACK_SP_CALLS && sp_limit > 0 && callsSP > sp_limit) {
|
||||||
logger.info({callsSP, sp_limit}, 'checkLimits: service provider limits exceeded');
|
logger.info({callsSP, sp_limit}, 'checkLimits: service provider limits exceeded');
|
||||||
writeAlerts({
|
writeAlerts({
|
||||||
|
|||||||
Generated
+7
-7
@@ -11,7 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-auto-scaling": "^3.549.0",
|
"@aws-sdk/client-auto-scaling": "^3.549.0",
|
||||||
"@aws-sdk/client-sns": "^3.549.0",
|
"@aws-sdk/client-sns": "^3.549.0",
|
||||||
"@jambonz/db-helpers": "^0.9.7",
|
"@jambonz/db-helpers": "^0.9.9",
|
||||||
"@jambonz/digest-utils": "^0.0.5",
|
"@jambonz/digest-utils": "^0.0.5",
|
||||||
"@jambonz/http-health-check": "^0.0.1",
|
"@jambonz/http-health-check": "^0.0.1",
|
||||||
"@jambonz/realtimedb-helpers": "^0.8.8",
|
"@jambonz/realtimedb-helpers": "^0.8.8",
|
||||||
@@ -1410,9 +1410,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@jambonz/db-helpers": {
|
"node_modules/@jambonz/db-helpers": {
|
||||||
"version": "0.9.7",
|
"version": "0.9.9",
|
||||||
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.9.7.tgz",
|
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.9.9.tgz",
|
||||||
"integrity": "sha512-5qN/CJZJXpbMkMn+8gFn8PpQ0ZImZxp1EjKyxLUlmMn+xgjeNb29c3pjeVt/6EQnBB65jAax6TNsVzVIfpvE2w==",
|
"integrity": "sha512-aUr7kq78NUiOg7/aqFW+KseHqwujtThaJHu7O1Bp5OznHLMDNFB8jJJDs3LGIqaRHEM/c4oaKtpKA4wahgP99w==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cidr-matcher": "^2.1.1",
|
"cidr-matcher": "^2.1.1",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
@@ -7907,9 +7907,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@jambonz/db-helpers": {
|
"@jambonz/db-helpers": {
|
||||||
"version": "0.9.7",
|
"version": "0.9.9",
|
||||||
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.9.7.tgz",
|
"resolved": "https://registry.npmjs.org/@jambonz/db-helpers/-/db-helpers-0.9.9.tgz",
|
||||||
"integrity": "sha512-5qN/CJZJXpbMkMn+8gFn8PpQ0ZImZxp1EjKyxLUlmMn+xgjeNb29c3pjeVt/6EQnBB65jAax6TNsVzVIfpvE2w==",
|
"integrity": "sha512-aUr7kq78NUiOg7/aqFW+KseHqwujtThaJHu7O1Bp5OznHLMDNFB8jJJDs3LGIqaRHEM/c4oaKtpKA4wahgP99w==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"cidr-matcher": "^2.1.1",
|
"cidr-matcher": "^2.1.1",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@
|
|||||||
"jslint:fix": "npm run jslint --fix"
|
"jslint:fix": "npm run jslint --fix"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jambonz/db-helpers": "^0.9.7",
|
"@jambonz/db-helpers": "^0.9.9",
|
||||||
"@jambonz/http-health-check": "^0.0.1",
|
"@jambonz/http-health-check": "^0.0.1",
|
||||||
"@jambonz/realtimedb-helpers": "^0.8.8",
|
"@jambonz/realtimedb-helpers": "^0.8.8",
|
||||||
"@jambonz/rtpengine-utils": "^0.4.4",
|
"@jambonz/rtpengine-utils": "^0.4.4",
|
||||||
|
|||||||
Reference in New Issue
Block a user