mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-10-04 02:04:22 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
563ea405e9 | ||
|
|
8cd91c19c9 | ||
|
|
994904e8e7 | ||
|
|
874d1804e1 | ||
|
|
9475b776be | ||
|
|
a3799576a2 |
@@ -33,7 +33,10 @@ const JAMBONES_REDIS_SENTINELS = process.env.JAMBONES_REDIS_SENTINELS ? {
|
||||
}),
|
||||
...(process.env.JAMBONES_REDIS_SENTINEL_USERNAME && {
|
||||
username: process.env.JAMBONES_REDIS_SENTINEL_USERNAME
|
||||
})
|
||||
}),
|
||||
...(process.env.JAMBONES_REDIS_SENTINEL_SENTINAL_PASSWORD && {
|
||||
sentinelPassword: process.env.JAMBONES_REDIS_SENTINEL_SENTINAL_PASSWORD
|
||||
}),
|
||||
} : null;
|
||||
|
||||
const Srf = require('drachtio-srf');
|
||||
@@ -64,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,
|
||||
@@ -77,7 +81,8 @@ const {
|
||||
lookupAccountBySid,
|
||||
lookupAccountCapacitiesBySid,
|
||||
queryCallLimits,
|
||||
lookupClientByAccountAndUsername
|
||||
lookupClientByAccountAndUsername,
|
||||
lookupAppBySid
|
||||
} = require('@jambonz/db-helpers')({
|
||||
host: process.env.JAMBONES_MYSQL_HOST,
|
||||
port: process.env.JAMBONES_MYSQL_PORT || 3306,
|
||||
@@ -97,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);
|
||||
@@ -117,6 +123,7 @@ srf.locals = {...srf.locals,
|
||||
activeCallIds: new Map(),
|
||||
getRtpEngine,
|
||||
dbHelpers: {
|
||||
registrar,
|
||||
pool,
|
||||
ping,
|
||||
lookupAuthHook,
|
||||
@@ -127,7 +134,8 @@ srf.locals = {...srf.locals,
|
||||
lookupAccountBySipRealm,
|
||||
lookupAccountCapacitiesBySid,
|
||||
queryCallLimits,
|
||||
lookupClientByAccountAndUsername
|
||||
lookupClientByAccountAndUsername,
|
||||
lookupAppBySid
|
||||
},
|
||||
realtimeDbHelpers: {
|
||||
createSet,
|
||||
|
||||
+7
-1
@@ -224,6 +224,12 @@ class CallSession extends Emitter {
|
||||
if (this.req.locals.application_sid) {
|
||||
Object.assign(headers, {'X-Application-Sid': this.req.locals.application_sid});
|
||||
}
|
||||
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});
|
||||
@@ -248,7 +254,7 @@ class CallSession extends Emitter {
|
||||
'-Max-Forwards',
|
||||
'-Record-Route',
|
||||
'-Session-Expires',
|
||||
'-X-Subspace-Forwarded-For'
|
||||
'-X-Subspace-Forwarded-For',
|
||||
],
|
||||
proxyResponseHeaders: ['all', '-X-Trace-ID'],
|
||||
localSdpB: spdOfferB,
|
||||
|
||||
+25
-2
@@ -28,7 +28,9 @@ module.exports = function(srf, logger) {
|
||||
lookupAccountBySipRealm,
|
||||
lookupAccountBySid,
|
||||
lookupAccountCapacitiesBySid,
|
||||
queryCallLimits
|
||||
queryCallLimits,
|
||||
lookupAppBySid,
|
||||
registrar
|
||||
} = srf.locals.dbHelpers;
|
||||
const {stats, writeCdrs} = srf.locals;
|
||||
|
||||
@@ -196,11 +198,32 @@ module.exports = function(srf, logger) {
|
||||
res.send(404);
|
||||
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.
|
||||
const appSid = uri.user.match(/app-(.*)/)[1];
|
||||
const app = await lookupAppBySid(appSid);
|
||||
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,
|
||||
account_sid: account.account_sid,
|
||||
account,
|
||||
application_sid: account.device_calling_application_sid,
|
||||
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 && {
|
||||
|
||||
Generated
+17
@@ -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