many changes from testing

This commit is contained in:
Dave Horton
2020-02-22 11:06:39 -05:00
parent 802cc1944f
commit 4bd9e015b5
10 changed files with 131 additions and 46 deletions

13
lib/utils/select-sbc.js Normal file
View File

@@ -0,0 +1,13 @@
const CIDRMatcher = require('cidr-matcher');
const matcher = new CIDRMatcher([process.env.JAMBONES_NETWORK_CIDR]);
module.exports = (sbcList) => {
const obj = sbcList
.split(',')
.map((str) => {
const arr = /^(.*)\/(.*):(\d+)$/.exec(str);
return {protocol: arr[1], host: arr[2], port: arr[3]};
})
.find((obj) => 'udp' == obj.protocol && matcher.contains(obj.host));
if (obj) return `${obj.host}:${obj.port}`;
};