dns

package
v0.0.0-...-3cdddeb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 13 Imported by: 15

README

dns

Go Reference

DNS queries and helper function for domain names.

Based on miekg's dns module.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultServers is the package default servers.
	// It is set in the init().
	// Used servers: "8.8.8.8", "1.1.1.1", "9.9.9.10", "1.0.0.1", "8.8.4.4", "149.112.112.10"
	DefaultServers Servers

	// DefaultMaxRetries is the default number of retries of failed queries.
	// Must be greater than 1, else functions will fail with ErrInvalidMaxRetries.
	DefaultMaxRetries int = 5

	// DefaultQueryTimeoutSec is the default query timeout in seconds.
	DefaultQueryTimeoutSec = 2
)
View Source
var (
	ErrInvalidMaxRetries = errors.New("invalid MaxRetries")
	ErrTruncated         = errors.New("message is truncated")
)
View Source
var (
	ErrNoError        = errors.New("NOERROR")  // NOERROR
	ErrFormat         = errors.New("FORMERR")  // FORMERR
	ErrServerFailure  = errors.New("SERVFAIL") // SERVFAIL
	ErrName           = errors.New("NXDOMAIN") // NXDOMAIN
	ErrNotImplemented = errors.New("NOTIMP")   // NOTIMP
	ErrRefused        = errors.New("REFUSED")  // REFUSED
)
View Source
var TypeA uint16 = 1
View Source
var TypeAAAA uint16 = 28
View Source
var TypeCAA uint16 = 257
View Source
var TypeCNAME uint16 = 5
View Source
var TypeDNAME uint16 = 39
View Source
var TypeMX uint16 = 15
View Source
var TypeNS uint16 = 2
View Source
var TypeSOA uint16 = 6
View Source
var TypeSRV uint16 = 33
View Source
var TypeTXT uint16 = 16

Functions

func Clean

func Clean(d string) string

Clean removes the trailing dot and returns a lower cased version of d.

func GetDomain

func GetDomain(d string) string

GetDomain returns the domain of d (eg.: sub.example.com -> example.com).

Returns an empty string ("") if d is empty, a dot ("."), starts with a dot (eg.: ".example.com") or d is just a TLD.

func GetDomainIndex

func GetDomainIndex(d string) int

GetDomainIndex returns the index of the domain of d (eg.: sub.example.com -> 4).

Returns -1 if d is empty, a dot ("."), starts with a dot (eg.: ".example.com") or d is just a TLD.

func GetSub

func GetSub(d string) string

GetSub returns the Subdomain of the given domain d (eg.: eg.: sub.example.com -> example.com). If d is invalid or cant get the subdomain returns an empty string ("").

func GetTLD

func GetTLD(d string) string

GetTLD returns the Top Level Domain of d (eg.: sub.exmaple.com -> com).

Returns an empty string ("") if d is empty, a dot (".") or starts with a dot (eg.: ".example.com").

func GetTLDIndex

func GetTLDIndex(d string) int

GetTLDIndex returns the index of the Top Level Domain in d (eg.: sub.example.com -> 12).

Returns 0 if d is a TLD.

Returns -1 if d is empty, a dot (".") or starts with a dot (eg.: ".example.com").

func HasSub

func HasSub(d string) bool

HasSub returns whether domain d has a subdomain.

func IsExists

func IsExists(name string) (bool, error)

IsExists checks whether a record with type A, AAAA, TXT, CNAME, MX, NS, CAA or SRV is set for name. NXDOMAIN is not an error here, because it means "not found".

If found a setted record, this function returns without trying for the other types.

func IsSetA

func IsSetA(name string) (bool, error)

IsSetA checks whether an A type record set for name using the DefaultServers. NXDOMAIN is not an error here, because it means "not found".

func IsSetAAAA

func IsSetAAAA(name string) (bool, error)

IsSetAAAA checks whether an AAAA type record set for name using the DefaultServers. NXDOMAIN is not an error here, because it means "not found".

func IsSetCAA

func IsSetCAA(name string) (bool, error)

IsSetCAA checks whether a CAA type record set for name using the DefaultServers. NXDOMAIN is not an error here, because it means "not found".

func IsSetCNAME

func IsSetCNAME(name string) (bool, error)

IsSetCNAME checks whether an CNAME type record set for name using the DefaultServers. NXDOMAIN is not an error here, because it means "not found".

func IsSetDNAME

func IsSetDNAME(name string) (bool, error)

