Set default host for each server

@param  string $host
@return MongoAdapter
189689
public function setDefaultHost($host, $port = null) {
		$this->defaultHost = (string) $host;
		
		if ($port !== null) {
			$this->setDefaultPort($port);
		}
		
		return $this;
	}
378889
public function host($host = '') {
        if ($host) {
            $this->host = $host;
        }
        if (!$this->host) {
            $this->host = self::server('HTTP_HOST');
        }
        return $this->host;
    }
734198
protected function _setSslContext($host)
    {
        foreach ($this->_config as $key => $value) {
            if (substr($key, 0, 4) !== 'ssl_') {
                continue;
            }
            $contextKey = substr($key, 4);
            if (empty($this->_config['context']['ssl'][$contextKey])) {
                $this->_config['context']['ssl'][$contextKey] = $value;
            }
            unset($this->_config[$key]);
        }
        if (!isset($this->_config['context']['ssl']['SNI_enabled'])) {
            $this->_config['context']['ssl']['SNI_enabled'] = true;
        }
        if (empty($this->_config['context']['ssl']['peer_name'])) {
            $this->_config['context']['ssl']['peer_name'] = $host;
        }
        if (empty($this->_config['context']['ssl']['cafile'])) {
            $dir = dirname(dirname(__DIR__));
            $this->_config['context']['ssl']['cafile'] = $dir . DIRECTORY_SEPARATOR .
                'config' . DIRECTORY_SEPARATOR . 'cacert.pem';
        }
        if (!empty($this->_config['context']['ssl']['verify_host'])) {
            $this->_config['context']['ssl']['CN_match'] = $host;
        }
        unset($this->_config['context']['ssl']['verify_host']);
    }
615721
protected function setHostAndPort($host)
    {
        if (!str_contains($host, ':')) {
            $this->host = $host;
        } else {
            list($this->host, $this->port) = explode(':', $host);

            $this->port = (int) $this->port;
        }
    }
230327
public function findConfiguredHost($host)
    {
        list($user, $host) = $this->parseHost($host);

        foreach ($this->groups as $group) {
            if ((isset($group['host']) && $group['host'] == $host) ||
                (isset($group['hostname']) && $group['hostname'] == $host)) {
                if (! empty($user)) {
                    // User is not specified in the SSH configuration...
                    if (! isset($group['user'])) {
                        continue;
                    }

                    // User is specified in the SSH configuration but is not the given user....
                    if (isset($group['user']) && $group['user'] != $user) {
                        continue;
                    }
                }

                return $group['host'];
            }
        }
    }
750959
public function setHost(/* string */ $host) {
		// Close connection before changing host.
		if ($this->host !== $host) {
			$this->close();
			$this->host = $host;
		}
	}
314867
private function filterHost(string $host): string
    {
        if ($host && $host !== self::HTTP_DEFAULT_HOST && strpos($host, '.') === false) {
            throw new InvalidArgumentException("Host '{$host}' is illegal!");
        }

        return strtolower($host);
    }
8030
protected function setHost($host)
    {
        $host = strtolower($host);
        
        if ($host !== '' && !$this->isValidDomain($host) && !$this->isValidIpv4($host) && !$this->isValidIpv6($host)) {
            throw new \InvalidArgumentException("Invalid hostname '$host'");
        }
        
        $this->host = $host;
    }
411479
public function setHost($host)
    {
        if ($this->validateHost($host) === false) {
            throw new Zend_Uri_Exception("Host \"$host\" is not a valid HTTP host");
        }

        $oldHost     = $this->_host;
        $this->_host = $host;

        return $oldHost;
    }
480617
def set_host(self, host):
        
        if host[-1] == '/':
            host = host[:-1]

        self.host = host
        return self
75713
public function setHost($host)
    {
        if ($host instanceof Binary && $host->getType() == Binary::TYPE_UUID) {
            return $this->{$this->createdByAttribute} = $host;
        }
        if ($host instanceof $this->hostClass || $host instanceof IdentityInterface) {
            return $this->{$this->createdByAttribute} = new Binary($host->getGUID(), Binary::TYPE_UUID);
        }
        if (is_string($host) && preg_match(Number::GUID_REGEX, $host)) {
            return $this->{$this->createdByAttribute} = new Binary(Number::guid_bin($host), Binary::TYPE_UUID);
        }
        if (strlen($host) == 16) {
            return $this->{$this->createdByAttribute} = new Binary($host, Binary::TYPE_UUID);
        }
        return false;
    }
