public static boolean isIPInRange(String ip, String cidr) {
        try {
            String[] parts = cidr.split(SLASH);
            if (parts.length == 1) {
                return StringUtils.equals(ip, cidr);
            }
            if (parts.length != 2) {
                return false;
            }
            InetAddress cidrIp = InetAddress.getByName(parts[0]);
            int prefixLength = Integer.parseInt(parts[1]);

            BigInteger cidrIpBigInt = new BigInteger(1, cidrIp.getAddress());
            BigInteger ipBigInt = new BigInteger(1, InetAddress.getByName(ip).getAddress());

            BigInteger mask = BigInteger.valueOf(-1).shiftLeft(cidrIp.getAddress().length * 8 - prefixLength);
            BigInteger cidrIpLower = cidrIpBigInt.and(mask);
            BigInteger cidrIpUpper = cidrIpLower.add(mask.not());

            return ipBigInt.compareTo(cidrIpLower) >= 0 && ipBigInt.compareTo(cidrIpUpper) <= 0;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
@Test
    public void isIPInRange() {

        // IPv4 test
        String ipv4Address = "192.168.1.10";
        String ipv4Cidr = "192.168.1.0/24";
        assert IPAddressUtils.isIPInRange(ipv4Address, ipv4Cidr);

        ipv4Address = "192.168.2.10";
        assert !IPAddressUtils.isIPInRange(ipv4Address, ipv4Cidr);

        // IPv6 test
        String ipv6Address = "2001:0db8:85a3:0000:0000:8a2e:0370:7334";
        String ipv6Cidr = "2001:0db8:85a3::/48";
        assert IPAddressUtils.isIPInRange(ipv6Address, ipv6Cidr);
    }