IsSetCNAME checks whether an DNAME type record set for name using the DefaultServers. NXDOMAIN is not an error here, because it means "not found".

func IsSetMX

func IsSetMX(name string) (bool, error)

IsSetMX checks whether an MX type record set for name using the DefaultServers. NXDOMAIN is not an error here, because it means "not found".

func IsSetNS

func IsSetNS(name string) (bool, error)

IsSetNS checks whether an NS type record set for name using the DefaultServers. NXDOMAIN is not an error here, because it means "not found".

func IsSetSOA

func IsSetSOA(name string) (bool, error)

IsSetSOA checks whether an SOA type record set for name using the DefaultServers. NXDOMAIN is not an error here, because it means "not found".

func IsSetSRV

func IsSetSRV(name string) (bool, error)

IsSetSRV checks whether an SRV type record set for name using the DefaultServers. NXDOMAIN is not an error here, because it means "not found".

func IsSetTXT

func IsSetTXT(name string) (bool, error)

IsSetTXT checks whether an TXT type record set for name using the DefaultServers. NXDOMAIN is not an error here, because it means "not found".

func IsValid deprecated

func IsValid(d string) bool

IsValid returns whether d is valid domain. This function is a wrapper for github.com/elmasy-com/elnet/validator.Domain.

This function returns false for "." (root domain).

Deprecated: Use github.com/elmasy-com/elnet/validator instead.

func IsValidSLD deprecated

func IsValidSLD(d string) bool

IsValidSLD returns whether d is valid Second Level Domain. This function is a wrapper for github.com/elmasy-com/elnet/validator.DomainPart.

Deprecated: Use github.com/elmasy-com/elnet/validator.DomainPart instead.

func IsWildcard

func IsWildcard(name string, t uint16) (bool, error)

IsWildcard uses the DefaultServers to check if name is a wildcard domain.

NOTE: Use IsValid() and Clean() before this function!

func Probe

func Probe(network, ip, port string, timeout time.Duration) (bool, error)

Probe checks whether DNS protocol is available on network on ip:port. This function do a simple query with "example.com."/"A". network must be "tcp", "tcp-tls" or "udp".

func QueryA

func QueryA(name string) ([]net.IP, error)

QueryA ask a random server from DefaultServers and returns a slice of net.IP. The answer slice will be nil in case of error.

The other record types are ignored.

func QueryAAAA

func QueryAAAA(name string) ([]net.IP, error)

QueryAAAA ask a random server from DefaultServers and returns a slice of net.IP. The answer slice will be nil in case of error.

The other record types are ignored.

func QueryCNAME

func QueryCNAME(name string) ([]string, error)

QueryCNAME ask a random server from DefaultServers and returns a slice of string. The answer slice will be nil in case of error.

The other record types are ignored.

func QueryDNAME

func QueryDNAME(name string) (string, error)

QueryDNAME ask a random server from DefaultServers and returns the target of string. The answer slice will be nil in case of error.

The other record types are ignored.

func QueryNS

func QueryNS(name string) ([]string, error)

QueryNS ask a random server from DefaultServers and returns a slice of string. The answer slice will be nil in case of error.

The other record types are ignored.

func QueryTXT

func QueryTXT(name string) ([]string, error)

QueryTXT ask a random server from DefaultServers and returns a slice of string. The answer slice will be nil in case of error.

The other record types are ignored.

func RcodeToError

func RcodeToError(rcode int) error

RcodeToError returns the error associated with the rcode. If rcode is unknown, returns rcode.

func TryQueryA

func TryQueryA(name string) ([]net.IP, error)

TryQueryA asks the DefaultServers for type A. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func TryQueryAAAA

func TryQueryAAAA(name string) ([]net.IP, error)

TryQueryAAAA asks the DefaultServers for type A. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func TryQueryCNAME

func TryQueryCNAME(name string) ([]string, error)

TryQueryCNAME asks the DefaultServers for type CNAME. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func TryQueryDNAME

func TryQueryDNAME(name string) (string, error)

TryQueryDNAME asks the DefaultServers for type DNAME. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func TryQueryNS

func TryQueryNS(name string) ([]string, error)

TryQueryNS asks the DefaultServers for type NS. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func TryQueryTXT

func TryQueryTXT(name string) ([]string, error)

TryQueryTXT asks the DefaultServers for type TXT. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func TypeToString

func TypeToString(t uint16) string

Types

type CAA

