cache

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	BaseResolvers:  DefaultResolvers,
	CacheSize:      10,
	ExpirationTime: 5 * 60,
	MaxRetries:     5,
}

DefaultOptions of the cache

View Source
var DefaultResolvers = []string{
	"1.1.1.1:53",
	"1.0.0.1:53",
	"8.8.8.8:53",
	"8.8.4.4:53",
}

DefaultResolvers trusted

View Source
var Separator = "-"

Functions

func MarshalAddresses

func MarshalAddresses(ips []string) []byte

func UnmarshalAddresses

func UnmarshalAddresses(data []byte) []string

Types

type Cache

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

Cache is a strcture for caching DNS lookups

func New

func New(options Options) (*Cache, error)

New creates a new caching dns resolver

func (*Cache) Lookup

func (c *Cache) Lookup(hostname string) ([]string, error)

Lookup a hostname

type DialerFunc

type DialerFunc func(context.Context, string, string) (net.Conn, error)

DialerFunc with signature matching of go net/dial

func NewDialer

func NewDialer(options Options) (DialerFunc, error)

NewDialer gets a new Dialer instance using a resolver cache

type NoAddressFoundError

type NoAddressFoundError struct{}

NoAddressFoundError occurs when no addresses are found for the host

func (*NoAddressFoundError) Error

func (m *NoAddressFoundError) Error() string

type Options

type Options struct {
	BaseResolvers  []string
	CacheSize      int
	ExpirationTime int
	MaxRetries     int
}

Options of the cache

type Resolver

type Resolver interface {
	Resolve(string) (dns.Result, error)
}

Resolver interface

Jump to

Keyboard shortcuts

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