Callsback an ip address or null if can't find the hostname
9627
function(hostname, callback) {
  get_nodes(function(err,nodes) {
    if (err) return callback(err);

    var n = nodes.filter(function(node) {
      return node.name === hostname;
    });

    callback(null,(n.length === 1) ? n[0].ip_address : null);
  });
}
790760
def get_hostname(address, fqdn=True):
    
    if is_ip(address):
        try:
            import dns.reversename
        except ImportError:
            if six.PY2:
                apt_install("python-dnspython", fatal=True)
            else:
                apt_install("python3-dnspython", fatal=True)
            import dns.reversename

        rev = dns.reversename.from_address(address)
        result = ns_query(rev)

        if not result:
            try:
                result = socket.gethostbyaddr(address)[0]
            except Exception:
                return None
    else:
        result = address

    if fqdn:
        # strip trailing .
        if result.endswith('.'):
            return result[:-1]
        else:
            return result
    else:
        return result.split('.')[0]
630558
private function getRemoteAddress() : ?string
    {
        $hostname = null;

        if (isset($_SERVER['REMOTE_ADDR'])) {
            $hostname = filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP);

            if (false === $hostname) {
                $hostname = null;
            }
        }

        if (function_exists('apache_request_headers')) {
            $headers = apache_request_headers();

            if ($headers === false) {
                return $hostname;
            }

            foreach ($headers as $k => $v) {
                if (strcasecmp($k, 'x-forwarded-for')) {
                    continue;
                }

                $hostname = explode(',', $v);
                $hostname = trim($hostname[0]);
                break;
            }
        }

        return $hostname;
    }
300770
public static String getLocalHostName() {
		try {
			InetAddress addr = InetAddress.getLocalHost();
			return addr.getHostName();
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		return null;
	}
969041
function getHostname(url, userOptions = {}) {
  const defaults = {
    removeSubdomains: true,
  };
  const options = Object.assign({}, defaults, userOptions);
  const domainRegExp = /^(?:[a-z]+:\/\/)?(?:[^/@]+@)?([^/:]+)/i;
  const ipAddressRegExp = /^\d{1,3}\.\d{1,3}.\d{1,3}\.\d{1,3}$/;
  const domainMatch = url.match(domainRegExp);

  if (domainMatch === null) {
    throw new Error(`URL is invalid: ${url}`);
  }

  // If the hostname is an IP address, no further processing can be done.
  const hostname = domainMatch[1];
  if (ipAddressRegExp.test(hostname)) {
    return hostname;
  }

  // Return the hostname with subdomains removed, if requested.
  return (options.removeSubdomains) ? removeSubdomains(hostname) : hostname;
}
622111
public String getHostByAddr(byte [] addr) throws UnknownHostException {
	Name name = ReverseMap.fromAddress(InetAddress.getByAddress(addr));
	Record [] records = new Lookup(name, Type.PTR).run();
	if (records == null)
		throw new UnknownHostException();
	return ((PTRRecord) records[0]).getTarget().toString();
}
1025797
private static String getHostName() {
    String hostName = null;
    try {
      hostName = InetAddress.getLocalHost().getHostName();
    } 
    catch (UnknownHostException ex) {
      LOG.info("Unable to obtain hostName", ex);
      hostName = "unknown";
    }
    return hostName;
  }
1200450
public IPAddress asAddress(IPVersion version) {
		if(isAddress(version)) {
			return parsedHost.asAddress(version);
		}
		return null;
	}
502015
def _resolv_name(self, hostname):
        """"""
        ip = hostname
        try:
            ip = socket.gethostbyname(hostname)
        except Exception as e:
            logger.debug("{}: Cannot convert {} to IP address ({})".format(self.plugin_name, hostname, e))
        return ip
8341
def ip_to_host(ip):
    '''
    
    '''
    try:
        hostname, aliaslist, ipaddrlist = socket.gethostbyaddr(ip)
    except Exception as exc:
        log.debug('salt.utils.network.ip_to_host(%r) failed: %s', ip, exc)
        hostname = None
    return hostname
1308307
function getProtocolAndHostname(origUrl?: string): null | string {
  const url = getUrlParts(origUrl);
  if (!url) {
    return null;
  }
  const port = url.port ? `:${url.port}` : "";
  return `${url.protocol || "http:"}//${url.hostname}${port}`;
}
1080707
def fetch_host_ip(host: str) -> str:
    
    try:
        ip = socket.gethostbyname(host)
    except socket.gaierror:
        return ''

    return ip
266634
function isBlacklisted(ip, callback) {
    var host_lookup = reverseIp(ip) + bl_zones[current_bl];

    dns.resolve4(host_lookup, function(err, domain) {
        if (err) {
            // Not blacklisted
            callback(false);
        } else {
            // It is blacklisted
            callback(true);
        }
    });
}
1022381
function getHostname()
{
  var interfaces = networkInterfaces()
  for(var name in interfaces)
  {
    var info = interfaces[name].filter(filterIPv4)[0]
    if(info) return info.address
  }
}
533678
def get_host_ipv6addr_info(ipv6addr=None, mac=None,
                                        discovered_data=None,
                                        return_fields=None, **api_opts):
    '''
    
    '''
    infoblox = _get_infoblox(**api_opts)
    return infoblox.get_host_ipv6addr_object(ipv6addr, mac, discovered_data, return_fields)
1320912
function DetectLocalIPAddress(callback) {
            if (!DetectRTC.isWebRTCSupported) {
                return;
            }

            if (DetectRTC.isORTCSupported) {
                return;
            }

            getIPs(function(ip) {
                //local IPs
                if (ip.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/)) {
                    callback('Local: ' + ip);
                }

                //assume the rest are public IPs
                else {
                    callback('Public: ' + ip);
                }
            });
        }
342071
function _getHost (fauxton_ip) {
    if (fauxton_ip) {
      return fauxton_ip;
    }
    //making some assumptions here
    const interfaces = os.networkInterfaces();
    const eth0 = interfaces[Object.keys(interfaces)[1]];
    return eth0.find(function (item) {
      return item.family === 'IPv4';
    }).address;
  }