nameresolver

package
v0.0.0-...-3d855e8 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2018 License: BSD-2-Clause Imports: 11 Imported by: 3

Documentation

Index

Constants

View Source
const CACHE_DIRNAME = "nameresolver"

CACHE_DIRNAME is the name of the directory under the cache root directory for storage of name resolution cache files

Variables

This section is empty.

Functions

func CreateCacheDir

func CreateCacheDir(cacheRootDir string) error

CreateCacheDir creates the cache dir for storage of name resolution cache files. It may return an error if the directory cannot be created. If the directory already exists, this function does nothing.

Types

type CacheFile

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

CacheFile represents just that.

func NewCacheFile

func NewCacheFile(cacheRootDir string, topic RequestTopic) *CacheFile

NewCacheFile initializes a new CacheFile struct, based on the cache root dir, and the name of the domain that is the subject of this cache file.

func NewExistingCacheFile

func NewExistingCacheFile(cacheRootDir string, topic RequestTopic) (*CacheFile, error)

NewCacheFile initializes a new CacheFile struct and ensures that this file exists or else returns an error.

func (*CacheFile) Result

func (cf *CacheFile) Result() (entry *Entry, resultError *errors.ErrorStack, err error)
Result returns the entry or the error that were stored in the cache file. An error may also be returned, if an

incident happens during retrieval/interpretation of the cache file.

entry is the entry that was stored in the cache file.

resultError is the resolution error that was stored in the cache file.

err is the error that may happen during retrieval of the value in the cache file.

func (*CacheFile) SetResult

func (cf *CacheFile) SetResult(entry *Entry, resultErr *errors.ErrorStack) error

SetResult writes in the cache file the provided entry or error. An error is returned if an incident happens or else nil is returned.

type Entry

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

Entry represents the resolution of a name, either into an alias (CNAME) or a list of IP addresses (both v4 and v6).

func NewAliasEntry

func NewAliasEntry(owner, CNAMETarget string) *Entry

NewAliasEntry is the constructor of an entry whose content symbolizes a domain name owning just a CNAME.

func NewIPEntry

func NewIPEntry(name string, addrs []net.IP) *Entry

NewIPEntry is the constructor of an entry whose content is a domain name and its associated IP addresses.

func (*Entry) Addrs

func (e *Entry) Addrs() []net.IP

func (*Entry) CNAMETarget

func (e *Entry) CNAMETarget() string

func (*Entry) MarshalJSON

func (e *Entry) MarshalJSON() ([]byte, error)

Implements json.Marshaler

func (*Entry) Owner

func (e *Entry) Owner() string

func (*Entry) UnmarshalJSON

func (e *Entry) UnmarshalJSON(bstr []byte) error

Implements json.Unmarshaler

type Request

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

Request represents a request to the name resolution "finder".

func NewRequest

func NewRequest(name string, except tools.Exceptions) *Request

NewRequest builds a new Request instance. This is the standard way of building new requests from a third-party module.

func NewRequestWithContext

func NewRequestWithContext(name string, except tools.Exceptions, ctx *Request) *Request

NewRequestWithContext builds a new Request instance, adding some context information to it to prevent resolution loops. This is mainly used by github.com/ANSSI-FR/transdep/nameresolver

func (*Request) DetectLoop

func (nr *Request) DetectLoop() bool

DetectLoop returns true if this request is part of a resolution loop

func (*Request) Equal

func (nr *Request) Equal(other *Request) bool

func (*Request) Exceptions

func (nr *Request) Exceptions() tools.Exceptions

func (*Request) Name

func (nr *Request) Name() string

func (*Request) RequestTopic

func (nr *Request) RequestTopic() RequestTopic

func (*Request) Result

func (nr *Request) Result() (*Entry, *errors.ErrorStack)

Result returns the result of a name resolution or an error. The error may be caused by a timeout after the default timeout duration, or an error during the resolution process.

func (*Request) ResultWithSpecificTimeout

func (nr *Request) ResultWithSpecificTimeout(dur time.Duration) (*Entry, *errors.ErrorStack)

ResultWithSpecificTimeout is similar to Result except that a timeout duration may be specified.

func (*Request) SetResult

func (nr *Request) SetResult(resEntry *Entry, err *errors.ErrorStack)

SetResult allows the definition of the result value associated with this request.

type RequestTopic

type RequestTopic struct {
	// name is the request topic.
	Name string
	// except is the list of exceptions/violations of the DNS protocol that we are willing to accept for this query
	Exceptions tools.Exceptions
}

Jump to

Keyboard shortcuts

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