类 InternetAddressUtil
java.lang.Object
com.alibaba.nacos.common.utils.InternetAddressUtil
ip tool.
- 作者:
- Nacos
-
字段概要
字段 -
方法概要
修饰符和类型方法说明static intbytesToInt(byte[] bytes) convert byte array to int.static StringCheck ips.static booleanCheck whether checkIps result is "ok".static booleancontainsPort(String address) Check if the address contains a port. 2020/9/3 14:53static StringgetIpFromString(String str) Resolve the IP from the string containing the IP address.static byte[]convert ip address to byte array.static intconvert ip address to int.static booleanjudge str is right domain.static booleancheck whether the str is ip address (IPv4 or IPv6).static booleancheck whether the ip address is IPv4.static booleancheck whether the ip address is IPv6.static Stringget localhost ip.static StringremoveBrackets(String str) remove brackets "[]".static String[]splitIpPortStr(String str) Split IP and port strings, support IPv4 and IPv6, IP in IPv6 must be enclosed with [].
-
字段详细资料
-
PREFER_IPV6_ADDRESSES
public static final boolean PREFER_IPV6_ADDRESSES -
IPV6_START_MARK
- 另请参阅:
-
IPV6_END_MARK
- 另请参阅:
-
ILLEGAL_IP_PREFIX
- 另请参阅:
-
IP_PORT_SPLITER
- 另请参阅:
-
SPLIT_IP_PORT_RESULT_LENGTH
public static final int SPLIT_IP_PORT_RESULT_LENGTH- 另请参阅:
-
PERCENT_SIGN_IN_IPV6
- 另请参阅:
-
LOCAL_HOST
- 另请参阅:
-
-
方法详细资料
-
localHostIp
get localhost ip.- 返回:
- java.lang.String
-
isIpv4
check whether the ip address is IPv4.- 参数:
addr- ip address- 返回:
- boolean
-
isIpv6
check whether the ip address is IPv6.- 参数:
addr- ip address- 返回:
- boolean
-
isIp
check whether the str is ip address (IPv4 or IPv6).- 参数:
addr- ip address str- 返回:
- boolean
-
containsPort
Check if the address contains a port. 2020/9/3 14:53- 参数:
address- address string- 返回:
- boolean
-
splitIpPortStr
Split IP and port strings, support IPv4 and IPv6, IP in IPv6 must be enclosed with []. Illegal IP will get abnormal results.- 参数:
str- ip and port string- 返回:
- java.lang.String[]
-
getIpFromString
Resolve the IP from the string containing the IP address.- 参数:
str- string containing IP address- 返回:
- java.lang.String
-
checkIps
Check ips.- 参数:
ips- ips- 返回:
- 'ok' if check passed, otherwise illegal ip
-
checkOk
Check whether checkIps result is "ok".- 参数:
checkIpsResult- checkIps result- 返回:
- boolean
-
removeBrackets
remove brackets "[]".- 参数:
str- is ipv6 address- 返回:
- string removed brackets
-
isDomain
judge str is right domain.(Check only rule).- 参数:
str- nacosIP- 返回:
- nacosIP is domain
-
ipToInt
convert ip address to int.- 参数:
ip- ip address.- 返回:
- int
-
bytesToInt
public static int bytesToInt(byte[] bytes) convert byte array to int.- 参数:
bytes- byte array.- 返回:
- int
-
ipToBytesByInet
convert ip address to byte array.- 参数:
ip- ip address.- 返回:
- byte[]
-