Example usage for java.net NetworkInterface getName

List of usage examples for java.net NetworkInterface getName

Introduction

In this page you can find the example usage for java.net NetworkInterface getName.

Prototype

public String getName() 

Source Link

Document

Get the name of this network interface.

Usage

From source file:com.marcosdiez.server.php.service.Network.java

public Network() {
    names = new LinkedList<String>();
    titles = new LinkedList<String>();
    adresses = new LinkedList<String>();
    try {//from  w w w . j  av a 2 s  .  co m
        List<NetworkInterface> list = Collections.list(NetworkInterface.getNetworkInterfaces());
        for (NetworkInterface iface : list) {
            List<InetAddress> addresses = Collections.list(iface.getInetAddresses());
            for (InetAddress address : addresses) {
                if (!address.isLoopbackAddress()) {
                    String host = address.getHostAddress().toUpperCase();
                    if (InetAddressUtils.isIPv4Address(host)) {
                        names.add(iface.getName());
                        titles.add(host + "(" + iface.getDisplayName() + ")");
                        adresses.add(host);
                    }
                }
            }
        }
        for (NetworkInterface iface : list) {
            List<InetAddress> addresses = Collections.list(iface.getInetAddresses());
            for (InetAddress address : addresses) {
                if (address.isLoopbackAddress()) {
                    String host = address.getHostAddress().toUpperCase();
                    if (InetAddressUtils.isIPv4Address(host)) {
                        names.add(iface.getName());
                        titles.add(host + "(" + iface.getDisplayName() + ")");
                        adresses.add(host);
                    }
                }
            }
        }
    } catch (Exception ex) {
    }
    names.add("all");
    adresses.add("0.0.0.0");
    titles.add("0.0.0.0 (all)");
}

From source file:nl.eduvpn.app.service.VPNService.java

/**
 * Retrieves the IP4 and IPv6 addresses assigned by the VPN server to this client using a network interface lookup.
 *
 * @return The IPv4 and IPv6 addresses in this order as a pair. If not found, a null value is returned instead.
 *///from   www.j  a v a 2 s  .co  m
private Pair<String, String> _lookupVpnIpAddresses() {
    try {
        List<NetworkInterface> networkInterfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
        for (NetworkInterface networkInterface : networkInterfaces) {
            if (VPN_INTERFACE_NAME.equals(networkInterface.getName())) {
                List<InetAddress> addresses = Collections.list(networkInterface.getInetAddresses());
                String ipV4 = null;
                String ipV6 = null;
                for (InetAddress address : addresses) {
                    String ip = address.getHostAddress();
                    boolean isIPv4 = ip.indexOf(':') < 0;
                    if (isIPv4) {
                        ipV4 = ip;
                    } else {
                        int delimiter = ip.indexOf('%');
                        ipV6 = delimiter < 0 ? ip.toLowerCase() : ip.substring(0, delimiter).toLowerCase();
                    }
                }
                if (ipV4 != null || ipV6 != null) {
                    return new Pair<>(ipV4, ipV6);
                } else {
                    return null;
                }
            }
        }
    } catch (SocketException ex) {
        Log.w(TAG, "Unable to retrieve network interface info!", ex);
    }
    return null;
}

From source file:com.seleuco.mame4droid.NetPlay.java

