HELPERS if FAUXTON_HOST not set use ip address
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;
  }
1068855
async def get_real_ext_ip(self):
        """"""
        while self._ip_hosts:
            try:
                timeout = aiohttp.ClientTimeout(total=self._timeout)
                async with aiohttp.ClientSession(
                    timeout=timeout, loop=self._loop
                ) as session, session.get(self._pop_random_ip_host()) as resp:
                    ip = await resp.text()
            except asyncio.TimeoutError:
                pass
            else:
                ip = ip.strip()
                if self.host_is_ip(ip):
                    log.debug('Real external IP: %s', ip)
                    break
        else:
            raise RuntimeError('Could not get the external IP')
        return ip
244949
def needs_ssh(hostname, _socket=None):
    
    if hostname.lower() in ['localhost', '127.0.0.1', '127.0.1.1']:
        return False
    _socket = _socket or socket
    fqdn = _socket.getfqdn()
    if hostname == fqdn:
        return False
    local_hostname = _socket.gethostname()
    local_short_hostname = local_hostname.split('.')[0]
    if local_hostname == hostname or local_short_hostname == hostname:
        return False
    return True
654409
def fake_getaddrinfo(
        host, port, family=None, socktype=None, proto=None, flags=None):
    """"""
    return [(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP,
             '', (host, port))]
1221167
def valid_host_with_port(hostport):
    
    host, port = hostport.rsplit(":", 1) if ":" in hostport else (hostport, None)

    # first, validate host or IP
    if not valid_ipv4(host) and not valid_host(host):
        return False

    # now, validate port
    if port is not None and not valid_port(port):
        return False

    return True
1172782
def remove_known_hosts(overcloud_ip):
    """"""

    known_hosts = os.path.expanduser("~/.ssh/known_hosts")

    if os.path.exists(known_hosts):
        command = ['ssh-keygen', '-R', overcloud_ip, '-f', known_hosts]
        subprocess.check_call(command)
633630
def has_pair(ip, alias):
    '''
    
    '''
    hosts = _list_hosts()
    try:
        return alias in hosts[ip]
    except KeyError:
        return False
1315402
def get_ip(host):
    '''
    
    '''
    hosts = _list_hosts()
    if not hosts:
        return ''
    # Look for the op
    for addr in hosts:
        if host in hosts[addr]:
            return addr
    # ip not found
    return ''
1107826
def get_host(self, use_x_forwarded=True):
        """"""
        # We try three options, in order of decreasing preference.
        if use_x_forwarded and ('HTTP_X_FORWARDED_HOST' in self.environ):
            host = self.environ['HTTP_X_FORWARDED_HOST']
            port = self.environ.get('HTTP_X_FORWARDED_PORT')
            if port and port != ('443' if self.is_secure else '80'):
                host = '%s:%s' % (host, port)
            return host
        elif 'HTTP_HOST' in self.environ:
            host = self.environ['HTTP_HOST']
        else:
            # Reconstruct the host using the algorithm from PEP 333.
            host = self.environ['SERVER_NAME']
            server_port = str(self.environ['SERVER_PORT'])
            if server_port != ('443' if self.is_secure else '80'):
                host = '%s:%s' % (host, server_port)
        return host
636181
function localhost(local, defaultPort) {
  // edge case when hostname:port is not informed via cli
  if (local === undefined || local === 'true') {
    local = [defaultPort];
  } else {
    local = local.toString().split(':');
  }

  return {
    hostname: reIp.test(local[0]) || isNaN(parseInt(local[0], 10)) &&
      local[0] ? local[0] : os.hostname(),
    port: parseInt(local[1] || (!reIp.test(local[0]) && local[0]), 10) ||
      defaultPort
  };
}
1336552
function isHostMethod(object, property){
    var t = typeof object[property];
    return t == 'function' ||
    (!!(t == 'object' && object[property])) ||
    t == 'unknown';
}
343055
def get_host(self, name, default=NoHostError):
        '''
        
        '''

        if name in self.hosts:
            return self.hosts[name]

        if default is NoHostError:
            raise NoHostError('No such host: {0}'.format(name))

        return default
510081
def allow_ip(*ips: typing.Union[str, ipaddress.IPv4Network, ipaddress.IPv4Address]):
    
    for ip in ips:
        if isinstance(ip, ipaddress.IPv4Address):
            allowed_ips.add(ip)
        elif isinstance(ip, str):
            allowed_ips.add(ipaddress.IPv4Address(ip))
        elif isinstance(ip, ipaddress.IPv4Network):
            allowed_ips.update(ip.hosts())
        else:
            raise ValueError(f"Bad type of ipaddress: {type(ip)} ('{ip}')")
907973
def suggest_localhost(func):
    '''
    '''
    from fabric.network import handle_prompt_abort, to_dict

    @wraps(func)
    def host_prompting_wrapper(*args, **kwargs):
        while not env.get('host_string', False):
            handle_prompt_abort("the target host connection string")
            host_string = raw_input("No hosts found. Please specify "
                                    "host string for connection [localhost]: ")
            if host_string == '':
                host_string = 'localhost'
            env.update(to_dict(host_string))
        return func(*args, **kwargs)

    host_prompting_wrapper.undecorated = func

    return host_prompting_wrapper
261793
def maybe_ip_addr(addr):
    

    if six.PY2 and isinstance(addr, str):
        addr = unicode(addr)  # noqa
    try:
        return ipaddress.ip_address(addr)
    except ValueError:
        pass
    return str(addr)
371467
public void setHost( String host )
    {
        _host = null;
        if ( host != null && host.length() > 0 )
        {
            //
            // Here's some very minimal support for IPv6 addresses.
            // If the literal IPv6 address is not enclosed in square brackets
            // then add them.
            //
            boolean needBrackets = ( ( host.indexOf( ':' ) >= 0 )
                    && !host.startsWith( "[" )
                    && !host.endsWith( "]" ) );

            if ( needBrackets )
            {
                _host = '[' + host + ']';
            }
            else
            {
                _host = host;
            }

            _opaque = false;
            setSchemeSpecificPart( null );
        }

        if ( _host == null )
        {
            setUserInfo( null );
            setPort( UNDEFINED_PORT );
        }
    }
809158
def _request_check(self, address):
        """"""
        server = self._servers.get(address)

        # "server" is None if another thread removed it from the topology.
        if server:
            server.request_check()