Documentation ¶
Overview ¶
Package dns_helper contains helpers to interact with the Domain Name System.
Index ¶
- func DNSFindNameservers(t testing.TestingT, fqdn string, resolvers []string) []string
- func DNSFindNameserversE(t testing.TestingT, fqdn string, resolvers []string) ([]string, error)
- func DNSLookupAuthoritativeAllWithRetry(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, ...)
- func DNSLookupAuthoritativeAllWithValidation(t testing.TestingT, query DNSQuery, resolvers []string, ...)
- func DNSLookupAuthoritativeAllWithValidationE(t testing.TestingT, query DNSQuery, resolvers []string, ...) error
- func DNSLookupAuthoritativeAllWithValidationRetry(t testing.TestingT, query DNSQuery, resolvers []string, ...)
- func DNSLookupAuthoritativeAllWithValidationRetryE(t testing.TestingT, query DNSQuery, resolvers []string, ...) error
- type DNSAnswer
- type DNSAnswers
- func DNSLookup(t testing.TestingT, query DNSQuery, resolvers []string) DNSAnswers
- func DNSLookupAuthoritative(t testing.TestingT, query DNSQuery, resolvers []string) DNSAnswers
- func DNSLookupAuthoritativeAll(t testing.TestingT, query DNSQuery, resolvers []string) DNSAnswers
- func DNSLookupAuthoritativeAllE(t testing.TestingT, query DNSQuery, resolvers []string) (DNSAnswers, error)
- func DNSLookupAuthoritativeAllWithRetryE(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, ...) (DNSAnswers, error)
- func DNSLookupAuthoritativeE(t testing.TestingT, query DNSQuery, resolvers []string) (DNSAnswers, error)
- func DNSLookupAuthoritativeWithRetry(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, ...) DNSAnswers
- func DNSLookupAuthoritativeWithRetryE(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, ...) (DNSAnswers, error)
- func DNSLookupE(t testing.TestingT, query DNSQuery, resolvers []string) (DNSAnswers, error)
- type DNSQuery
- type InconsistentAuthoritativeError
- type MaxRetriesExceeded
- type NSNotFoundError
- type NoResolversError
- type NotFoundError
- type QueryTypeError
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DNSFindNameservers ¶
DNSFindNameservers tries to find the NS record for the given FQDN, iterating down the domain hierarchy until it founds the NS records and returns it. Fails if there's any error or no NS record is found up to the apex domain.
func DNSFindNameserversE ¶
DNSFindNameserversE tries to find the NS record for the given FQDN, iterating down the domain hierarchy until it founds the NS records and returns it. Returns the last error if the apex domain is reached with no result.
func DNSLookupAuthoritativeAllWithRetry ¶
func DNSLookupAuthoritativeAllWithRetry(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, sleepBetweenRetries time.Duration)
DNSLookupAuthoritativeAllWithRetry repeatedly sends DNS requests for the specified record and type, until ALL authoritative nameservers reply with the exact same non-empty answers or until max retries has been exceeded. If defined, uses the given resolvers instead of the default system ones to find the authoritative nameservers. Fails when max retries has been exceeded.
func DNSLookupAuthoritativeAllWithValidation ¶
func DNSLookupAuthoritativeAllWithValidation(t testing.TestingT, query DNSQuery, resolvers []string, expectedAnswers DNSAnswers)
DNSLookupAuthoritativeAllWithValidation gets authoritative answers for the specified record and type. All the authoritative nameservers found must give the same answers and match the expectedAnswers. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers. Fails on any underlying error from DNSLookupAuthoritativeAllWithValidationE.
func DNSLookupAuthoritativeAllWithValidationE ¶
func DNSLookupAuthoritativeAllWithValidationE(t testing.TestingT, query DNSQuery, resolvers []string, expectedAnswers DNSAnswers) error
DNSLookupAuthoritativeAllWithValidationE gets authoritative answers for the specified record and type. All the authoritative nameservers found must give the same answers and match the expectedAnswers. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers. Returns ValidationError when expectedAnswers differ from the obtained ones. Returns any underlying error from DNSLookupAuthoritativeAllE.
func DNSLookupAuthoritativeAllWithValidationRetry ¶
func DNSLookupAuthoritativeAllWithValidationRetry(t testing.TestingT, query DNSQuery, resolvers []string, expectedAnswers DNSAnswers, maxRetries int, sleepBetweenRetries time.Duration)
DNSLookupAuthoritativeAllWithValidationRetry repeatedly gets authoritative answers for the specified record and type until ALL the authoritative nameservers found give the same answers and match the expectedAnswers, or until max retries has been exceeded. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers. Fails when max retries has been exceeded.
func DNSLookupAuthoritativeAllWithValidationRetryE ¶
func DNSLookupAuthoritativeAllWithValidationRetryE(t testing.TestingT, query DNSQuery, resolvers []string, expectedAnswers DNSAnswers, maxRetries int, sleepBetweenRetries time.Duration) error
DNSLookupAuthoritativeAllWithValidationRetryE repeatedly gets authoritative answers for the specified record and type until ALL the authoritative nameservers found give the same answers and match the expectedAnswers, or until max retries has been exceeded. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers.
Types ¶
type DNSAnswers ¶
type DNSAnswers []DNSAnswer
DNSAnswers type
func DNSLookup ¶
func DNSLookup(t testing.TestingT, query DNSQuery, resolvers []string) DNSAnswers
DNSLookup sends a DNS query for the specified record and type using the given resolvers. Fails on any error. Supported record types: A, AAAA, CNAME, MX, NS, TXT
func DNSLookupAuthoritative ¶
func DNSLookupAuthoritative(t testing.TestingT, query DNSQuery, resolvers []string) DNSAnswers
DNSLookupAuthoritative gets authoritative answers for the specified record and type. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers. Fails on any error from DNSLookupAuthoritativeE.
func DNSLookupAuthoritativeAll ¶
func DNSLookupAuthoritativeAll(t testing.TestingT, query DNSQuery, resolvers []string) DNSAnswers
DNSLookupAuthoritativeAll gets authoritative answers for the specified record and type. All the authoritative nameservers found must give the same answers. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers. Fails on any error from DNSLookupAuthoritativeAllE.
func DNSLookupAuthoritativeAllE ¶
func DNSLookupAuthoritativeAllE(t testing.TestingT, query DNSQuery, resolvers []string) (DNSAnswers, error)
DNSLookupAuthoritativeAllE gets authoritative answers for the specified record and type. All the authoritative nameservers found must give the same answers. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers. Returns InconsistentAuthoritativeError when any authoritative nameserver gives a different answer. Returns any underlying error.
func DNSLookupAuthoritativeAllWithRetryE ¶
func DNSLookupAuthoritativeAllWithRetryE(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, sleepBetweenRetries time.Duration) (DNSAnswers, error)
DNSLookupAuthoritativeAllWithRetryE repeatedly sends DNS requests for the specified record and type, until ALL authoritative nameservers reply with the exact same non-empty answers or until max retries has been exceeded. If defined, uses the given resolvers instead of the default system ones to find the authoritative nameservers.
func DNSLookupAuthoritativeE ¶
func DNSLookupAuthoritativeE(t testing.TestingT, query DNSQuery, resolvers []string) (DNSAnswers, error)
DNSLookupAuthoritativeE gets authoritative answers for the specified record and type. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers. Returns NotFoundError when no answer found in any authoritative nameserver. Returns any underlying error from individual lookups.
func DNSLookupAuthoritativeWithRetry ¶
func DNSLookupAuthoritativeWithRetry(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, sleepBetweenRetries time.Duration) DNSAnswers
DNSLookupAuthoritativeWithRetry repeatedly gets authoritative answers for the specified record and type until ANY of the authoritative nameservers found replies with non-empty answer matching the expectedAnswers, or until max retries has been exceeded. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers. Fails on any error from DNSLookupAuthoritativeWithRetryE.
func DNSLookupAuthoritativeWithRetryE ¶
func DNSLookupAuthoritativeWithRetryE(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, sleepBetweenRetries time.Duration) (DNSAnswers, error)
DNSLookupAuthoritativeWithRetryE repeatedly gets authoritative answers for the specified record and type until ANY of the authoritative nameservers found replies with non-empty answer matching the expectedAnswers, or until max retries has been exceeded. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers.
func DNSLookupE ¶
DNSLookupE sends a DNS query for the specified record and type using the given resolvers. Returns QueryTypeError when record type is not supported. Returns any underlying error. Supported record types: A, AAAA, CNAME, MX, NS, TXT
type InconsistentAuthoritativeError ¶
type InconsistentAuthoritativeError struct { Query DNSQuery Answers DNSAnswers Nameserver string PreviousAnswers DNSAnswers }
InconsistentAuthoritativeError is an error that occurs if an authoritative answer is different from another
func (InconsistentAuthoritativeError) Error ¶
func (err InconsistentAuthoritativeError) Error() string
type MaxRetriesExceeded ¶
MaxRetriesExceeded is an error that occurs when the maximum amount of retries is exceeded.
func (MaxRetriesExceeded) Error ¶
func (err MaxRetriesExceeded) Error() string
type NSNotFoundError ¶
NSNotFoundError is an error that occurs if no NS records found
func (NSNotFoundError) Error ¶
func (err NSNotFoundError) Error() string
type NoResolversError ¶
type NoResolversError struct{}
NoResolversError is an error that occurs if no resolvers have been set for DNSLookupE
func (NoResolversError) Error ¶
func (err NoResolversError) Error() string
type NotFoundError ¶
NotFoundError is an error that occurs if no answer found
func (NotFoundError) Error ¶
func (err NotFoundError) Error() string
type QueryTypeError ¶
type QueryTypeError struct {
Type string
}
QueryTypeError is an error that occurs if the DNS query type is not supported
func (QueryTypeError) Error ¶
func (err QueryTypeError) Error() string
type ValidationError ¶
type ValidationError struct { Query DNSQuery Answers DNSAnswers ExpectedAnswers DNSAnswers }
ValidationError is an error that occurs when answers validation fails
func (ValidationError) Error ¶
func (err ValidationError) Error() string