public String getIPAddress() {
    try {//www .  j a  v  a  2s .  co m
        Enumeration<NetworkInterface> ifaceList;
        NetworkInterface selectedIface = null;

        // First look for a WLAN interface
        ifaceList = NetworkInterface.getNetworkInterfaces();
        while (selectedIface == null && ifaceList.hasMoreElements()) {
            NetworkInterface intf = ifaceList.nextElement();
            if (intf.getName().startsWith("wlan")) {
                List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
                for (InetAddress addr : addrs) {
                    if (!addr.isLoopbackAddress()) {
                        String sAddr = addr.getHostAddress().toUpperCase();
                        boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
                        if (isIPv4)
                            return sAddr;
                    }
                }
            }
        }

        // If we didn't find that, look for an Ethernet interface
        ifaceList = NetworkInterface.getNetworkInterfaces();
        while (selectedIface == null && ifaceList.hasMoreElements()) {
            NetworkInterface intf = ifaceList.nextElement();
            if (intf.getName().startsWith("eth")) {
                List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
                for (InetAddress addr : addrs) {
                    if (!addr.isLoopbackAddress()) {
                        String sAddr = addr.getHostAddress().toUpperCase();
                        boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
                        if (isIPv4)
                            return sAddr;
                    }
                }
            }
        }

        List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
        for (NetworkInterface intf : interfaces) {
            List<InetAddress> addrs = Collections.list(intf.getInetAddresses());
            for (InetAddress addr : addrs) {
                if (!addr.isLoopbackAddress()) {
                    String sAddr = addr.getHostAddress().toUpperCase();
                    boolean isIPv4 = InetAddressUtils.isIPv4Address(sAddr);
                    if (isIPv4)
                        return sAddr;
                }
            }
        }
    } catch (Exception ex) {
    }
    return null;
}

From source file:org.kei.android.phone.netcap.OutputFragment.java

