Beispiel #1
0
    public boolean matchInetNetwork(final InetAddress ip) {
        boolean sameNet = false;

        for (Iterator iter = networks.iterator(); (!sameNet) && iter.hasNext();) {
            InetNetwork network = (InetNetwork) iter.next();
            sameNet = network.contains(ip);
        }
        return sameNet;
    }
Beispiel #2
0
    public boolean matchInetNetwork(final String hostIP) {
        InetAddress ip = null;

        try {
            ip = InetAddress.getByName(hostIP);
        } catch (java.net.UnknownHostException uhe) {
            log("Cannot resolve address for " + hostIP + ": " + uhe.getMessage());
        }

        boolean sameNet = false;

        if (ip != null) for (Iterator iter = networks.iterator(); (!sameNet) && iter.hasNext();) {
            InetNetwork network = (InetNetwork) iter.next();
            sameNet = network.contains(ip);
        }
        return sameNet;
    }
Beispiel #3
0
 public void initInetNetworks(final String[] nets) {
     networks = new ArrayList<InetNetwork>();
     for (int i = 0; i < nets.length; i++)
         try {
             InetNetwork net = InetNetwork.getFromString(nets[i]);
             if (!networks.contains(net)) networks.add(net);
         } catch (java.net.UnknownHostException uhe) {
             log("Cannot resolve address: " + uhe.getMessage());
         }
     networks.trimToSize();
 }
Beispiel #4
0
 public void initInetNetworks(final Collection<String> nets) {
     networks = new ArrayList<InetNetwork>();
     for (final String netName : nets)
         try {
             InetNetwork net = InetNetwork.getFromString(netName);
             if (!networks.contains(net)) networks.add(net);
         } catch (java.net.UnknownHostException uhe) {
             log("Cannot resolve address: " + uhe.getMessage());
         }
     networks.trimToSize();
 }