1090487
public function useProxy($host = self::DEFAULT_PROXY_HOST, $port = self::DEFAULT_PROXY_PORT, $type = self::DEFAULT_PROXY_TYPE)
    {
        $this->setProxyType($type);
        $this->setProxyHost($host);
        $this->setProxyPort($port);

        return $this;
    }
915167
public function setHost($host)
    {
        try {
            $host = new StringObject($host);
        } catch (\Exception $e) {
            throw new UrlObjectException($e->getMessage());
        }

        $this->host = $host->stripTrailingSlash()->trim()->val();

        $this->rebuildUrl();

        return $this;
    }
1087394
public function getConfigForHost($host)
    {
        $matches = array();
        foreach ($this->configs as $config) {
            if (fnmatch($config['host'], $host)) {
                $matches[] = $config;
            }
        }
        if (count($matches) == 0) {
            throw new RuntimeException("Unable to find configuration for host '{$host}'");
        }
        usort($matches, function ($a, $b) {
            return strlen($a['host']) > strlen($b['host']);
        });
        $result = array();
        foreach ($matches as $match) {
            $result = array_merge($result, $match);
        }
        unset($result['host']);
        if (isset($result['identityfile'])) {
            $result['identityfile'] = $this->processPath($result['identityfile']);
        } else if (file_exists($file = $this->processPath($this->getIdentity()))) {
            $result['identityfile'] = $file;
        }

        return $result;
    }
1182848
public function connect(string $host = null): self
    {
        // link is already active?
        if ($host && isset($this->links[$host])) {
            return $this;
        }

        // set type as single as default
        $type = Link::TYPE_SINGLE;

        // get config as array
        $config = $this->config->toArray();

        // get database directives from given config
        $database = ($config['database'] ?? []);

        // is master/slave active?
        if (true === $this->config->get('sharding')) {
            $master = ($database['master'] ?? []);
            $slaves = ($database['slaves'] ?? []);
            switch ($host) {
                // act: master as default
                case null:
                case Link::TYPE_MASTER:
                    $type = Link::TYPE_MASTER;
                    $database = array_merge($database, $master);
                    break;
                //  act: slave
                case Link::TYPE_SLAVE:
                    $type = Link::TYPE_SLAVE;
                    if (!empty($slaves)) {
                        $database = array_merge($database, Util::arrayRand($slaves));
                    }
                    break;
                default:
                    // given host is master's host?
                    if ($host == ($master['host'] ?? '')) {
                        $type = Link::TYPE_MASTER;
                        $database = array_merge($database, $master);
                    } else {
                        // or given host is slaves's host?
                        $type = Link::TYPE_SLAVE;
                        foreach ($slaves as $slave) {
                            if (isset($slave['host']) && $slave['host'] == $host) {
                                $database = array_merge($database, $slave);
                                break;
                            }
                        }
                    }
            }
        }

        // remove unused parts
        unset($config['database'], $database['master'], $database['slaves']);

        // merge configs
        $config = array_merge($config, $database);
        if (!isset($config['host'], $config['name'], $config['username'], $config['password'])) {
            throw new InvalidConfigException(
                'Please specify all needed credentials (host, name, username, password) for a link!');
        }

        // use host as a key for link stack
        $host = $config['host'];

        // create a new link if not exists
        if (!isset($this->links[$host])) {
            $link = new Link($this->database, new Config($config), $type, $host);
            $link->open();
            // add link to links stack
            $this->setLink($host, $link);
        }

        return $this;
    }
990050
public function blockOne($host)
    {
        return $this->exists($host)
            ? $this->updateOne($host)
            : $this->addOne($host);
    }
713831
public function setHost($host)
    {
        $this->host = trim(strtolower($host));

        if ('' === $this->host) {
            $this->merge();

            return;
        }

        if (!isset($this->cache['hosts-configuration'])) {
            $this->merge();

            return;
        }

        foreach ($this->cache['hosts-configuration'] as $hostConf) {
            if (!isset($hostConf['servername'])) {
                continue;
            }
            if ($this->match($this->host, $hostConf['servername'])) {
                $this->merge($hostConf);
                break;
            }
            if (!isset($hostConf['hosts'])) {
                continue;
            }
            foreach ((array) $hostConf['hosts'] as $hostname) {
                if ($this->match($this->host, $hostname)) {
                    $this->merge($hostConf);
                    break 2;
                }
            }
        }
    }