From 1a6747b78fa0b2ef4ac7a8cd66a1c92ee7fb5f0a Mon Sep 17 00:00:00 2001 From: "thomas.hazelaar" Date: Tue, 10 Oct 2023 11:48:15 +0200 Subject: [PATCH] Added a environment variable JAMBONES_OUTDIAL_TRUNK_FAILOVER to disable random trunk selection --- lib/call-session.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/call-session.js b/lib/call-session.js index 2bd859e..4c3a854 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -229,6 +229,14 @@ class CallSession extends Emitter { /* was a specific carrier requested */ let voip_carrier_sid = this.req.get('X-Requested-Carrier-Sid'); const account_sid = this.req.get('X-Account-Sid'); + this.logger.info(`carrier requested ${voip_carrier_sid}`); + if (!voip_carrier_sid) { + if(process.env.JAMBONES_OUTDIAL_TRUNK_FAILOVER==='false') { + this.logger.info(`no outbound carriers found for account_sid ${account_sid}`); + this.res.send(603); + return this.srf.endSession(this.req); + } + } if (!voip_carrier_sid && account_sid) { /* search for an LCR table for this account or service provider */ voip_carrier_sid = await this.lookupCarrierByAccountLcr(account_sid, this.req.calledNumber); @@ -247,7 +255,7 @@ class CallSession extends Emitter { } if (!voip_carrier_sid) { /* no LCR/ inbound carrier for this account/SP - at this point its a random shuffle of outbound carriers */ - voip_carrier_sid = await this.lookupOutboundCarrierForAccount(this.account_sid); + voip_carrier_sid = await this.lookupOutboundCarrierForAccount(this.account_sid); } if (!voip_carrier_sid) { /* no outbound carriers exist for this account/SP */