// LookupHost uses the Tor LookupHost function in order to resolve hosts over
// Tor.
423285
func (p *ProxyNet) LookupHost(host string) ([]string, error) {
	return LookupHost(host, p.SOCKS)
}
947082
func (a *api) GetHost(id string) (*host.Host, error) {
	client, err := a.connectMaster()
	if err != nil {
		return nil, err
	}

	return client.GetHost(id)
}
562360
func lookup(server string, name string, dnsType uint16) (response *dns.Msg, err error) {
	name = dns.Fqdn(name)
	m := &dns.Msg{}
	m.SetQuestion(name, dnsType)
	m.Rcode = dns.OpcodeQuery
	m.RecursionDesired = true

	response, _, err = clientUDP.Exchange(m, server)
	if err == nil && m.Response == true && m.Truncated == false {
		return response, nil
	}

	// Try TCP on error, a truncated response, or some bogus non-response
	response, _, err = clientTCP.Exchange(m, server)
	return response, err
}
680054
func (s CertSet) Lookup(cert *x509.Certificate) bool {
	return s[SHA1RawPublicKey(cert)]
}
721375
func (n *node) Lookup(path string) *httpRoute {
	cur := n
	prev := n
	for part, i := slice(path, 0); ; part, i = slice(path, i) {
		if part != "" {
			cur = cur.children[part]
			if cur == nil {
				// can't progress any deeper, return last backend we saw
				return prev.backend
			}
			if cur.backend != nil {
				prev = cur // update last seen backend
			}
		}
		if i == -1 {
			break
		}
	}
	if cur.backend != nil {
		return cur.backend
	}
	return prev.backend
}
642812
func (k *TupleKey4Global) ToHost() TupleKey {
	return &TupleKey4Global{
		TupleKey4: *k.TupleKey4.ToHost().(*TupleKey4),
	}
}
244409
func (h *Hostsfile) LookupStaticHostV4(host string) []net.IP {
	return h.lookupStaticHost(h.hmap.byNameV4, host)
}
584459
func Host(host string) ConnectOption {
	return func(c *httpclient.HttpClient) {
		c.Host = host
	}
}
833703
func (c *localClient) Lookup(device protocol.DeviceID) (addresses []string, err error) {
	if cache, ok := c.Get(device); ok {
		if time.Since(cache.when) < CacheLifeTime {
			addresses = cache.Addresses
		}
	}

	return
}
803120
func (s *ServiceCache) Find(ip net.IP, port int, host string, local bool) interface{} {
	s.RLock()
	defer s.RUnlock()

	if host != "" {
		if data := s.findHost(host, port, local); data != nil {
			return data
		}
	}

	return s.findIP(ip, port, local)
}
1121106
func (l *ComposableEnvLookup) Lookup(key string, config *config.ServiceConfig) []string {
	result := []string{}
	for _, lookup := range l.Lookups {
		env := lookup.Lookup(key, config)
		if len(env) == 1 {
			result = env
		}
	}
	return result
}
551850
func (p *ProxyNet) LookupSRV(service, proto, name string) (string, []*net.SRV, error) {
	return LookupSRV(service, proto, name, p.SOCKS, p.DNS, p.StreamIsolation)
}
1075057
func (api *API) HostGetByHost(host string) (res *Host, err error) {
	hosts, err := api.HostsGet(Params{"filter": map[string]string{"host": host}})
	if err != nil {
		return
	}

	if len(hosts) == 1 {
		res = &hosts[0]
	} else {
		e := ExpectedOneResult(len(hosts))
		err = &e
	}
	return
}
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)
	})
}
899545
func MatchHost(req *http.Request, ereq *Request) (bool, error) {
	url := ereq.URLStruct
	if strings.EqualFold(url.Host, req.URL.Host) {
		return true, nil
	}
	return regexp.MatchString(url.Host, req.URL.Host)
}
839181
func (h *Hostsfile) LookupStaticHostV4(host string) []net.IP {
	h.RLock()
	defer h.RUnlock()
	if len(h.hmap.byNameV4) != 0 {
		if ips, ok := h.hmap.byNameV4[absDomainName(host)]; ok {
			ipsCp := make([]net.IP, len(ips))
			copy(ipsCp, ips)
			return ipsCp
		}
	}
	return nil
}
1164217
func host(in string) string {
	out, err := utils.Host(in)
	if err != nil {
		return in
	}
	return out
}