类 IPUtil

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

public class IPUtil 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
      另请参阅:
      常量字段值
  • 构造器详细资料

    • IPUtil

      public IPUtil()
  • 方法详细资料

    • 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 [].
      参数:
      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