mirror of
https://github.com/jambonz/sbc-inbound.git
synced 2026-07-24 04:41:53 +00:00
support PRIVATE_VOIP_NETWORK_CIDR for SDP negotiation (#124)
* support PRIVATE_VOIP_NETWORK_CIDR for SDP negotiation * support multi PRIVATE_VOIP_NETWORK_CIDR
This commit is contained in:
+3
-2
@@ -6,7 +6,8 @@ const {
|
||||
SdpWantsSDES,
|
||||
nudgeCallCounts,
|
||||
roundTripTime,
|
||||
parseConnectionIp
|
||||
parseConnectionIp,
|
||||
isPrivateVoipNetwork
|
||||
} = require('./utils');
|
||||
|
||||
const {forwardInDialogRequests} = require('drachtio-fn-b2b-sugar');
|
||||
@@ -177,7 +178,7 @@ class CallSession extends Emitter {
|
||||
...this.rtpEngineOpts.common,
|
||||
...this.rtpEngineOpts.uac.mediaOpts,
|
||||
'from-tag': this.rtpEngineOpts.uas.tag,
|
||||
direction: ['public', 'private'],
|
||||
direction: [isPrivateVoipNetwork(this.req.source_address) ? 'private' : 'public', 'private'],
|
||||
sdp
|
||||
};
|
||||
const startAt = process.hrtime();
|
||||
|
||||
+10
-1
@@ -195,6 +195,14 @@ const isMSTeamsCIDR = (ip) => {
|
||||
return matcher.contains(ip);
|
||||
};
|
||||
|
||||
const isPrivateVoipNetwork = (ip) => {
|
||||
if (process.env.PRIVATE_VOIP_NETWORK_CIDR) {
|
||||
const matcher = new CIDRMatcher(process.env.PRIVATE_VOIP_NETWORK_CIDR.split(','));
|
||||
return matcher.contains(ip);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
isWSS,
|
||||
SdpWantsSrtp,
|
||||
@@ -211,5 +219,6 @@ module.exports = {
|
||||
nudgeCallCounts,
|
||||
roundTripTime,
|
||||
parseConnectionIp,
|
||||
isMSTeamsCIDR
|
||||
isMSTeamsCIDR,
|
||||
isPrivateVoipNetwork
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user