dns

package
v0.0.0-...-b1713d8 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2019 License: BSD-3-Clause Imports: 13 Imported by: 2

Documentation

Overview

Resolve host name stuff.

Index

Constants

View Source
const ErrCantResolve = "can't resolve the address"
View Source
const ErrDupEntry = "duplicated entry"
View Source
const ErrHostNotResolved = "host name not resolved"
View Source
const ErrIterStop = "iter stop"
View Source
const ErrNotFound = "entry not found"
View Source
const ErrServFail = "serv fail"

Variables

View Source
var ConfigurationFile = "/etc/resolv.conf"
View Source
var DefaultExpire = 24 * 60 * 60 * time.Second

Time of life of one entry, in seconds. Is query is a hit this time is reseted.

View Source
var DialTimeout = 10 * time.Second
View Source
var ReadTimeout = 500 * time.Millisecond
View Source
var Sleep = 3600 * time.Second

Time between the cleanup of the cache. Old entries are removed. In seconds.

View Source
var Timeout = 5 //Seconds
View Source
var WriteTimeout = 500 * time.Millisecond

Functions

func LookupHost

func LookupHost(host string) (addrs []string, err error)

func LookupHostNoCache

func LookupHostNoCache(host string) (addrs []string, err error)

func LookupHostWithServers

func LookupHostWithServers(host string, servers []string, attempts, timeout int) (addrs []string, err error)

func LookupIp

func LookupIp(ip string) (host string, err error)

func MulticastDNSAllInterfaces

func MulticastDNSAllInterfaces() error

func MulticastDNSResolverConfig

func MulticastDNSResolverConfig(ifs []net.Interface) error

func Resolve

func Resolve(h string) (out string, err error)

Resolve simple resolver one host name to one ip

func ResolveUrl

func ResolveUrl(url *url.URL) (*url.URL, error)

ResolveUrl replaces the host name with the ip address. Supports ipv4 and ipv6. If use in the place of host a path or a scheme for sockets, file or unix, ResolveUrl will only copy the url.

Types

type Cache

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

func (*Cache) Close

func (c *Cache) Close() error

func (*Cache) Get

func (c *Cache) Get(key string) *Host

func (*Cache) PutAddrs

func (c *Cache) PutAddrs(key string, ips []string) error

func (*Cache) PutPtr

func (c *Cache) PutPtr(key, ptr string) error

func (*Cache) PutServFail

func (c *Cache) PutServFail(key string) error

type Cacher

type Cacher interface {
	Get(key string) *Host
	PutAddrs(key string, ips []string) error
	PutPtr(key, ptr string) error
	PutServFail(key string) error
	Close() error
}

func NewCache

func NewCache(s Storer, d, cleanup time.Duration) Cacher

type Host

type Host struct {
	Addrs    []string
	ServFail bool
	Expire   time.Time
}

func (*Host) ReturnAddrs

func (h *Host) ReturnAddrs() ([]string, error)

func (*Host) ReturnPtr

func (h *Host) ReturnPtr() (string, error)

type Mem

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

func (*Mem) Del

func (m *Mem) Del(key string) error

func (*Mem) Get

func (m *Mem) Get(key string) (*Host, error)

func (*Mem) Iter

func (m *Mem) Iter(f func(key string, data *Host) error) error

func (*Mem) Put

func (m *Mem) Put(key string, data *Host) error

type Storer

type Storer interface {
	Get(key string) (*Host, error)
	Put(key string, data *Host) error
	Del(key string) error
	Iter(f func(key string, data *Host) error) error
}

func NewMem

func NewMem() Storer

Jump to

Keyboard shortcuts

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