List of usage examples for java.net NetworkInterface getDisplayName
public String getDisplayName()
From source file:com.vuze.plugin.azVPN_PIA.Checker.java
/** * @return rebind sucessful, or rebinding to already bound address *///from w w w. ja va 2s. c o m private boolean rebindNetworkInterface(NetworkInterface networkInterface, InetAddress onlyToAddress, final StringBuilder sReply) { vpnIP = onlyToAddress; /** if (true) { sReply.append("Would rebind to " + networkInterface.getDisplayName() + onlyToAddress + "\n"); return false; } /**/ String ifName = networkInterface.getName(); String configBindIP = config.getCoreStringParameter(PluginConfig.CORE_PARAM_STRING_LOCAL_BIND_IP); int bindNetworkInterfaceIndex = -1; if (onlyToAddress != null) { Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses(); for (int j = 0; inetAddresses.hasMoreElements(); j++) { InetAddress element = inetAddresses.nextElement(); if (element.equals(onlyToAddress)) { bindNetworkInterfaceIndex = j; break; } } } if (configBindIP.equals(ifName) || (bindNetworkInterfaceIndex >= 0 && configBindIP.equals(ifName + "[" + bindNetworkInterfaceIndex + "]"))) { addReply(sReply, CHAR_GOOD, "pia.already.bound.good", new String[] { ifName }); } else { String newConfigBindIP = ifName; if (bindNetworkInterfaceIndex >= 0) { newConfigBindIP += "[" + bindNetworkInterfaceIndex + "]"; } final AESemaphore sem = new AESemaphore("PIA BindWait"); NetworkAdmin.getSingleton().addPropertyChangeListener(new NetworkAdminPropertyChangeListener() { public void propertyChanged(String property) { if (property.equals(NetworkAdmin.PR_DEFAULT_BIND_ADDRESS)) { sem.releaseForever(); NetworkAdmin.getSingleton().removePropertyChangeListener(this); addReply(sReply, CHAR_GOOD, "pia.bind.complete.triggered"); } } }); // I think setting CORE_PARAM_STRING_LOCAL_BIND_IP is actually synchronous // We set up a PropertyChangeListener in case it ever becomes asynchronous config.setCoreStringParameter(PluginConfig.CORE_PARAM_STRING_LOCAL_BIND_IP, newConfigBindIP); config.setUnsafeBooleanParameter("Enforce Bind IP", true); config.setUnsafeBooleanParameter("Check Bind IP On Start", true); config.setUnsafeBooleanParameter("upnp.enable", false); config.setUnsafeBooleanParameter("natpmp.enable", false); addReply(sReply, CHAR_GOOD, "pia.change.binding", new String[] { "" + newConfigBindIP, networkInterface.getName() + " (" + networkInterface.getDisplayName() + ")" }); sem.reserve(11000); return sem.isReleasedForever(); } return true; }
From source file:com.vuze.plugin.azVPN_Helper.CheckerCommon.java
/** * @return rebind sucessful, or rebinding to already bound address *//*from w w w . jav a2 s.co m*/ private final boolean rebindNetworkInterface(NetworkInterface networkInterface, InetAddress onlyToAddress, final StringBuilder sReply) { vpnIP = onlyToAddress; config.setUnsafeBooleanParameter("Enforce Bind IP", true); config.setUnsafeBooleanParameter("Check Bind IP On Start", true); config.setUnsafeBooleanParameter("Plugin.UPnP.upnp.enable", false); config.setUnsafeBooleanParameter("Plugin.UPnP.natpmp.enable", false); /** if (true) { sReply.append("Would rebind to " + networkInterface.getDisplayName() + onlyToAddress + "\n"); return false; } /**/ String ifName = networkInterface.getName(); String configBindIP = config.getCoreStringParameter(PluginConfig.CORE_PARAM_STRING_LOCAL_BIND_IP); int bindNetworkInterfaceIndex = -1; if (onlyToAddress != null) { Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses(); for (int j = 0; inetAddresses.hasMoreElements(); j++) { InetAddress element = inetAddresses.nextElement(); if (element.equals(onlyToAddress)) { bindNetworkInterfaceIndex = j; break; } } } if (configBindIP.equals(ifName) || (bindNetworkInterfaceIndex >= 0 && configBindIP.equals(ifName + "[" + bindNetworkInterfaceIndex + "]"))) { addReply(sReply, CHAR_GOOD, "vpnhelper.already.bound.good", new String[] { ifName }); } else { String newConfigBindIP = ifName; if (bindNetworkInterfaceIndex >= 0) { newConfigBindIP += "[" + bindNetworkInterfaceIndex + "]"; } final AESemaphore sem = new AESemaphore("VPNHelper BindWait"); NetworkAdmin.getSingleton().addPropertyChangeListener(new NetworkAdminPropertyChangeListener() { public void propertyChanged(String property) { if (property.equals(NetworkAdmin.PR_DEFAULT_BIND_ADDRESS)) { sem.releaseForever(); NetworkAdmin.getSingleton().removePropertyChangeListener(this); addReply(sReply, CHAR_GOOD, "vpnhelper.bind.complete.triggered"); } } }); // I think setting CORE_PARAM_STRING_LOCAL_BIND_IP is actually synchronous // We set up a PropertyChangeListener in case it ever becomes asynchronous config.setCoreStringParameter(PluginConfig.CORE_PARAM_STRING_LOCAL_BIND_IP, newConfigBindIP); addReply(sReply, CHAR_GOOD, "vpnhelper.change.binding", new String[] { "" + newConfigBindIP, networkInterface == null ? "null" : networkInterface.getName() + " (" + networkInterface.getDisplayName() + ")" }); sem.reserve(11000); return sem.isReleasedForever(); } return true; }
From source file:com.vuze.plugin.azVPN_Air.Checker.java
/** * @return rebind sucessful, or rebinding to already bound address *///from www . j av a 2 s. c o m private boolean rebindNetworkInterface(NetworkInterface networkInterface, InetAddress onlyToAddress, final StringBuilder sReply) { vpnIP = onlyToAddress; /** if (true) { sReply.append("Would rebind to " + networkInterface.getDisplayName() + onlyToAddress + "\n"); return false; } /**/ String ifName = networkInterface.getName(); String configBindIP = config.getCoreStringParameter(PluginConfig.CORE_PARAM_STRING_LOCAL_BIND_IP); int bindNetworkInterfaceIndex = -1; if (onlyToAddress != null) { Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses(); for (int j = 0; inetAddresses.hasMoreElements(); j++) { InetAddress element = inetAddresses.nextElement(); if (element.equals(onlyToAddress)) { bindNetworkInterfaceIndex = j; break; } } } if (configBindIP.equals(ifName) || (bindNetworkInterfaceIndex >= 0 && configBindIP.equals(ifName + "[" + bindNetworkInterfaceIndex + "]"))) { addReply(sReply, CHAR_GOOD, "airvpn.already.bound.good", new String[] { ifName }); } else { String newConfigBindIP = ifName; if (bindNetworkInterfaceIndex >= 0) { newConfigBindIP += "[" + bindNetworkInterfaceIndex + "]"; } final AESemaphore sem = new AESemaphore("AirVPN BindWait"); NetworkAdmin.getSingleton().addPropertyChangeListener(new NetworkAdminPropertyChangeListener() { public void propertyChanged(String property) { if (property.equals(NetworkAdmin.PR_DEFAULT_BIND_ADDRESS)) { sem.releaseForever(); NetworkAdmin.getSingleton().removePropertyChangeListener(this); addReply(sReply, CHAR_GOOD, "airvpn.bind.complete.triggered"); } } }); // I think setting CORE_PARAM_STRING_LOCAL_BIND_IP is actually synchronous // We set up a PropertyChangeListener in case it ever becomes asynchronous config.setCoreStringParameter(PluginConfig.CORE_PARAM_STRING_LOCAL_BIND_IP, newConfigBindIP); config.setUnsafeBooleanParameter("Enforce Bind IP", true); config.setUnsafeBooleanParameter("Check Bind IP On Start", true); config.setUnsafeBooleanParameter("upnp.enable", false); config.setUnsafeBooleanParameter("natpmp.enable", false); addReply(sReply, CHAR_GOOD, "airvpn.change.binding", new String[] { "" + newConfigBindIP, networkInterface.getName() + " (" + networkInterface.getDisplayName() + ")" }); sem.reserve(11000); return sem.isReleasedForever(); } return true; }
From source file:net.fenyo.gnetwatch.GUI.GUI.java
private void appendNetworkInterfaces() { try {//from w w w. j a v a2s .c o m // should be localized String str = "<HR/><B>Local network interfaces</B>"; str += "<TABLE BORDER='0' BGCOLOR='black' cellspacing='1' cellpadding='1'>"; for (final Enumeration nifs = NetworkInterface.getNetworkInterfaces(); nifs.hasMoreElements();) { final NetworkInterface nif = (NetworkInterface) nifs.nextElement(); str += "<TR><TD bgcolor='lightyellow' align='right'><B>" + htmlFace("interface name") + "</B></TD><TD bgcolor='lightyellow'><B>" + htmlFace(nif.getName()) + "</B></TD></TR>"; str += "<TR><TD bgcolor='lightyellow' align='right'>" + htmlFace("display name") + "</TD><TD bgcolor='lightyellow'>" + htmlFace(nif.getDisplayName()) + "</TD></TR>"; for (final Enumeration addrs = nif.getInetAddresses(); addrs.hasMoreElements();) { final InetAddress addr = (InetAddress) addrs.nextElement(); if (Inet4Address.class.isInstance(addr)) str += "<TR><TD bgcolor='lightyellow' align='right'>" + htmlFace("IPv4 address") + "</TD><TD bgcolor='lightyellow'>" + htmlFace(addr.getHostAddress()) + "</TD></TR>"; if (Inet6Address.class.isInstance(addr)) str += "<TR><TD bgcolor='lightyellow' align='right'>" + htmlFace("IPv6 address") + "</TD><TD bgcolor='lightyellow'>" + htmlFace(addr.getHostAddress()) + "</TD></TR>"; } } str += "</TABLE>"; appendConsole(str); } catch (final SocketException ex) { log.error("Exception", ex); } }