use system_information.private_network_cidr (#158)

* use system_information.private_network_cidr

* lint
This commit is contained in:
Dave Horton
2024-08-18 12:50:01 -04:00
committed by GitHub
parent fec4c42008
commit 20755f456d
4 changed files with 35 additions and 17 deletions

View File

@@ -202,9 +202,16 @@ const isMSTeamsCIDR = (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);
const {srf, logger} = require('..');
const {privateNetworkCidr} = srf.locals;
if (privateNetworkCidr) {
try {
const matcher = new CIDRMatcher(privateNetworkCidr.split(','));
return matcher.contains(ip);
} catch (err) {
logger.info({err, privateNetworkCidr},
'Error checking private network CIDR, probably misconfigured must be a comma separated list of CIDRs');
}
}
return false;
};