tinyresolver

package module
v0.0.0-...-63f81f0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0 Imports: 12 Imported by: 1

README

tinyresolver

tiny resolver is a simple DNS resolver for Golang, it can be used instead of a external DNS server as it relies on root hits to do its queries

usage:

resolver := tinyresolver.New()
rr, err := resolver.Resolve("ghostbox.org", "A")
if err != nil {
  panic(err)
}

answer := rr.Extra[0]
log.Printf("IP: %s", answer.(*dns.A).A)

it uses the miekg dns library, and these are also the results it returns.

Documentation

Index

Constants

View Source
const (
	// Timeout is the time in seconds the request is allowed to take before a timeout error is returned
	Timeout = 4 * time.Second

	// MaxDepth is the max recursive depth to query
	MaxDepth = 10

	// MaxNameservers is the max name servers to query simultainiously
	MaxNameservers = 4
)

Variables

View Source
var (
	ErrMaxDepth  = errors.New("Max recursion depth reached")
	ErrMaxParent = errors.New("Max parent reached")
	ErrNoNS      = errors.New("no NS record found for domain")
	ErrQueryLoop = errors.New("loop in query")
)

Various errors

Functions

func IsIpv4Net

func IsIpv4Net(host string) bool

Types

type Resolver

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

Resolver is the resolver object

func New

func New() *Resolver

New creates a new resolver

func (*Resolver) Debug

func (r *Resolver) Debug(enable bool)

Debug enables or disables debug logging of a query

func (*Resolver) Resolve

func (r *Resolver) Resolve(qname, qtype string) (*dns.Msg, error)

Resolve resoves a record by name and type, and returns the message of the answer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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