// ValidateHost validates that the specified string is a valid host and returns it.
178781
func ValidateHost(val string) (string, error) {
	host := strings.TrimSpace(val)
	// The empty string means default and is not handled by parseDaemonHost
	if host != "" {
		_, err := parseDaemonHost(host)
		if err != nil {
			return val, err
		}
	}
	// Note: unlike most flag validators, we don't return the mutated value here
	//       we need to know what the user entered later (using ParseHost) to adjust for TLS
	return val, nil
}
642812
func (k *TupleKey4Global) ToHost() TupleKey {
	return &TupleKey4Global{
		TupleKey4: *k.TupleKey4.ToHost().(*TupleKey4),
	}
}
1132136
func (c *Client) RemoveHost(hostID string) error {
	return c.call("RemoveHost", hostID, nil)
}
1079802
func GetHost(r *http.Request) string {
	h := r.URL.Host
	if h == "" {
		h = r.Host
	}
	return h
}
698022
func MatchHost(handlers map[string]http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		host := r.Host
		handler, found := handlers[host]
		if !found {
			http.Error(w, fmt.Sprintf("%s not found for host %s", r.URL.Path, host), http.StatusNotFound)
			return
		}
		handler.ServeHTTP(w, r)
	})
}
260713
func (a *api) authenticateHost() error {
	if hostAuthenticated {
		return nil
	}

	options := config.GetOptions()

	// Try to load the master keys, fail silently if they don't exist
	masterKeyFile := filepath.Join(options.IsvcsPath, auth.MasterKeyFileName)
	if err := auth.LoadMasterKeyFile(masterKeyFile); err != nil {
		log.WithError(err).Debug("Unable to load master keys")
	}

	// Load the delegate keys
	delegateKeyFile := filepath.Join(options.EtcPath, auth.DelegateKeyFileName)
	if err := auth.LoadDelegateKeysFromFile(delegateKeyFile); err != nil {
		return err
	}

	// Get our host ID
	myHostID, err := utils.HostID()
	if err != nil {
		return err
	} else if err := validation.ValidHostID(myHostID); err != nil {
		return err
	}

	// Load an auth token once
	tokenFile := filepath.Join(options.EtcPath, auth.TokenFileName)
	getToken := func() (string, int64, error) {
		return a.AuthenticateHost(myHostID)
	}

	if _, err := auth.RefreshToken(getToken, tokenFile); err != nil {
		return err
	}

	hostAuthenticated = true
	return nil
}
413451
func isValidHostURL(hostURL string) (ok bool) {
	if strings.TrimSpace(hostURL) != "" {
		url := newClientURL(hostURL)
		if url.Scheme == "https" || url.Scheme == "http" {
			if url.Path == "/" {
				ok = true
			}
		}
	}
	return ok
}
263059
func validateIsolation(hc *container.HostConfig) error {
	// We may not be passed a host config, such as in the case of docker commit
	if hc == nil {
		return nil
	}
	if !hc.Isolation.IsValid() {
		return fmt.Errorf("Invalid isolation: %q. Windows supports 'default', 'process', or 'hyperv'", hc.Isolation)
	}
	return nil
}
428005
func (m *HostStatus) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetAddress()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return HostStatusValidationError{
					field:  "Address",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	for idx, item := range m.GetStats() {
		_, _ = idx, item

		{
			tmp := item

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return HostStatusValidationError{
						field:  fmt.Sprintf("Stats[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	{
		tmp := m.GetHealthStatus()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return HostStatusValidationError{
					field:  "HealthStatus",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	{
		tmp := m.GetSuccessRate()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return HostStatusValidationError{
					field:  "SuccessRate",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	// no validation rules for Weight

	return nil
}
255728
func (m *ClusterStatus) Validate() error {
	if m == nil {
		return nil
	}

	// no validation rules for Name

	// no validation rules for AddedViaApi

	{
		tmp := m.GetSuccessRateEjectionThreshold()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return ClusterStatusValidationError{
					field:  "SuccessRateEjectionThreshold",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	for idx, item := range m.GetHostStatuses() {
		_, _ = idx, item

		{
			tmp := item

			if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

				if err := v.Validate(); err != nil {
					return ClusterStatusValidationError{
						field:  fmt.Sprintf("HostStatuses[%v]", idx),
						reason: "embedded message failed validation",
						cause:  err,
					}
				}
			}
		}

	}

	return nil
}
429873
func (m *Http1ProtocolOptions) Validate() error {
	if m == nil {
		return nil
	}

	{
		tmp := m.GetAllowAbsoluteUrl()

		if v, ok := interface{}(tmp).(interface{ Validate() error }); ok {

			if err := v.Validate(); err != nil {
				return Http1ProtocolOptionsValidationError{
					field:  "AllowAbsoluteUrl",
					reason: "embedded message failed validation",
					cause:  err,
				}
			}
		}
	}

	// no validation rules for AcceptHttp_10

	// no validation rules for DefaultHostForHttp_10

	return nil
}
832322
func extractHost(header string) (host string) {
	host, _, err := net.SplitHostPort(header)
	if err != nil {
		host = header
	}
	return host
}
862964
func (_m *ClientInterface) RemoveHost(hostID string) error {
	ret := _m.Called(hostID)

	var r0 error
	if rf, ok := ret.Get(0).(func(string) error); ok {
		r0 = rf(hostID)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
227017
func (s *StreamAddr) Validate() error {
	if s.Host == "" {
		return errors.New("cannot have empty Host")
	}
	if err := s.Project.Validate(); err != nil {
		return err
	}
	if err := s.Path.Validate(); err != nil {
		return err
	}
	return nil
}
633007
func (t *vhostTrie) matchHost(host string) *vhostTrie {
	// try exact match
	if subtree, ok := t.edges[host]; ok {
		return subtree
	}

	// then try replacing labels in the host
	// with wildcards until we get a match
	labels := strings.Split(host, ".")
	for i := range labels {
		labels[i] = "*"
		candidate := strings.Join(labels, ".")
		if subtree, ok := t.edges[candidate]; ok {
			return subtree
		}
	}

	return nil
}
238425
func ValidateURL(value string) error {
	if _, err := url.Parse(value); err != nil {
		return err
	}
	return nil
}
1184578
func NewErrorInvalidHost(h string, d string, n map[string]string) ErrorInvalidHost {
	return ErrorInvalidHost{host: h, ds: d, nw: n}
}