dns

package
v0.0.0-...-27eea44 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoSuchHost = &net.DNSError{Err: "no such host", IsNotFound: true}
View Source
var ResolverAt = DirectResolverAt

Functions

func FindNSServers

func FindNSServers(ctx context.Context, domain string) ([]*net.NS, error)

func IpAddrsToIPs

func IpAddrsToIPs(ipAddrs []net.IPAddr) []net.IP

func NSHosts

func NSHosts(ns []*net.NS) []string

func SameIPs

func SameIPs(a, b []net.IP) bool

Types

type DNSRequest

type DNSRequest struct {
	Type   string
	Domain string
}

type DNSResponse

type DNSResponse struct {
	Records []string
	Error   error
}

type DirectResolver

type DirectResolver struct {
	NSServer string
}

func (DirectResolver) LookupCNAME

func (r DirectResolver) LookupCNAME(ctx context.Context, domain string) (string, error)

func (DirectResolver) LookupIPAddr

func (r DirectResolver) LookupIPAddr(ctx context.Context, domain string) ([]net.IPAddr, error)

func (DirectResolver) LookupNS

func (r DirectResolver) LookupNS(ctx context.Context, domain string) ([]*net.NS, error)

type ErrCNAMEFound

type ErrCNAMEFound string

func (ErrCNAMEFound) CNAME

func (e ErrCNAMEFound) CNAME() string

func (ErrCNAMEFound) Error

func (e ErrCNAMEFound) Error() string

type ErrUnexpectedRequest

type ErrUnexpectedRequest DNSRequest

func (ErrUnexpectedRequest) Error

func (e ErrUnexpectedRequest) Error() string

type MockResolver

type MockResolver struct {
	Records map[DNSRequest]DNSResponse
}

func (MockResolver) LookupCNAME

func (r MockResolver) LookupCNAME(ctx context.Context, domain string) (string, error)

func (MockResolver) LookupIPAddr

func (r MockResolver) LookupIPAddr(ctx context.Context, domain string) ([]net.IPAddr, error)

func (MockResolver) LookupNS

func (r MockResolver) LookupNS(ctx context.Context, domain string) ([]*net.NS, error)

type Resolver

type Resolver interface {
	LookupIPAddr(ctx context.Context, domain string) ([]net.IPAddr, error)
	LookupCNAME(ctx context.Context, domain string) (string, error)
	LookupNS(ctx context.Context, domain string) ([]*net.NS, error)
}

func DirectResolverAt

func DirectResolverAt(nsServer string) Resolver

type RootResolver

type RootResolver struct{}

func (RootResolver) LookupCNAME

func (r RootResolver) LookupCNAME(ctx context.Context, domain string) (string, error)

func (RootResolver) LookupIPAddr

func (r RootResolver) LookupIPAddr(ctx context.Context, domain string) ([]net.IPAddr, error)

func (RootResolver) LookupNS

func (r RootResolver) LookupNS(ctx context.Context, domain string) ([]*net.NS, error)

Jump to

Keyboard shortcuts

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