code: public static InetAddress getLocalAddress(Map<String, Integer> destHostPorts) {
          if (LOCAL_ADDRESS != null) {
              return LOCAL_ADDRESS;
          }
  
          InetAddress localAddress = getLocalAddressByHostname();
          if (!isValidAddress(localAddress)) {
              localAddress = getLocalAddressBySocket(destHostPorts);
          }
  
          if (!isValidAddress(localAddress)) {
              localAddress = getLocalAddressByNetworkInterface();
          }
  
          if (isValidAddress(localAddress)) {
              LOCAL_ADDRESS = localAddress;
          }
  
          return localAddress;
      }
docs: <pre>
  1. check if you already have ip
  2. get ip from hostname
  3. get ip from socket
  4. get ip from network interface
  </pre>
  @param destHostPorts a map of ports
  @return local ip