diff --git a/lib/call-session.js b/lib/call-session.js index 9261dfc..ec4a0d2 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -217,6 +217,10 @@ class CallSession extends Emitter { private_network: await isPrivateVoipNetwork(this.req.uri), uri: this.req.uri }]; + if (this.req.has('X-SIP-Proxy')) { + proxy = this.req.get('X-SIP-Proxy'); + if (!proxy.startsWith('sip:') && !proxy.startsWith('sips:')) proxy = `sip:${proxy}`; + } } else if (teams) { const vmailParam = 'opaque=app:voicemail'; @@ -425,6 +429,7 @@ class CallSession extends Emitter { '-X-Preferred-From-Host', '-X-Jambonz-FS-UUID', '-X-Voip-Carrier-Sid', + '-X-SIP-Proxy' ], proxyResponseHeaders: [ 'all', diff --git a/test/scenarios/uac-sip-uri-proxy.xml b/test/scenarios/uac-sip-uri-proxy.xml new file mode 100644 index 0000000..31d1143 --- /dev/null +++ b/test/scenarios/uac-sip-uri-proxy.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + ;tag=[pid]SIPpTag09[call_number] + To: + Call-ID: [call_id] + CSeq: 1 INVITE + Contact: sip:sipp@[local_ip]:[local_port] + Max-Forwards: 70 + Subject: uac-sip-uri-proxy + X-Account-Sid: ed649e33-e771-403a-8c99-1780eabbc803 + X-Call-Sid: fff49e33-e771-403a-8c99-1780eabbc803 + X-Jambonz-Routing: sip + X-SIP-Proxy: 172.39.0.20:5060 + Content-Type: application/sdp + Content-Length: [len] + + v=0 + o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip] + s=- + c=IN IP[local_ip_type] [local_ip] + t=0 0 + m=audio [auto_media_port] RTP/AVP 8 101 + a=rtpmap:8 PCMA/8000 + a=rtpmap:101 telephone-event/8000 + a=fmtp:101 0-11,16 + + ]]> + + + + + + + + + + + + + + + [peer_tag_param] + [last_Call-ID:] + CSeq: 2 ACK + Subject: + Content-Length: 0 + + ]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/sip-tests.js b/test/sip-tests.js index 538646d..d4a5f77 100644 --- a/test/sip-tests.js +++ b/test/sip-tests.js @@ -84,6 +84,10 @@ test('sbc-outbound tests', async(t) => { await sippUac('uac-sip-uri-auth-success.xml'); t.pass('successfully connected to sip uri that requires auth'); + /* invite to sipUri through proxy */ + await sippUac('uac-sip-uri-proxy.xml'); + t.pass('successfully connected to sip uri through proxy'); + // re-rack test data execSync(`mysql -h 127.0.0.1 -u root --protocol=tcp -D jambones_test < ${__dirname}/db/jambones-sql.sql`); execSync(`mysql -h 127.0.0.1 -u root --protocol=tcp -D jambones_test < ${__dirname}/db/populate-test-data5.sql`); @@ -96,7 +100,7 @@ test('sbc-outbound tests', async(t) => { const res = await queryCdrs({account_sid: 'ed649e33-e771-403a-8c99-1780eabbc803'}); console.log(`${res.total} cdrs: ${JSON.stringify(res)}`); - t.ok(res.total === 8, 'wrote 8 cdrs'); + t.ok(res.total === 9, 'wrote 9 cdrs'); srf.disconnect(); } catch (err) {