Documentation
¶
Overview ¶
Package dns_helper contains helpers to interact with the Domain Name System.
Index ¶
- func DNSFindNameservers(t testing.TestingT, fqdn string, resolvers []string) []stringdeprecated
- func DNSFindNameserversContext(t testing.TestingT, ctx context.Context, fqdn string, resolvers []string) []string
- func DNSFindNameserversContextE(t testing.TestingT, ctx context.Context, fqdn string, resolvers []string) ([]string, error)
- func DNSFindNameserversE(t testing.TestingT, fqdn string, resolvers []string) ([]string, error)deprecated
- func DNSLookupAuthoritativeAllWithRetry(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, ...)deprecated
- func DNSLookupAuthoritativeAllWithRetryContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, ...)
- func DNSLookupAuthoritativeAllWithValidation(t testing.TestingT, query DNSQuery, resolvers []string, ...)deprecated
- func DNSLookupAuthoritativeAllWithValidationContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, ...)
- func DNSLookupAuthoritativeAllWithValidationContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, ...) error
- func DNSLookupAuthoritativeAllWithValidationE(t testing.TestingT, query DNSQuery, resolvers []string, ...) errordeprecated
- func DNSLookupAuthoritativeAllWithValidationRetry(t testing.TestingT, query DNSQuery, resolvers []string, ...)deprecated
- func DNSLookupAuthoritativeAllWithValidationRetryContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, ...)
- func DNSLookupAuthoritativeAllWithValidationRetryContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, ...) error
- func DNSLookupAuthoritativeAllWithValidationRetryE(t testing.TestingT, query DNSQuery, resolvers []string, ...) errordeprecated
- type DNSAnswer
- type DNSAnswers
- func DNSLookup(t testing.TestingT, query DNSQuery, resolvers []string) DNSAnswersdeprecated
- func DNSLookupAuthoritative(t testing.TestingT, query DNSQuery, resolvers []string) DNSAnswersdeprecated
- func DNSLookupAuthoritativeAll(t testing.TestingT, query DNSQuery, resolvers []string) DNSAnswersdeprecated
- func DNSLookupAuthoritativeAllContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) DNSAnswers
- func DNSLookupAuthoritativeAllContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) (DNSAnswers, error)
- func DNSLookupAuthoritativeAllE(t testing.TestingT, query DNSQuery, resolvers []string) (DNSAnswers, error)deprecated
- func DNSLookupAuthoritativeAllWithRetryContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, ...) (DNSAnswers, error)
- func DNSLookupAuthoritativeAllWithRetryE(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, ...) (DNSAnswers, error)deprecated
- func DNSLookupAuthoritativeContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) DNSAnswers
- func DNSLookupAuthoritativeContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) (DNSAnswers, error)
- func DNSLookupAuthoritativeE(t testing.TestingT, query DNSQuery, resolvers []string) (DNSAnswers, error)deprecated
- func DNSLookupAuthoritativeWithRetry(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, ...) DNSAnswersdeprecated
- func DNSLookupAuthoritativeWithRetryContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, ...) DNSAnswers
- func DNSLookupAuthoritativeWithRetryContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, ...) (DNSAnswers, error)
- func DNSLookupAuthoritativeWithRetryE(t testing.TestingT, query DNSQuery, resolvers []string, maxRetries int, ...) (DNSAnswers, error)deprecated
- func DNSLookupContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) DNSAnswers
- func DNSLookupContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) (DNSAnswers, error)
- func DNSLookupE(t testing.TestingT, query DNSQuery, resolvers []string) (DNSAnswers, error)deprecated
- 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
deprecated
DNSFindNameservers tries to find the NS record for the given FQDN, iterating down the domain hierarchy until it finds the NS records and returns them. Fails if there's any error or no NS record is found up to the apex domain.
Deprecated: Use DNSFindNameserversContext instead.
func DNSFindNameserversContext ¶ added in v1.0.0
func DNSFindNameserversContext(t testing.TestingT, ctx context.Context, fqdn string, resolvers []string) []string
DNSFindNameserversContext tries to find the NS record for the given FQDN, iterating down the domain hierarchy until it finds the NS records and returns them. Fails if there's any error or no NS record is found up to the apex domain.
func DNSFindNameserversContextE ¶ added in v1.0.0
func DNSFindNameserversContextE(t testing.TestingT, ctx context.Context, fqdn string, resolvers []string) ([]string, error)
DNSFindNameserversContextE tries to find the NS record for the given FQDN, iterating down the domain hierarchy until it finds the NS records and returns them. Returns NSNotFoundError if the apex domain is reached with no result.
func DNSFindNameserversE
deprecated
DNSFindNameserversE tries to find the NS record for the given FQDN, iterating down the domain hierarchy until it finds the NS records and returns them. Returns NSNotFoundError if the apex domain is reached with no result.
Deprecated: Use DNSFindNameserversContextE instead.
func DNSLookupAuthoritativeAllWithRetry
deprecated
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.
Deprecated: Use DNSLookupAuthoritativeAllWithRetryContext instead.
func DNSLookupAuthoritativeAllWithRetryContext ¶ added in v1.0.0
func DNSLookupAuthoritativeAllWithRetryContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, maxRetries int, sleepBetweenRetries time.Duration)
DNSLookupAuthoritativeAllWithRetryContext 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
deprecated
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 DNSLookupAuthoritativeAllWithValidationContextE.
Deprecated: Use DNSLookupAuthoritativeAllWithValidationContext instead.
func DNSLookupAuthoritativeAllWithValidationContext ¶ added in v1.0.0
func DNSLookupAuthoritativeAllWithValidationContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, expectedAnswers DNSAnswers)
DNSLookupAuthoritativeAllWithValidationContext 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 DNSLookupAuthoritativeAllWithValidationContextE.
func DNSLookupAuthoritativeAllWithValidationContextE ¶ added in v1.0.0
func DNSLookupAuthoritativeAllWithValidationContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, expectedAnswers DNSAnswers) error
DNSLookupAuthoritativeAllWithValidationContextE 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 DNSLookupAuthoritativeAllContextE.
func DNSLookupAuthoritativeAllWithValidationE
deprecated
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 DNSLookupAuthoritativeAllContextE.
Deprecated: Use DNSLookupAuthoritativeAllWithValidationContextE instead.
func DNSLookupAuthoritativeAllWithValidationRetry
deprecated
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.
Deprecated: Use DNSLookupAuthoritativeAllWithValidationRetryContext instead.
func DNSLookupAuthoritativeAllWithValidationRetryContext ¶ added in v1.0.0
func DNSLookupAuthoritativeAllWithValidationRetryContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, expectedAnswers DNSAnswers, maxRetries int, sleepBetweenRetries time.Duration)
DNSLookupAuthoritativeAllWithValidationRetryContext 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 DNSLookupAuthoritativeAllWithValidationRetryContextE ¶ added in v1.0.0
func DNSLookupAuthoritativeAllWithValidationRetryContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, expectedAnswers DNSAnswers, maxRetries int, sleepBetweenRetries time.Duration) error
DNSLookupAuthoritativeAllWithValidationRetryContextE 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.
func DNSLookupAuthoritativeAllWithValidationRetryE
deprecated
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.
Deprecated: Use DNSLookupAuthoritativeAllWithValidationRetryContextE instead.
Types ¶
type DNSAnswer ¶
type DNSAnswer struct {
Type, Value string
}
DNSAnswer represents a single DNS answer with a record type and value.
type DNSAnswers ¶
type DNSAnswers []DNSAnswer
DNSAnswers is a collection of DNS answers.
func DNSLookup
deprecated
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
Deprecated: Use DNSLookupContext instead.
func DNSLookupAuthoritative
deprecated
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 DNSLookupAuthoritativeContextE.
Deprecated: Use DNSLookupAuthoritativeContext instead.
func DNSLookupAuthoritativeAll
deprecated
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 DNSLookupAuthoritativeAllContextE.
Deprecated: Use DNSLookupAuthoritativeAllContext instead.
func DNSLookupAuthoritativeAllContext ¶ added in v1.0.0
func DNSLookupAuthoritativeAllContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) DNSAnswers
DNSLookupAuthoritativeAllContext 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 DNSLookupAuthoritativeAllContextE.
func DNSLookupAuthoritativeAllContextE ¶ added in v1.0.0
func DNSLookupAuthoritativeAllContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) (DNSAnswers, error)
DNSLookupAuthoritativeAllContextE 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 DNSLookupAuthoritativeAllE
deprecated
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.
Deprecated: Use DNSLookupAuthoritativeAllContextE instead.
func DNSLookupAuthoritativeAllWithRetryContextE ¶ added in v1.0.0
func DNSLookupAuthoritativeAllWithRetryContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, maxRetries int, sleepBetweenRetries time.Duration) (DNSAnswers, error)
DNSLookupAuthoritativeAllWithRetryContextE 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 DNSLookupAuthoritativeAllWithRetryE
deprecated
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.
Deprecated: Use DNSLookupAuthoritativeAllWithRetryContextE instead.
func DNSLookupAuthoritativeContext ¶ added in v1.0.0
func DNSLookupAuthoritativeContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) DNSAnswers
DNSLookupAuthoritativeContext 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 DNSLookupAuthoritativeContextE.
func DNSLookupAuthoritativeContextE ¶ added in v1.0.0
func DNSLookupAuthoritativeContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) (DNSAnswers, error)
DNSLookupAuthoritativeContextE 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 DNSLookupAuthoritativeE
deprecated
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.
Deprecated: Use DNSLookupAuthoritativeContextE instead.
func DNSLookupAuthoritativeWithRetry
deprecated
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 a non-empty answer, 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 DNSLookupAuthoritativeWithRetryContextE.
Deprecated: Use DNSLookupAuthoritativeWithRetryContext instead.
func DNSLookupAuthoritativeWithRetryContext ¶ added in v1.0.0
func DNSLookupAuthoritativeWithRetryContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, maxRetries int, sleepBetweenRetries time.Duration) DNSAnswers
DNSLookupAuthoritativeWithRetryContext repeatedly gets authoritative answers for the specified record and type until ANY of the authoritative nameservers found replies with a non-empty answer, 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 DNSLookupAuthoritativeWithRetryContextE.
func DNSLookupAuthoritativeWithRetryContextE ¶ added in v1.0.0
func DNSLookupAuthoritativeWithRetryContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string, maxRetries int, sleepBetweenRetries time.Duration) (DNSAnswers, error)
DNSLookupAuthoritativeWithRetryContextE repeatedly gets authoritative answers for the specified record and type until ANY of the authoritative nameservers found replies with a non-empty answer, 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 DNSLookupAuthoritativeWithRetryE
deprecated
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 a non-empty answer, or until max retries has been exceeded. If resolvers are defined, uses them instead of the default system ones to find the authoritative nameservers.
Deprecated: Use DNSLookupAuthoritativeWithRetryContextE instead.
func DNSLookupContext ¶ added in v1.0.0
func DNSLookupContext(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) DNSAnswers
DNSLookupContext 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 DNSLookupContextE ¶ added in v1.0.0
func DNSLookupContextE(t testing.TestingT, ctx context.Context, query DNSQuery, resolvers []string) (DNSAnswers, error)
DNSLookupContextE sends a DNS query for the specified record and type using the given resolvers. Returns QueryTypeError when record type is not supported. Returns NoResolversError when no resolvers are provided. Returns any underlying error. Supported record types: A, AAAA, CNAME, MX, NS, TXT
func DNSLookupE
deprecated
DNSLookupE sends a DNS query for the specified record and type using the given resolvers. Returns QueryTypeError when record type is not supported. Returns NoResolversError when no resolvers are provided. Returns any underlying error. Supported record types: A, AAAA, CNAME, MX, NS, TXT
Deprecated: Use DNSLookupContextE instead.
type DNSQuery ¶
type DNSQuery struct {
Type, Name string
}
DNSQuery represents a DNS query with a record type and name.
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