类 InternetAddressUtil

java.lang.Object
com.alibaba.nacos.common.utils.InternetAddressUtil

public class InternetAddressUtil extends Object
ip tool.
作者:
Nacos
  • 字段详细资料

    • PREFER_IPV6_ADDRESSES

      public static final boolean PREFER_IPV6_ADDRESSES
    • IPV6_START_MARK

      public static final String IPV6_START_MARK
      另请参阅:
    • IPV6_END_MARK

      public static final String IPV6_END_MARK
      另请参阅:
    • ILLEGAL_IP_PREFIX

      public static final String ILLEGAL_IP_PREFIX
      另请参阅:
    • IP_PORT_SPLITER

      public static final String IP_PORT_SPLITER
      另请参阅:
    • SPLIT_IP_PORT_RESULT_LENGTH

      public static final int SPLIT_IP_PORT_RESULT_LENGTH
      另请参阅:
    • PERCENT_SIGN_IN_IPV6

      public static final String PERCENT_SIGN_IN_IPV6
      另请参阅:
    • LOCAL_HOST

      public static final String LOCAL_HOST
      另请参阅:
  • 方法详细资料

    • localHostIp

      public static String localHostIp()
      get localhost ip.
      返回:
      java.lang.String
    • isIpv4

      public static boolean isIpv4(String addr)
      check whether the ip address is IPv4.
      参数:
      addr - ip address
      返回:
      boolean
    • isIpv6

      public static boolean isIpv6(String addr)
      check whether the ip address is IPv6.
      参数:
      addr - ip address
      返回:
      boolean
    • isIp

      public static boolean isIp(String addr)
      check whether the str is ip address (IPv4 or IPv6).
      参数:
      addr - ip address str
      返回:
      boolean
    • containsPort

      public static boolean containsPort(String address)
      Check if the address contains a port. 2020/9/3 14:53
      参数:
      address - address string
      返回:
      boolean
    • splitIpPortStr

      public static String[] splitIpPortStr(String str)
      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

      public static String getIpFromString(String str)
      Resolve the IP from the string containing the IP address.
      参数:
      str - string containing IP address
      返回:
      java.lang.String
    • checkIps

      public static String checkIps(String... ips)
      Check ips.
      参数:
      ips - ips
      返回:
      'ok' if check passed, otherwise illegal ip
    • checkOk

      public static boolean checkOk(String checkIpsResult)
      Check whether checkIps result is "ok".
      参数:
      checkIpsResult - checkIps result
      返回:
      boolean
    • removeBrackets

      public static String removeBrackets(String str)
      remove brackets "[]".
      参数:
      str - is ipv6 address
      返回:
      string removed brackets
    • isDomain

      public static boolean isDomain(String str)
      judge str is right domain.(Check only rule).
      参数:
      str - nacosIP
      返回:
      nacosIP is domain
    • ipToInt

      public static int ipToInt(String ip)
      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

      public static byte[] ipToBytesByInet(String ip)
      convert ip address to byte array.
      参数:
      ip - ip address.
      返回:
      byte[]