mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2025-12-19 04:37:43 +00:00
wip
This commit is contained in:
3
app.js
3
app.js
@@ -67,6 +67,7 @@ const {LifeCycleEvents} = require('./lib/constants');
|
||||
const setNameRtp = `${(process.env.JAMBONES_CLUSTER_ID || 'default')}:active-rtp`;
|
||||
const rtpServers = [];
|
||||
const setName = `${(process.env.JAMBONES_CLUSTER_ID || 'default')}:active-sip`;
|
||||
const Registrar = require('@jambonz/mw-registrar');
|
||||
|
||||
const {
|
||||
pool,
|
||||
@@ -101,6 +102,7 @@ const {
|
||||
host: process.env.JAMBONES_REDIS_HOST,
|
||||
port: process.env.JAMBONES_REDIS_PORT || 6379
|
||||
}, logger);
|
||||
const registrar = new Registrar(logger, redisClient);
|
||||
|
||||
const ngProtocol = process.env.JAMBONES_NG_PROTOCOL || 'udp';
|
||||
const ngPort = process.env.RTPENGINE_PORT || ('udp' === ngProtocol ? 22222 : 8080);
|
||||
@@ -121,6 +123,7 @@ srf.locals = {...srf.locals,
|
||||
activeCallIds: new Map(),
|
||||
getRtpEngine,
|
||||
dbHelpers: {
|
||||
registrar,
|
||||
pool,
|
||||
ping,
|
||||
lookupAuthHook,
|
||||
|
||||
@@ -227,6 +227,9 @@ class CallSession extends Emitter {
|
||||
if (this.req.locals.queue_name) {
|
||||
Object.assign(headers, {'X-Queue-Name': this.req.locals.queue_name});
|
||||
}
|
||||
if (this.req.locals.called_user) {
|
||||
Object.assign(headers, {'X-Called-User': this.req.locals.called_user});
|
||||
}
|
||||
if (this.req.authorization) {
|
||||
if (this.req.authorization.grant && this.req.authorization.grant.application_sid) {
|
||||
Object.assign(headers, {'X-Application-Sid': this.req.authorization.grant.application_sid});
|
||||
|
||||
@@ -29,7 +29,8 @@ module.exports = function(srf, logger) {
|
||||
lookupAccountBySid,
|
||||
lookupAccountCapacitiesBySid,
|
||||
queryCallLimits,
|
||||
lookupAppBySid
|
||||
lookupAppBySid,
|
||||
registrar
|
||||
} = srf.locals.dbHelpers;
|
||||
const {stats, writeCdrs} = srf.locals;
|
||||
|
||||
@@ -198,6 +199,7 @@ module.exports = function(srf, logger) {
|
||||
return req.srf.endSession(req);
|
||||
}
|
||||
let deviceAppSid = null;
|
||||
let called_user = null;
|
||||
const queue_name = uri.user.startsWith('queue-') ? uri.user.match(/queue-(.*)/)[1] : null;
|
||||
if (uri.user.startsWith('app-')) {
|
||||
// Call from registered device to test application.
|
||||
@@ -206,6 +208,14 @@ module.exports = function(srf, logger) {
|
||||
if (app && app.account_sid === account.account_sid) {
|
||||
deviceAppSid = app.application_sid;
|
||||
}
|
||||
} else if (!queue_name) {
|
||||
// check if call to registered user
|
||||
const {realm} = this.req.authorization.challengeResponse;
|
||||
const calledAor = `${req.calledNumber}@${realm}`;
|
||||
const reg = await registrar.query(calledAor);
|
||||
if (reg) {
|
||||
called_user = calledAor;
|
||||
}
|
||||
}
|
||||
req.locals = {
|
||||
service_provider_sid: account.service_provider_sid,
|
||||
@@ -213,6 +223,7 @@ module.exports = function(srf, logger) {
|
||||
account,
|
||||
application_sid: deviceAppSid || account.device_calling_application_sid,
|
||||
...(queue_name && ({queue_name})),
|
||||
...(called_user && ({called_user})),
|
||||
webhook_secret: account.webhook_secret,
|
||||
realm: uri.host,
|
||||
...(account.registration_hook && {
|
||||
|
||||
17
package-lock.json
generated
17
package-lock.json
generated
@@ -14,6 +14,7 @@
|
||||
"@jambonz/db-helpers": "^0.9.1",
|
||||
"@jambonz/digest-utils": "^0.0.3",
|
||||
"@jambonz/http-health-check": "^0.0.1",
|
||||
"@jambonz/mw-registrar": "^0.2.4",
|
||||
"@jambonz/realtimedb-helpers": "^0.8.6",
|
||||
"@jambonz/rtpengine-utils": "^0.4.3",
|
||||
"@jambonz/siprec-client-utils": "^0.2.6",
|
||||
@@ -1696,6 +1697,14 @@
|
||||
"node": ">=14.x"
|
||||
}
|
||||
},
|
||||
"node_modules/@jambonz/mw-registrar": {
|
||||
"version": "0.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/mw-registrar/-/mw-registrar-0.2.5.tgz",
|
||||
"integrity": "sha512-+aBI2xpR6Ir140Hi7/ED+z5Hl7NgCalyVzTLNlgUVzTvsMLtyZZh6n9IQipKnuKvhh4nPM4aJ+JuFhi1UH9zEA==",
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@jambonz/realtimedb-helpers": {
|
||||
"version": "0.8.6",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.8.6.tgz",
|
||||
@@ -7664,6 +7673,14 @@
|
||||
"express": "^4.17.2"
|
||||
}
|
||||
},
|
||||
"@jambonz/mw-registrar": {
|
||||
"version": "0.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/mw-registrar/-/mw-registrar-0.2.5.tgz",
|
||||
"integrity": "sha512-+aBI2xpR6Ir140Hi7/ED+z5Hl7NgCalyVzTLNlgUVzTvsMLtyZZh6n9IQipKnuKvhh4nPM4aJ+JuFhi1UH9zEA==",
|
||||
"requires": {
|
||||
"debug": "^4.3.4"
|
||||
}
|
||||
},
|
||||
"@jambonz/realtimedb-helpers": {
|
||||
"version": "0.8.6",
|
||||
"resolved": "https://registry.npmjs.org/@jambonz/realtimedb-helpers/-/realtimedb-helpers-0.8.6.tgz",
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
"@jambonz/stats-collector": "^0.1.9",
|
||||
"@jambonz/time-series": "^0.2.5",
|
||||
"@jambonz/digest-utils": "^0.0.3",
|
||||
"@jambonz/mw-registrar": "^0.2.4",
|
||||
"@aws-sdk/client-sns": "^3.360.0",
|
||||
"@aws-sdk/client-auto-scaling": "^3.360.0",
|
||||
"bent": "^7.3.12",
|
||||
|
||||
Reference in New Issue
Block a user