dns

package
v1.0.16 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidIP = fmt.Errorf("invalid ip address resolved for hostname")

Functions

This section is empty.

Types

type Answer

type Answer struct {
	Name string     `json:"name"`
	Type RecordType `json:"type"`
	TTL  uint       `json:"ttl"`
	Data string     `json:"data"`
}

type DNS

type DNS interface {
	// Lookup performs a DNS lookup for the given hostname and returns a valid IP address for the A record.
	Lookup(ctx context.Context, hostname string) (bool, *net.IP, error)
}

type Dns

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

func New

func New(cache cache.Cache, opts ...WithConfig) *Dns

New creates a new DNS caching resolver.

func (*Dns) Lookup

func (d *Dns) Lookup(ctx context.Context, hostname string) (bool, *net.IP, error)

Lookup performs a DNS lookup for the given hostname and returns a valid IP address for the A record.

type RecordType

type RecordType uint8
const (
	A     RecordType = 1
	CNAME RecordType = 5
)

type Result

type Result struct {
	Status StatusType `json:"Status"`
	Answer []Answer   `json:"Answer"`
}

type StatusType

type StatusType uint8
const (
	NoError  StatusType = 0
	FormErr  StatusType = 1
	ServFail StatusType = 2
	NXDomain StatusType = 3
	Refused  StatusType = 5
	NotAuth  StatusType = 9
	NotZone  StatusType = 10
)

func (StatusType) String

func (s StatusType) String() string

type WithConfig

type WithConfig func(config *dnsConfig)

func WithFailIfLocal

func WithFailIfLocal() WithConfig

WithFailIfLocal will cause the DNS resolver to fail if the hostname is a local hostname.

Jump to

Keyboard shortcuts

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