How to use the is-cidr function in is-cidr

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;
    };
}

is-cidr

Check if a string is an IP address in CIDR notation

BSD-2-Clause
Latest version published 16 days ago

Package Health Score

72 / 100
Full package analysis

Similar packages