type CAA struct {
	Flag  uint8
	Tag   string
	Value string
}

func QueryCAA

func QueryCAA(name string) ([]CAA, error)

QueryCAA ask a random server from DefaultServers and returns a slice of CAA. The answer slice will be nil in case of error.

The other record types are ignored.

func TryQueryCAA

func TryQueryCAA(name string) ([]CAA, error)

TryQueryCAA asks the DefaultServers for type CAA. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (CAA) String

func (c CAA) String() string

type MX

type MX struct {
	Preference int    // Priority
	Exchange   string // Server's hostname
}

func QueryMX

func QueryMX(name string) ([]MX, error)

QueryMX ask a random server from DefaultServers and returns a slice of MX. The answer slice will be nil in case of error.

The other record types are ignored.

func TryQueryMX

func TryQueryMX(name string) ([]MX, error)

TryQueryMX asks the DefaultServers for type MX. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (MX) String

func (m MX) String() string

type Parts

type Parts struct {
	TLD    string // Top level domain (eg.: "com"). Cant be empty.
	Domain string // Domain part (eg.: example"). Cant be empty.
	Sub    string // Subdomain part (eg.: "www"). Can be empty.
}

func GetParts

func GetParts(d string) *Parts

GetParts returns the parts of d.

If d is just a TLD, returns a struct with empty Domain (eg.: "com" -> &Result{Sub: "", Domain: "", TLD: "com"}).

If d does not contains subdomain, than Sub will be empty (eg.: "example.com" -> &Result{Sub: "", Domain: "example", TLD: "com"}).

Returns nil if d is empty, a dot (".") or starts with a dot (eg.: ".example.com").

NOTE: This function does not validate and Clean() the given domain d. It is recommended to use IsValid() and Clean() before this function.

type Record

type Record struct {
	Type  uint16
	Value string
}

func QueryAll

func QueryAll(name string) ([]Record, error)

QueryAll query every known type and returns the records. This function checks whether name with the type is a wildcard.

type SOA

type SOA struct {
	Mname   string
	Rname   string
	Serial  int
	Refresh int
	Retry   int
	Expire  int
	MinTTL  int
}

See more: https://www.rfc-editor.org/rfc/rfc1035.html#section-3.3.13

func QuerySOA

func QuerySOA(name string) (*SOA, error)

QuerySOA ask a random server from DefaultServers and returns a SOA struct pointer. The answer slice will be nil in case of error.

The other record types are ignored.

func TryQuerySOA

func TryQuerySOA(name string) (*SOA, error)

TryQuerySOA asks the DefaultServers for type SOA. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (SOA) String

func (s SOA) String() string

type SRV

type SRV struct {
	Priority int
	Weight   int
	Port     int
	Target   string
}

func QuerySRV

func QuerySRV(name string) ([]SRV, error)

QuerySRV ask a random server from DefaultServers and returns a slice of SRV. The answer slice will be nil in case of error.

The other record types are ignored.

func TryQuerySRV

func TryQuerySRV(name string) ([]SRV, error)

TryQuerySRV asks the DefaultServers for type SRV. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (SRV) String

func (s SRV) String() string

type Server

type Server struct {
	Protocol string // Protocol name, must be "udp", "tcp" or "tcp-tls"
	IP       string // Ip address
	Port     string // Destination port
	// contains filtered or unexported fields
}

func NewServer

func NewServer(protocol string, ip string, port string, timeout time.Duration) (Server, error)

NewServer creates a new Server.

The protocol must be "udp", "tcp" or "tcp-tls".

func NewServerStr

func NewServerStr(s string, timeout time.Duration) (Server, error)

NewServerStr creates a Server from string s.

String format:

[protocol://]ip[:port]

If protocol is missing, defaults to "udp". Valid protocols are: "udp", "tcp" and "tcp-tls".

If port is missing, defaults to "53".

Valid strings:

  • udp://127.0.0.1:53 -> UDP query to 127.0.0.1 on port 53 (IPv4)
  • udp://[::1]:53 -> UDP query to ::1 on port 53 (IPv6)
  • udp://127.0.0.1 -> UDP query to 127.0.0.1 on port 53
  • 127.0.0.1:53 -> UDP query to 127.0.0.1 on port 53
  • 127.0.0.1 -> UDP query to 127.0.0.1 on port 53

func (*Server) QueryA

func (s *Server) QueryA(name string) ([]net.IP, error)

QueryA ask the server and returns a slice of net.IP. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Server) QueryAAAA

