From 750294eab2a23071ade30dca12c34415f0e35256 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Wed, 10 May 2023 16:02:08 -0400 Subject: [PATCH] add support for tls with srtp media encryption (#83) --- lib/call-session.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/call-session.js b/lib/call-session.js index bab062e..4a1de1d 100644 --- a/lib/call-session.js +++ b/lib/call-session.js @@ -256,7 +256,8 @@ class CallSession extends Emitter { const obj = { name: vc.name, diversion: vc.diversion, - hostport + hostport, + protocol: o.protocol }; if (vc.register_username && vc.register_password) { obj.auth = { @@ -266,6 +267,16 @@ class CallSession extends Emitter { } mapGateways.set(u, obj); uris.push(u); + if (o.protocol === 'tls/srtp') { + /** TODO: this is a bit of a hack in the sense that we are not + * supporting a scenario where you have a carrier with several outbound + * gateways, some requiring encrypted media and some not. This should be rectified + * but it will require more significant changes and right now it seems + * like a rare use case -- encryption is usually an all or nothing requirement. + */ + this.logger.info({u}, 'using SRTP for outbound call'); + this.rtpEngineOpts = makeRtpEngineOpts(this.req, false, true, true); + } }); this.logger.debug({uris, voip_carrier_sid}, 'selected outbound gateways for requested carrier'); }