* 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)
| 31 | * @return {string} |
| 32 | */ |
| 33 | function 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 | |
| 51 | function isValidDate(d) { |
| 52 | return d instanceof Date && !isNaN(d); |