forked from I2P_Developers/i2p.i2p
Util: Add AddressType enum
This commit is contained in:
8
core/java/src/net/i2p/util/AddressType.java
Normal file
8
core/java/src/net/i2p/util/AddressType.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package net.i2p.util;
|
||||
|
||||
/**
|
||||
* @since 0.9.54
|
||||
*/
|
||||
public enum AddressType {
|
||||
IPV4, IPV6, YGG
|
||||
}
|
||||
@@ -54,6 +54,26 @@ public abstract class Addresses {
|
||||
private static final Set<String> _macCache = new HashSet<String>();
|
||||
private static final boolean TEST_IPV6_ONLY = false;
|
||||
|
||||
/**
|
||||
* Do we have any address of this type?
|
||||
* Warning, very slow on Windows, appx. 200ms + 50ms/interface
|
||||
*
|
||||
* @since 0.9.54
|
||||
*/
|
||||
public static boolean isConnected(AddressType type) {
|
||||
switch(type) {
|
||||
case IPV6:
|
||||
return isConnectedIPv6();
|
||||
|
||||
case YGG:
|
||||
return getYggdrasilAddress() != null;
|
||||
|
||||
case IPV4:
|
||||
default:
|
||||
return isConnected();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Do we have any non-loop, non-wildcard IPv4 address at all?
|
||||
* Warning, very slow on Windows, appx. 200ms + 50ms/interface
|
||||
@@ -266,7 +286,7 @@ public abstract class Addresses {
|
||||
/**
|
||||
* Warning, very slow on Windows. Caller should cache.
|
||||
*
|
||||
* @return the IPv6 address with prefix 02xx: or 03xx:
|
||||
* @return the IPv6 address with prefix 02xx: or 03xx:, or null
|
||||
* @since 0.9.49
|
||||
*/
|
||||
public static byte[] getYggdrasilAddress() {
|
||||
|
||||
Reference in New Issue
Block a user