func (s *Server) QueryAAAA(name string) ([]net.IP, error)

QueryAAAA ask the server and returns a slice of net.IP. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Server) QueryCAA

func (s *Server) QueryCAA(name string) ([]CAA, error)

QueryCAA ask the server and returns a slice of CAA. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Server) QueryCNAME

func (s *Server) QueryCNAME(name string) ([]string, error)

QueryCNAME ask the server and returns a slice of string. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Server) QueryDNAME

func (s *Server) QueryDNAME(name string) (string, error)

QueryDNAME ask the server and returns the target string. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Server) QueryMX

func (s *Server) QueryMX(name string) ([]MX, error)

QueryMX ask the server and returns a slice of MX. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Server) QueryNS

func (s *Server) QueryNS(name string) ([]string, error)

QueryNS ask the server and returns a slice of string. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Server) QuerySOA

func (s *Server) QuerySOA(name string) (*SOA, error)

QuerySOA ask the server and returns a SOA struct pointer. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Server) QuerySRV

func (s *Server) QuerySRV(name string) ([]SRV, error)

QuerySRV ask the server and returns a slice of SRV. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Server) QueryTXT

func (s *Server) QueryTXT(name string) ([]string, error)

QueryTXT ask the server and returns a slice of string. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Server) Server

func (s *Server) Server() string

Server returns the server address string for github.com/miekg/dns.Client.Exchange. If the underlying IP is an IPv6 address, add brackets around the string (eg.: "[::1]:53")

func (Server) String

func (s Server) String() string

String format and return the Server struct.

func (*Server) ToTCP

func (s *Server) ToTCP() *Server

type Servers

type Servers struct {
	// contains filtered or unexported fields
}

func NewServersSlice

func NewServersSlice(retries int, srvs ...Server) Servers

NewServersSlice creates a new Servers from srvs. Retries is the maximum number retries allowed in TryQuery function.

func NewServersStr

func NewServersStr(retries int, timeout time.Duration, s ...string) (Servers, error)

NewServersStr creates a new Servers from srvs. The protocol must be "udp", "tcp" or "tcp-tls". The ddefault protocol is "udp" and the default port is "53". Retries is the maximum number retries allowed in TryQuery function. Timeout is a cumulative timeout for dial.

func (*Servers) Append

func (s *Servers) Append(srv Server)

Append add Server srv to the Servers.

func (*Servers) Get

func (s *Servers) Get(index int) *Server

Get returns a DNS server to use. If index is between the servers range, returns the selected server. If index is not between the servers range, returns a random one.

Set index to -1 to get a random one.

func (*Servers) GetMaxRetries

func (s *Servers) GetMaxRetries() int

GetMaxRetries returns the maximum number retries configured in the Servers.

func (*Servers) IsSet

func (s *Servers) IsSet(name string, t uint16) (bool, error)

IsSet checks whether a record with type t is set for name. This function retries the query in case of error (**NOT** errors like NXDOMAIN) up to n times (configured when created the Servers). NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsSetA

func (s *Servers) IsSetA(name string) (bool, error)

IsSetA checks whether an A type record set for name. NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsSetAAAA

func (s *Servers) IsSetAAAA(name string) (bool, error)

IsSetAAAA checks whether an AAAA type record set for name. NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsSetCAA

func (s *Servers) IsSetCAA(name string) (bool, error)

IsSetCAA checks whether a CAA type record set for name. NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsSetCNAME

func (s *Servers) IsSetCNAME(name string) (bool, error)

IsSetCNAME checks whether an CNAME type record set for name. NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsSetDNAME

func (s *Servers) IsSetDNAME(name string) (bool, error)

IsSetDNAME checks whether an DNAME type record set for name. NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsSetMX

func (s *Servers) IsSetMX(name string) (bool, error)

IsSetMX checks whether an MX type record set for name. NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsSetNS

func (s *Servers) IsSetNS(name string) (bool, error)

IsSetNS checks whether an NS type record set for name. NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsSetSOA

func (s *Servers) IsSetSOA(name string) (bool, error)

IsSetSOA checks whether an SOA type record set for name. NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsSetSRV

func (s *Servers) IsSetSRV(name string) (bool, error)

IsSetSRV checks whether an SRV type record set for name. NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsSetTXT

func (s *Servers) IsSetTXT(name string) (bool, error)

IsSetTXT checks whether an TXT type record set for name. NXDOMAIN is not an error here, because it means "not found".

