private boolean isMatchInternal(IPListConfig config, String remoteAddrStr) throws AddressStringException {
        // An exact match from the user-provided config. Shortcut.
        if (config.getIpList().contains(remoteAddrStr)) {
            return true;
        }
        // If we've matched this IP before, then we can just re-use that result.
        MatchCacheKey cacheKey = new MatchCacheKey(config, remoteAddrStr);
        Boolean cacheResult = matchCache.getIfPresent(cacheKey);
        if (cacheResult != null) {
            return cacheResult;
        }

        // Slow path, but we'll cache the result.
        Set<IPAddressString> rules = getOrInstantiateRules(config);
        for (IPAddressString rule : rules) {
            IPAddressString remoteAddr = new IPAddressString(remoteAddrStr);
            // If it's prefix like CIDR or a wildcard (/12, .*)
            if (rule.isPrefixed()) {
                if (rule.prefixEquals(remoteAddr)) {
                    cacheMatch(cacheKey, true);
                    return true;
                }
            } else {
                // Rule matches exactly (or via some direct match).
                if (rule.equals(remoteAddr) || rule.contains(remoteAddr) ) {
                    cacheMatch(cacheKey, true);
                    return true;
                }

                // If the rule is a range.
                String ruleAsString = rule.toString();
                boolean isRange = ruleAsString.contains("-");
                if (isRange) {
                    String[] rangeSplit = ruleAsString.split("-");
                    if (rangeSplit.length != 2) {
                        throw new IllegalArgumentException("Invalid range rule: " + ruleAsString);
                    }
                    IPAddress lower = new IPAddressString(rangeSplit[0]).toAddress();
                    IPAddress upper = new IPAddressString(rangeSplit[1]).toAddress();
                    IPAddressSeqRange ruleRange = lower.spanWithRange(upper);
                    cacheMatch(cacheKey, true);
                    return ruleRange.contains(remoteAddr.toAddress());
                }
            }
        }
        cacheMatch(cacheKey, false);
        return false;
    }
Returns true if the remote address is a match for the configured
values in the IP List.
@param config the config
@param remoteAddrStr the remote address
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/AbstractIPListPolicy.java