if REFER from FS has a hostname in the Refer-To preserve it on the outbound REFER

This commit is contained in:
Dave Horton
2022-11-28 12:29:58 -05:00
parent ebcd0ce4a2
commit c4d4d7bc0a
2 changed files with 4 additions and 3 deletions
+3 -3
View File
@@ -774,10 +774,10 @@ Duration=${payload.duration} `
const referredBy = req.getParsedHeader('Referred-By');
if (!referredBy) return res.send(400);
const u = parseUri(referredBy.uri);
const isDotDecimal = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(uri.host);
let selectedGateway = false;
let e164 = false;
if (gateway) {
if (gateway && isDotDecimal) {
/* host of Refer-to to an outbound gateway */
const gw = await this.srf.locals.getOutboundGatewayForRefer(gateway.voip_carrier_sid);
if (gw) {
@@ -787,7 +787,7 @@ Duration=${payload.duration} `
uri.port = gw.port;
}
}
if (!selectedGateway) {
if (!selectedGateway && isDotDecimal) {
uri.host = this.req.source_address;
uri.port = this.req.source_port;
}
+1
View File
@@ -60,6 +60,7 @@ test('incoming call tests', async(t) => {
await sippUac('uac-pcap-carrier-max-call-limit.xml', '172.38.0.20');
t.pass('rejects incoming call with 503 when max calls per account reached');
/* switch off this env for remaining tests (JAMBONES_HOSTING is for Saas sts) */
delete process.env.JAMBONES_HOSTING;
await sippUac('uac-pcap-carrier-fail-ambiguous.xml', '172.38.0.40');
t.pass('rejects incoming call with 503 when multiple accounts have same carrier witrh default routing')