@Override
public void onClick(final View v) {
    if (v.equals(refreshBT)) {
        adapter.clear();/*from  w  w w . j a va  2  s. co m*/
        try {
            final List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
            if (interfaces != null && interfaces.size() != 0)
                adapter.add(getResources().getText(R.string.any).toString());
            for (final NetworkInterface ni : interfaces)
                if (ni.isUp())
                    adapter.add(ni.getName());
        } catch (final Throwable e) {
            logException(e);
        }
    } else if (v.equals(browseOutputCaptureTV)) {
        final Map<String, String> extra = new HashMap<String, String>();
        extra.put(FileChooser.FILECHOOSER_TYPE_KEY, "" + FileChooser.FILECHOOSER_TYPE_DIRECTORY_ONLY);
        extra.put(FileChooser.FILECHOOSER_TITLE_KEY, "Save");
        extra.put(FileChooser.FILECHOOSER_MESSAGE_KEY, "Use this folder:? ");
        extra.put(FileChooser.FILECHOOSER_DEFAULT_DIR, browseOutputCaptureTV.getText().toString());
        extra.put(FileChooser.FILECHOOSER_SHOW_KEY, "" + FileChooser.FILECHOOSER_SHOW_DIRECTORY_ONLY);
        extra.put(FileChooser.FILECHOOSER_USER_MESSAGE, getClass().getSimpleName());
        Tools.switchToForResult(owner, FileChooserActivity.class, extra,
                FileChooserActivity.FILECHOOSER_SELECTION_TYPE_DIRECTORY);

    } else if (v.equals(captureBT)) {
        if (!captureBT.isChecked()) {
            captureBT.setChecked(true);
            delete();
        } else {
            String sdest = browseOutputCaptureTV.getText().toString();
            if (sdest.isEmpty()) {
                Tools.showAlertDialog(owner, "Error", "Empty destination folder!");
                captureBT.setChecked(false);
                return;
            }

            File legacy = new File(sdest.replaceFirst("emulated/([0-9]+)/", "emulated/legacy/"));
            File fdest = new File(sdest);
            Log.i(getClass().getSimpleName(), "Test directory '" + legacy + "'");
            if (legacy.isDirectory())
                fdest = legacy;
            if (!fdest.isDirectory()) {
                Tools.showAlertDialog(owner, "Error", "The destination folder is not a valid directory!");
                captureBT.setChecked(false);
                return;
            } else if (!fdest.canWrite()) {
                Tools.showAlertDialog(owner, "Error", "Unable to write into the destination folder!");
                captureBT.setChecked(false);
                return;
            }

            if (!RootTools.isAccessGiven()) {
                Resources r = getResources();
                Tools.toast(owner, R.drawable.ic_launcher, r.getString(R.string.root_toast_error));
                showResult.setText(" " + r.getString(R.string.root_error));
                captureBT.setChecked(false);
                return;
            }

            final PackageManager m = owner.getPackageManager();
            String s = owner.getPackageName();
            try {
                final PackageInfo p = m.getPackageInfo(s, 0);
                s = p.applicationInfo.dataDir;
            } catch (final PackageManager.NameNotFoundException e) {
            }
            s = s + "/netcap";
            copyFile(Build.SUPPORTED_ABIS[0] + "/netcap", s, owner);
            final File netcap = new File(s);
            if (!netcap.exists()) {
                Tools.showAlertDialog(owner, "Error",
                        "'netcap' for '" + Build.SUPPORTED_ABIS[0] + "' was not found!");
                return;
            }
            pname = netcap.getAbsolutePath();
            netcap.setExecutable(true);

            ifaces = "";
            String ni = (String) devicesSp.getSelectedItem();
            if (ni.equals(getResources().getText(R.string.any).toString())) {
                for (int i = 0; i < adapter.getCount(); i++) {
                    ni = adapter.getItem(i);
                    if (ni.equals(getResources().getText(R.string.any).toString()))
                        continue;
                    ifaces += ni;
                    if (i < adapter.getCount() - 1)
                        ifaces += ",";
                }
            } else
                ifaces = ni;

            final File outputFile = new File(fdest,
                    new SimpleDateFormat("yyyyMMdd_hhmmssa'_netcap.pcap'", Locale.US).format(new Date()));
            buffer.clear();
            new Thread(new Runnable() {
                public void run() {
                    try {
                        String cmd = netcap.getAbsolutePath() + " -i " + ifaces + " -f "
                                + outputFile.getAbsolutePath() + " -d";
                        if (promiscuousCB.isChecked())
                            cmd += " -p";
                        cmd += " 2>&1";
                        command = new Command(0, cmd) {
                            @Override
                            public void commandOutput(int id, String line) {
                                super.commandOutput(id, line);
                                if (line.startsWith(NETCAP_READY))
                                    pid = line.substring(NETCAP_READY.length());
                                buffer.add(line);
                                owner.runOnUiThread(new Runnable() {
                                    @SuppressWarnings("unchecked")
                                    @Override
                                    public void run() {
                                        final String[] lines = (String[]) buffer.toArray(new String[] {});
                                        final StringBuilder sb = new StringBuilder();
                                        for (final String s : lines)
                                            sb.append(" ").append(s).append("\n");
                                        showResult.setText(sb.toString());
                                    }
                                });
                            }

                            public void commandCompleted(int id, int exitcode) {
                                super.commandCompleted(id, exitcode);
                                owner.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        captureBT.setChecked(false);
                                    }
                                });
                            }

                            public void commandTerminated(int id, String reason) {
                                super.commandTerminated(id, reason);
                            }
                        };
                        RootTools.getShell(true).add(command);
                    } catch (final Exception e) {
                        logException(e);
                    }
                }
            }).start();
        }
    }
}

From source file:info.pancancer.arch3.worker.WorkerRunnable.java

/**
 * Get the IP address of this machine, preference is given to returning an IPv4 address, if there is one.
 *
 * @return An InetAddress object./*from  w w  w. j a v a  2  s  .  co m*/
 * @throws SocketException
 */
