public static String getLocalhostNameOrAddress(final boolean returnAddress) {
        try {

            for (NetworkInterface networkInterface : Collections.list(NetworkInterface.getNetworkInterfaces())) {
                for (InetAddress inetAddress : Collections.list(networkInterface.getInetAddresses())) {
                    if (inetAddress.isLoopbackAddress()) {
                        continue;
                    }
                    if (returnAddress) {
                        return inetAddress.getHostAddress();
                    } else {
                        return inetAddress.getCanonicalHostName();
                    }
                }
            }
        } catch (Exception e) {
            LOG.error("Failed to get local host name or address", e);
        }
        return "";
    }
Returns the local host name or IP address. Can be used to set {@code Referer} HTTP header.
If fails to find the local host name or address, returns an empty string.
@param returnAddress if true, return address; otherwise, return name
@return string representing the local host name or address
client-v2/src/main/java/com/clickhouse/client/api/internal/EnvUtils.java