Package com.alibaba.druid.support.http.util

Examples of com.alibaba.druid.support.http.util.IPRange


                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    allowList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, allow : " + getInitParameter(PARAM_NAME_ALLOW);
            LOG.error(msg, e);
        }

        try {
            String param = getInitParameter(PARAM_NAME_DENY);
            if (param != null && param.trim().length() != 0) {
                param = param.trim();
                String[] items = param.split(",");

                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    denyList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, deny : " + getInitParameter(PARAM_NAME_DENY);
View Full Code Here


                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    allowList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, allow : " + getInitParameter(PARAM_NAME_ALLOW);
            LOG.error(msg, e);
        }

        try {
            String param = getInitParameter(PARAM_NAME_DENY);
            if (param != null && param.trim().length() != 0) {
                param = param.trim();
                String[] items = param.split(",");

                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    denyList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, deny : " + getInitParameter(PARAM_NAME_DENY);
View Full Code Here

                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    allowList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, allow : " + getInitParameter(PARAM_NAME_ALLOW);
            LOG.error(msg, e);
        }

        try {
            String param = getInitParameter(PARAM_NAME_DENY);
            if (param != null && param.trim().length() != 0) {
                param = param.trim();
                String[] items = param.split(",");

                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    denyList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, deny : " + getInitParameter(PARAM_NAME_DENY);
View Full Code Here

                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    allowList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, allow : " + getInitParameter(PARAM_NAME_ALLOW);
            LOG.error(msg, e);
        }

        try {
            String param = getInitParameter(PARAM_NAME_DENY);
            if (param != null && param.trim().length() != 0) {
                param = param.trim();
                String[] items = param.split(",");

                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    denyList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, deny : " + getInitParameter(PARAM_NAME_DENY);
View Full Code Here

                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    allowList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, allow : " + getInitParameter(PARAM_NAME_ALLOW);
            LOG.error(msg, e);
        }

        try {
            String param = getInitParameter(PARAM_NAME_DENY);
            if (param != null && param.trim().length() != 0) {
                param = param.trim();
                String[] items = param.split(",");

                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    denyList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, deny : " + getInitParameter(PARAM_NAME_DENY);
View Full Code Here

                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    allowList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, allow : " + getInitParameter(PARAM_NAME_ALLOW);
            LOG.error(msg, e);
        }

        try {
            String param = getInitParameter(PARAM_NAME_DENY);
            if (param != null && param.trim().length() != 0) {
                param = param.trim();
                String[] items = param.split(",");

                for (String item : items) {
                    if (item == null || item.length() == 0) {
                        continue;
                    }

                    IPRange ipRange = new IPRange(item);
                    denyList.add(ipRange);
                }
            }
        } catch (Exception e) {
            String msg = "initParameter config error, deny : " + getInitParameter(PARAM_NAME_DENY);
View Full Code Here

import com.alibaba.druid.support.http.util.IPRange;

public class IPRangeTest extends TestCase {

    public void test_ipRange_0() throws Exception {
        IPRange rang = new IPRange("128.242.127.0/24");

        assertEquals("128.242.127.0", rang.getIPAddress().toString());
        assertEquals("255.255.255.0", rang.getIPSubnetMask().toString());

        assertTrue(rang.isIPAddressInRange(new IPAddress("128.242.127.2")));

        assertFalse(rang.isIPAddressInRange(new IPAddress("128.242.126.2")));
       
        rang.toString();
    }
View Full Code Here

       
        rang.toString();
    }

    public void test_ipRange_1() throws Exception {
        IPRange rang = new IPRange("128.242.127.0/30");

        assertEquals("128.242.127.0", rang.getIPAddress().toString());
        assertEquals("255.255.255.252", rang.getIPSubnetMask().toString());

        assertTrue(rang.isIPAddressInRange(new IPAddress("128.242.127.0")));
        assertTrue(rang.isIPAddressInRange(new IPAddress("128.242.127.1")));
        assertTrue(rang.isIPAddressInRange(new IPAddress("128.242.127.2")));
        assertTrue(rang.isIPAddressInRange(new IPAddress("128.242.127.3")));

        assertFalse(rang.isIPAddressInRange(new IPAddress("128.242.127.4")));

    }
View Full Code Here

        assertFalse(rang.isIPAddressInRange(new IPAddress("128.242.127.4")));

    }

    public void test_ipRange_2() throws Exception {
        IPRange rang = new IPRange("10.16.200.0/24");

        assertTrue(rang.isIPAddressInRange(new IPAddress("10.16.200.0")));
        assertTrue(rang.isIPAddressInRange(new IPAddress("10.16.200.255")));

    }
View Full Code Here

        assertTrue(rang.isIPAddressInRange(new IPAddress("10.16.200.255")));

    }

    public void test_ipRange_3() throws Exception {
        IPRange rang = new IPRange("0.0.0.0/0");
        assertTrue(rang.isIPAddressInRange(new IPAddress("2.16.200.0")));

    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.support.http.util.IPRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.