public InetAddress getFirstNonLoopbackAddress() throws SocketException {
    final String dockerInterfaceName = "docker";
    for (NetworkInterface i : Collections.list(NetworkInterface.getNetworkInterfaces())) {
        if (i.getName().contains(dockerInterfaceName)) {
            // the virtual ip address for the docker mount is useless but is not a loopback address
            continue;
        }
        log.info("Examining " + i.getName());
        for (InetAddress addr : Collections.list(i.getInetAddresses())) {
            if (!addr.isLoopbackAddress()) {
                // Prefer IP v4
                if (addr instanceof Inet4Address) {
                    return addr;
                }
            }

        }
    }
    Log.info("Could not find an ipv4 address");
    for (NetworkInterface i : Collections.list(NetworkInterface.getNetworkInterfaces())) {
        log.info("Examining " + i.getName());
        if (i.getName().contains(dockerInterfaceName)) {
            // the virtual ip address for the docker mount is useless but is not a loopback address
            continue;
        }
        // If we got here it means we never found an IP v4 address, so we'll have to return the IPv6 address.
        for (InetAddress addr : Collections.list(i.getInetAddresses())) {
            // InetAddress addr = (InetAddress) en2.nextElement();
            if (!addr.isLoopbackAddress()) {
                return addr;
            }
        }
    }
    return null;
}

From source file:com.poinsart.votar.VotarMain.java

public String getWifiIp() {
    Enumeration<NetworkInterface> en = null;
    try {/*from w ww  .  j a  v a  2  s . co  m*/
        en = NetworkInterface.getNetworkInterfaces();
    } catch (SocketException e) {
        return null;
    }
    while (en.hasMoreElements()) {
        NetworkInterface intf = en.nextElement();
        if (intf.getName().contains("wlan")) {
            for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
                InetAddress inetAddress = enumIpAddr.nextElement();
                if (!inetAddress.isLoopbackAddress() && (inetAddress.getAddress().length == 4)) {
                    //Log.d("VotAR Main", inetAddress.getHostAddress());
                    return inetAddress.getHostAddress().toString();
                }
            }
        }
    }
    return null;
}

From source file:com.scottieknows.test.cassandra.CassandraClusterManager.java

/**
 * @return {@link Map} of interface name to address
 *//*from   w  w  w  . java2  s .  co m*/
Map<String, String> getIpsStartingWith(String prefix) {
    if (prefix == null) {
        return Collections.emptyMap();
    }
    try {
        Map<String, String> rtn = new HashMap<>();
        Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
        while (networkInterfaces.hasMoreElements()) {
            NetworkInterface i = networkInterfaces.nextElement();
            Enumeration<InetAddress> addrs = i.getInetAddresses();
            while (addrs.hasMoreElements()) {
                InetAddress addr = addrs.nextElement();
                String hostAddress = addr.getHostAddress();
                if (hostAddress.startsWith(prefix)) {
                    rtn.put(i.getName(), hostAddress);
                }
            }
        }
        return rtn;
    } catch (SocketException e) {
        throw new RuntimeException("could not retrieve network interfaces: " + e, e);
    }
}

From source file:com.sentaroh.android.SMBSync2.CommonUtilities.java

public static String getLocalIpAddress() {
    String result = "";
    boolean exit = false;
    try {/*w ww .  jav  a  2 s . co m*/
        for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en
                .hasMoreElements();) {
            NetworkInterface intf = en.nextElement();
            for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
                InetAddress inetAddress = enumIpAddr.nextElement();
                //                   if (!inetAddress.isLoopbackAddress() && !(inetAddress.toString().indexOf(":")>=0)) {
                //                       return inetAddress.getHostAddress().toString();
                //                   }
                //                  Log.v("","ip="+inetAddress.getHostAddress()+
                //                        ", name="+intf.getName());
                if (inetAddress.isSiteLocalAddress()) {
                    result = inetAddress.getHostAddress();
                    //                       Log.v("","result="+result+", name="+intf.getName()+"-");
                    if (intf.getName().equals("wlan0")) {
                        exit = true;
                        break;
                    }
                }
            }
            if (exit)
                break;
        }
    } catch (SocketException ex) {
        Log.e(APPLICATION_TAG, ex.toString());
        result = "192.168.0.1";
    }
    //      Log.v("","getLocalIpAddress result="+result);
    if (result.equals(""))
        result = "192.168.0.1";
    return result;
}

From source file:ch.cyberduck.core.socket.NetworkInterfaceAwareSocketFactory.java