func (*Servers) IsWildcard

func (s *Servers) IsWildcard(name string, t uint16) (bool, error)

IsWildcard check if name is a wildcard domain.

NOTE: Use IsValid() and Clean() before this function!

func (*Servers) QueryA

func (s *Servers) QueryA(name string) ([]net.IP, error)

QueryA ask a random server from servers and returns a slice of net.IP. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Servers) QueryAAAA

func (s *Servers) QueryAAAA(name string) ([]net.IP, error)

QueryAAAA ask a random server from servers and returns a slice of net.IP. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Servers) QueryAll

func (s *Servers) QueryAll(name string) ([]Record, error)

QueryAll query every known type and returns the records. This function checks whether name with the type is a wildcard, and if name is a wildcard, ommit from the retuned []Record.

It is possible to return records when error returned.

func (*Servers) QueryCAA

func (s *Servers) QueryCAA(name string) ([]CAA, error)

QueryCAA ask a random server from servers and returns a slice of CAA. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Servers) QueryCNAME

func (s *Servers) QueryCNAME(name string) ([]string, error)

QueryCNAME ask a random server from servers and returns a slice of string. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Servers) QueryDNAME

func (s *Servers) QueryDNAME(name string) (string, error)

QueryDNAME ask a random server from servers and returns the target string. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Servers) QueryMX

func (s *Servers) QueryMX(name string) ([]MX, error)

QueryMX ask a random server from servers and returns a slice of MX. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Servers) QueryNS

func (s *Servers) QueryNS(name string) ([]string, error)

QueryNS ask a random server from servers and returns a slice of string. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Servers) QuerySOA

func (s *Servers) QuerySOA(name string) (*SOA, error)

QuerySOA ask a random server from servers and returns a SOA struct pointer. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Servers) QuerySRV

func (s *Servers) QuerySRV(name string) ([]SRV, error)

QuerySRV ask a random server from servers and returns a slice of SRV. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Servers) QueryTXT

func (s *Servers) QueryTXT(name string) ([]string, error)

QueryTXT ask a random server from servers and returns a slice of string. The answer slice will be nil in case of error.

The other record types are ignored.

func (*Servers) SetMaxRetries

func (s *Servers) SetMaxRetries(n int)

SetMaxRetries sets the maximum number retries in the Servers.

func (*Servers) TryQuery

func (s *Servers) TryQuery(name string, t uint16) ([]mdns.RR, error)

TryQuery asks the servers for type t. If any error occurred, retries with an other server (except if error is NXDOMAIN). Returns the Answer section. In case of error, the answer will be nil and return ErrX or any unknown error.

NOTE: The first used server is random.

func (*Servers) TryQueryA

func (s *Servers) TryQueryA(name string) ([]net.IP, error)

TryQueryA asks the servers for type A. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (*Servers) TryQueryAAAA

func (s *Servers) TryQueryAAAA(name string) ([]net.IP, error)

TryQueryAAAA asks the servers for type AAAA. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (*Servers) TryQueryCAA

func (s *Servers) TryQueryCAA(name string) ([]CAA, error)

TryQueryCAA asks the servers for type CAA. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (*Servers) TryQueryCNAME

func (s *Servers) TryQueryCNAME(name string) ([]string, error)

TryQueryCNAME asks the servers for type CNAME. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (*Servers) TryQueryDNAME

func (s *Servers) TryQueryDNAME(name string) (string, error)

TryQueryDNAME asks the servers for type DNAME. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (*Servers) TryQueryMX

func (s *Servers) TryQueryMX(name string) ([]MX, error)

TryQueryMX asks the servers for type MX. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (*Servers) TryQueryNS

func (s *Servers) TryQueryNS(name string) ([]string, error)

TryQueryNS asks the servers for type NS. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (*Servers) TryQuerySOA

func (s *Servers) TryQuerySOA(name string) (*SOA, error)

TryQuerySOA asks the servers for type SOA. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (*Servers) TryQuerySRV

func (s *Servers) TryQuerySRV(name string) ([]SRV, error)

TryQuerySRV asks the servers for type SRV. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

func (*Servers) TryQueryTXT

func (s *Servers) TryQueryTXT(name string) ([]string, error)

TryQueryTXT asks the servers for type TXT. If any error occurred, retries with next server (except if error is NXDOMAIN).

In case of error, the answer will be nil and return ErrX or any unknown error.

The first used server is random. The other record types are ignored.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL