if (networkInterfacesAll == null || networkInterfacesAll.length == 0) {
throw new RuntimeException("No network interfaces found");
}
selectNICComboBox = new JComboBox();
NetworkInterface tunnelInterface = null;
for (NetworkInterface intf : networkInterfacesAll) {
if (!ON_WINDOWS && intf.name.equals("lo")) {
loopbackInterface = intf;
}
if ((intf.name != null && intf.name.equals("tap0")) ||
(intf.description != null && intf.description.contains("VMware Virtual Ethernet Adapter"))) {
tunnelInterface = intf;
}
selectNICComboBox.addItem(intf.description + " (" + intf.name + ")");
}
selectNICComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() != ItemEvent.SELECTED) {
return;
}
/* Detect selected network interface */
String descr = (String) ((JComboBox)e.getSource()).getSelectedItem();
NetworkInterface selected = null;
for (NetworkInterface networkInterface2 : networkInterfacesAll) {
String label = networkInterface2.description + " (" + networkInterface2.name + ")";
if (label.equals(descr)) {
selected = networkInterface2;
break;