private NetworkInterface findIPv6Interface(Inet6Address address) throws IOException {
    if (blacklisted.isEmpty()) {
        if (log.isDebugEnabled()) {
            log.debug("Ignore IP6 default network interface setup with empty blacklist");
        }/* w w  w . j  av  a2  s .  c  o m*/
        return null;
    }
    if (address.getScopeId() != 0) {
        if (log.isDebugEnabled()) {
            log.debug(String.format(
                    "Ignore IP6 default network interface setup for address with scope identifier %d",
                    address.getScopeId()));
        }
        return null;
    }
    // If we find an interface name en0 that supports IPv6 make it the default.
    // We must use the index of the network interface. Referencing the interface by name will still
    // set the scope id to '0' referencing the awdl0 interface that is first in the list of enumerated
    // network interfaces instead of its correct index in <code>java.net.Inet6Address</code>
    // Use private API to defer the numeric format for the address
    List<Integer> indexes = new ArrayList<Integer>();
    final Enumeration<NetworkInterface> enumeration = NetworkInterface.getNetworkInterfaces();
    while (enumeration.hasMoreElements()) {
        indexes.add(enumeration.nextElement().getIndex());
    }
    for (Integer index : indexes) {
        final NetworkInterface n = NetworkInterface.getByIndex(index);
        if (log.isDebugEnabled()) {
            log.debug(String.format("Evaluate interface with %s index %d", n, index));
        }
        if (!n.isUp()) {
            if (log.isDebugEnabled()) {
                log.debug(String.format("Ignore interface %s not up", n));
            }
            continue;
        }
        if (blacklisted.contains(n.getName())) {
            log.warn(String.format("Ignore network interface %s disabled with blacklist", n));
            continue;
        }
        for (InterfaceAddress i : n.getInterfaceAddresses()) {
            if (i.getAddress() instanceof Inet6Address) {
                if (log.isInfoEnabled()) {
                    log.info(String.format("Selected network interface %s", n));
                }
                return n;
            }
        }
        log.warn(String.format("No IPv6 for interface %s", n));
    }
    log.warn("No network interface found for IPv6");
    return null;
}

From source file:net.pms.newgui.NetworkTab.java

