func lookupFromAnyServer(name string, qtype uint16, conf *dns.ClientConfig, logger log.Logger) (*dns.Msg, error) {
	client := &dns.Client{}

	for _, server := range conf.Servers {
		servAddr := net.JoinHostPort(server, conf.Port)
		msg, err := askServerForName(name, qtype, client, servAddr, true)
		if err != nil {
			level.Warn(logger).Log("msg", "DNS resolution failed", "server", server, "name", name, "err", err)
			continue
		}

		if msg.Rcode == dns.RcodeSuccess || msg.Rcode == dns.RcodeNameError {
			// We have our answer.  Time to go home.
			return msg, nil
		}
	}

	return nil, errors.Errorf("could not resolve %s: no servers returned a viable answer", name)
}
func lookupFromAnyServer(name string, qtype uint16, conf *dns.ClientConfig, logger log.Logger) (*dns.Msg, error) {
	client := &dns.Client{}

	for _, server := range conf.Servers {
		servAddr := net.JoinHostPort(server, conf.Port)
		msg, err := askServerForName(name, qtype, client, servAddr, true)
		if err != nil {
			level.Warn(logger).Log("msg", "DNS resolution failed", "server", server, "name", name, "err", err)
			continue
		}

		if msg.Rcode == dns.RcodeSuccess || msg.Rcode == dns.RcodeNameError {
			
			return msg, nil
		}
	}

	return nil, errors.Errorf("could not resolve %s: no servers returned a viable answer", name)
}
func lookupFromAnyServer ( name string , qtype uint16 , conf * dns . ClientConfig , logger log . Logger ) ( * dns . Msg , error ) { client := & dns . Client { } for _ , server := range conf . Servers { servAddr := net . JoinHostPort ( server , conf . Port ) msg , err := askServerForName ( name , qtype , client , servAddr , true ) if err != nil { level . Warn ( logger ) . Log ( " " , " " , " " , server , " " , name , " " , err ) continue } if msg . Rcode == dns . RcodeSuccess || msg . Rcode == dns . RcodeNameError { // We have our answer.  Time to go home. return msg , nil } } return nil , errors . Errorf ( " " , name ) }
// lookupFromAnyServer uses all configured servers to try and resolve a specific
// name.  If a viable answer is received from a server, then it is
// immediately returned, otherwise the other servers in the config are
// tried, and if none of them return a viable answer, an error is returned.
//
// A "viable answer" is one which indicates either:
//
// 1. "yes, I know that name, and here are its records of the requested type"
//    (RCODE==SUCCESS, ANCOUNT > 0);
// 2. "yes, I know that name, but it has no records of the requested type"
//    (RCODE==SUCCESS, ANCOUNT==0); or
// 3. "I know that name doesn't exist" (RCODE==NXDOMAIN).
//
// A non-viable answer is "anything else", which encompasses both various
// system-level problems (like network timeouts) and also
// valid-but-unexpected DNS responses (SERVFAIL, REFUSED, etc).
lookupFromAnyServer uses all configured servers to try and resolve a specific name . If a viable answer is received from a server then it is immediately returned otherwise the other servers in the config are tried and if none of them return a viable answer an error is returned . A viable answer is one which indicates either : 1 . yes I know that name and here are its records of the requested type ( RCODE == SUCCESS ANCOUNT > 0 ) ; 2 . yes I know that name but it has no records of the requested type ( RCODE == SUCCESS ANCOUNT == 0 ) ; or 3 . I know that name doesn t exist ( RCODE == NXDOMAIN ) . A non - viable answer is anything else which encompasses both various system - level problems ( like network timeouts ) and also valid - but - unexpected DNS responses ( SERVFAIL REFUSED etc ) .