How to use is-cidr - 9 common examples

To help you get started, we’ve selected a few is-cidr examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github terascope / teraslice / packages / xlucene-evaluator / src / document-matcher / logic-builder / ip.ts View on Github external
export function ipTerm(node: Term) {
    const argeCidr = isCidr(node.value as string);
    if (argeCidr > 0) {
        const range = ip6addr.createCIDR(node.value);
        return pRangeTerm(range);
    }

    return function isIpterm(ip: string) {
        if (isCidr(ip) > 0) {
            const argRange = ip6addr.createCIDR(ip);
            return argRange.contains(node.value);
        }
        return ip === node.value;
    };
}
github terascope / teraslice / packages / xlucene-evaluator / src / document-matcher / type-manager / types / ip.ts View on Github external
ipFn = (ip: string) => {
                            if (isCidr(ip) > 0) {
                                const argRange = ip6addr.createCIDR(ip);
                                const argFirst = argRange.first().toString();
                                const argLast = argRange.last().toString();
                                const rangeFirst = range.first().toString();
                                const rangeLast = range.last().toString();
                                return (range.contains(argFirst) || range.contains(argLast) || argRange.contains(rangeFirst) || argRange.contains(rangeLast));
                            }
                            if (isIP(ip) > 0) return range.contains(ip);
                            return false;
                        };
                    } else {
github terascope / teraslice / packages / xlucene-evaluator / src / document-matcher / logic-builder / ip.ts View on Github external
return function isIpterm(ip: string) {
        if (isCidr(ip) > 0) {
            const argRange = ip6addr.createCIDR(ip);
            return argRange.contains(node.value);
        }
        return ip === node.value;
    };
}
github terascope / teraslice / packages / xlucene-evaluator / src / document-matcher / type-manager / types / ip.ts View on Github external
const populateIpQueries = (node: AST, _field?: string) => {
            const topField = node.field || _field;

            if (topField && this.fields[topField]) {
                let ipFn;

                if (node.term) {
                    const argeCidr = isCidr(node.term);
                    if (argeCidr > 0) {
                        const range = ip6addr.createCIDR(node.term);

                        ipFn = (ip: string) => {
                            if (isCidr(ip) > 0) {
                                const argRange = ip6addr.createCIDR(ip);
                                const argFirst = argRange.first().toString();
                                const argLast = argRange.last().toString();
                                const rangeFirst = range.first().toString();
                                const rangeLast = range.last().toString();
                                return (range.contains(argFirst) || range.contains(argLast) || argRange.contains(rangeFirst) || argRange.contains(rangeLast));
                            }
                            if (isIP(ip) > 0) return range.contains(ip);
                            return false;
                        };
                    } else {
github terascope / teraslice / packages / xlucene-evaluator / src / document-matcher / logic-builder / ip.ts View on Github external
return function checkIp(ip: string) {
        if (isCidr(ip) > 0) {
            return checkCidr(ip, range);
        }
        if (isIP(ip) > 0) return range.contains(ip);
        return false;
    };
}
github npm / npm-profile / cmds / util / validate-cidr.js View on Github external
function validate (cidr) {
  if (isCidrV6(cidr)) {
    throw new Error('CIDR whitelist can only contain IPv4 addresses, ' + cidr + ' is IPv6')
  }
  if (!isCidrV4(cidr)) {
    throw new Error('CIDR whitelist contains invalid CIDR entry: ' + cidr)
  }
}
github npm / npm-profile / cmds / util / validate-cidr.js View on Github external
function validate (cidr) {
  if (isCidrV6(cidr)) {
    throw new Error('CIDR whitelist can only contain IPv4 addresses, ' + cidr + ' is IPv6')
  }
  if (!isCidrV4(cidr)) {
    throw new Error('CIDR whitelist contains invalid CIDR entry: ' + cidr)
  }
}
github graalvm / graaljs / deps / npm / lib / token.js View on Github external
function validateCIDR (cidr) {
  if (isCidrV6(cidr)) {
    throw new Error('CIDR whitelist can only contain IPv4 addresses, ' + cidr + ' is IPv6')
  }
  if (!isCidrV4(cidr)) {
    throw new Error('CIDR whitelist contains invalid CIDR entry: ' + cidr)
  }
}
github graalvm / graaljs / deps / npm / lib / token.js View on Github external
function validateCIDR (cidr) {
  if (isCidrV6(cidr)) {
    throw new Error('CIDR whitelist can only contain IPv4 addresses, ' + cidr + ' is IPv6')
  }
  if (!isCidrV4(cidr)) {
    throw new Error('CIDR whitelist contains invalid CIDR entry: ' + cidr)
  }
}

is-cidr

Check if a string is an IP address in CIDR notation

BSD-2-Clause
Latest version published 7 months ago

Package Health Score

67 / 100
Full package analysis

Similar packages