use system_information.private_network_cidr (#143)

* use system_information.private_network_cidr

* make gh actions work

* fix: export logger
This commit is contained in:
Dave Horton
2024-08-18 12:50:19 -04:00
committed by GitHub
parent bf1c670b40
commit a7406ddb8a
5 changed files with 43 additions and 23 deletions

21
app.js
View File

@@ -50,7 +50,8 @@ const {
lookupSipGatewaysByCarrier,
lookupCarrierBySid,
queryCallLimits,
lookupCarrierByAccountLcr
lookupCarrierByAccountLcr,
lookupSystemInformation
} = require('@jambonz/db-helpers')({
host: process.env.JAMBONES_MYSQL_HOST,
port: process.env.JAMBONES_MYSQL_PORT || 3306,
@@ -84,6 +85,7 @@ srf.locals = {...srf.locals,
queryCdrs,
activeCallIds,
idleEmitter,
privateNetworkCidr: process.env.PRIVATE_VOIP_NETWORK_CIDR || null,
dbHelpers: {
ping,
lookupOutboundCarrierForAccount,
@@ -94,7 +96,8 @@ srf.locals = {...srf.locals,
lookupSipGatewaysByCarrier,
lookupCarrierBySid,
queryCallLimits,
lookupCarrierByAccountLcr
lookupCarrierByAccountLcr,
lookupSystemInformation
},
realtimeDbHelpers: {
client: redisClient,
@@ -184,10 +187,18 @@ if (process.env.K8S || process.env.HTTP_PORT) {
});
}
if ('test' !== process.env.NODE_ENV) {
/* update call stats periodically */
setInterval(() => {
/* update call stats periodically as well as definition of private network cidr */
setInterval(async() => {
stats.gauge('sbc.sip.calls.count', activeCallIds.size, ['direction:outbound',
`instance_id:${process.env.INSTANCE_ID || 0}`]);
const r = await lookupSystemInformation();
if (r) {
if (r.private_network_cidr !== srf.locals.privateNetworkCidr) {
logger.info(`updating private network cidr from ${srf.locals.privateNetworkCidr} to ${r.private_network_cidr}`);
srf.locals.privateNetworkCidr = r.private_network_cidr;
}
}
}, 20000);
}
@@ -262,4 +273,4 @@ function handle(signal) {
}
}
module.exports = {srf};
module.exports = {srf, logger};