public JComponent build() {
    FormLayout layout = new FormLayout("left:pref, 2dlu, p, 2dlu , p, 2dlu, p, 2dlu, pref:grow",
            "p, 0dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, p, 15dlu, p, 3dlu,p, 3dlu, p,  3dlu, p, 3dlu, p, 3dlu, p,3dlu, p, 3dlu, p, 15dlu, p,3dlu, p, 3dlu, p, 15dlu, p, 3dlu, p");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.DLU4_BORDER);
    builder.setOpaque(true);/*from   ww  w  .  j  av  a 2 s .com*/

    CellConstraints cc = new CellConstraints();

    smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3"));
    smcheckBox.setContentAreaFilled(false);
    smcheckBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setMinimized((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    if (PMS.getConfiguration().isMinimized()) {
        smcheckBox.setSelected(true);
    }

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(Messages.getString("NetworkTab.0"), cc.xy(1, 7));
    final KeyedComboBoxModel kcbm = new KeyedComboBoxModel(
            new Object[] { "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "is", "it",
                    "ja", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv" },
            new Object[] { "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)", "Czech",
                    "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Icelandic",
                    "Italian", "Japanese", "Norwegian", "Polish", "Portuguese", "Portuguese (Brazilian)",
                    "Romanian", "Russian", "Slovenian", "Spanish", "Swedish" });
    langs = new JComboBox(kcbm);
    langs.setEditable(false);
    //langs.setSelectedIndex(0);
    String defaultLang = null;
    if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) {
        defaultLang = configuration.getLanguage();
    } else {
        defaultLang = Locale.getDefault().getLanguage();
    }
    if (defaultLang == null) {
        defaultLang = "en";
    }
    kcbm.setSelectedKey(defaultLang);
    if (langs.getSelectedIndex() == -1) {
        langs.setSelectedIndex(0);
    }

    langs.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setLanguage((String) kcbm.getSelectedKey());

            }
        }
    });
    builder.add(langs, cc.xyw(3, 7, 7));

    builder.add(smcheckBox, cc.xyw(1, 9, 9));

    JButton service = new JButton(Messages.getString("NetworkTab.4"));
    service.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (PMS.get().installWin32Service()) {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"),
                        "Information", JOptionPane.INFORMATION_MESSAGE);

            } else {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.14"), "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    builder.add(service, cc.xy(1, 11));
    if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) {
        service.setEnabled(false);
    }

    host = new JTextField(PMS.getConfiguration().getServerHostname());
    host.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setHostname(host.getText());
            PMS.get().getFrame().setReloadable(true);
        }
    });
    // host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ;
    port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : "");
    port.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            try {
                String p = port.getText();
                if (StringUtils.isEmpty(p)) {
                    p = "5001";
                }
                int ab = Integer.parseInt(p);
                configuration.setServerPort(ab);
                PMS.get().getFrame().setReloadable(true);
            } catch (NumberFormatException nfe) {
            }

        }
    });

    cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), cc.xyw(1, 21, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    ArrayList<String> names = new ArrayList<String>();
    names.add("");
    ArrayList<String> interfaces = new ArrayList<String>();
    interfaces.add("");
    Enumeration<NetworkInterface> enm;
    try {
        enm = NetworkInterface.getNetworkInterfaces();
        while (enm.hasMoreElements()) {
            NetworkInterface ni = enm.nextElement();
            // check for interface has at least one ip address.
            if (ni.getInetAddresses().hasMoreElements()) {
                names.add(ni.getName());
                String displayName = ni.getDisplayName();
                if (displayName == null) {
                    displayName = ni.getName();
                }
                interfaces.add(displayName.trim());
            }
        }
    } catch (SocketException e1) {
        logger.error(null, e1);
    }

    final KeyedComboBoxModel networkInterfaces = new KeyedComboBoxModel(names.toArray(), interfaces.toArray());
    networkinterfacesCBX = new JComboBox(networkInterfaces);
    networkInterfaces.setSelectedKey(configuration.getNetworkInterface());
    networkinterfacesCBX.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey());
                //host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ;
                PMS.get().getFrame().setReloadable(true);
            }
        }
    });

    ip_filter = new JTextField(PMS.getConfiguration().getIpFilter());
    ip_filter.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setIpFilter(ip_filter.getText());
            PMS.get().getFrame().setReloadable(true);
        }
    });

    builder.addLabel(Messages.getString("NetworkTab.20"), cc.xy(1, 23));
    builder.add(networkinterfacesCBX, cc.xyw(3, 23, 7));
    builder.addLabel(Messages.getString("NetworkTab.23"), cc.xy(1, 25));
    builder.add(host, cc.xyw(3, 25, 7));
    builder.addLabel(Messages.getString("NetworkTab.24"), cc.xy(1, 27));
    builder.add(port, cc.xyw(3, 27, 7));
    builder.addLabel(Messages.getString("NetworkTab.30"), cc.xy(1, 29));
    builder.add(ip_filter, cc.xyw(3, 29, 7));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.31"), cc.xyw(1, 31, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32"));
    newHTTPEngine.setSelected(PMS.getConfiguration().isHTTPEngineV2());
    newHTTPEngine.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(newHTTPEngine, cc.xyw(1, 33, 9));

    preventSleep = new JCheckBox(Messages.getString("NetworkTab.33"));
    preventSleep.setSelected(PMS.getConfiguration().isPreventsSleep());
    preventSleep.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(preventSleep, cc.xyw(1, 35, 9));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.34"), cc.xyw(1, 37, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    JPanel panel = builder.getPanel();
    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    return scrollPane;
}