mxresolv

package
v4.20.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Resolver is exposed to be patched in tests
	Resolver = net.DefaultResolver
)

Functions

func Lookup

func Lookup(ctx context.Context, domainName string) (mxHosts []string, implicit bool, err error)

Lookup performs a DNS lookup of MX records for the specified domain. It returns a prioritised list of MX hostnames, where hostnames with the same priority are shuffled. If the second returned value is true, then the host does not have explicit MX records, and its A record is returned instead.

It uses an LRU cache with a timeout to reduce the number of network requests.

func LookupWithPref added in v4.20.0

func LookupWithPref(ctx context.Context, domainName string) (mxRecords []*net.MX, implicit bool, err error)

LookupWithPref performs a DNS lookup of MX records for the specified domain. It returns a slice of net.MX records that are ordered by preference. Records with the same preference are sorted by hostname to ensure deterministic behaviour. If the second returned value is true, then the host does not have explicit MX records, and its A record is used instead.

It uses an LRU cache with a timeout to reduce the number of network requests.

func ResetCache added in v4.14.2

func ResetCache()

ResetCache clears the cache for use in tests, and is not Thread-Safe

func SetDeterministicInTests added in v4.17.1

func SetDeterministicInTests() func()

SetDeterministicInTests sets rand to deterministic seed for testing, and is not Thread-Safe.

Types

This section is empty.

Jump to

Keyboard shortcuts

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