MCPcopy Create free account
hub / github.com/adobe/Marinus / createRange

Function createRange

web_server/routes/dns.js:33–49  ·  view source on GitHub ↗

* Converts a CIDR range into a string for text searches. * Supports Class B and Class C ranges. * @param {string} range The CIDR range to be converted. * @return {string}

(range)

Source from the content-addressed store, hash-verified

31 * @return {string}
32 */
33function createRange(range) {
34 let parts = range.split('/');
35 let ip = parts[0];
36 let ipParts = ip.split('.');
37 let cidr = parts[1];
38 if (cidr < 8 || cidr > 32) {
39 return ('Error: Invalid CIDR');
40 }
41 if (ipParts.length !== 4) {
42 return ('Error: Invalid IP');
43 }
44 let searchRange = ipParts[0] + '\\.' + ipParts[1] + '\\.';
45 if (cidr >= 24) {
46 searchRange += ipParts[2];
47 }
48 return (searchRange);
49}
50
51function isValidDate(d) {
52 return d instanceof Date && !isNaN(d);

Callers 1

dnsRouterFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected