dnsx

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package dnsx contains the library logic

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	BaseResolvers:     DefaultResolvers,
	MaxRetries:        5,
	QuestionTypes:     []uint16{miekgdns.TypeA},
	TraceMaxRecursion: math.MaxUint16,
	Hostsfile:         true,
}

DefaultOptions contains the default configuration options

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

DefaultResolvers contains the list of resolvers known to be trusted.

Functions

func StringToRequestType

func StringToRequestType(tp string) (rt uint16, err error)

StringToRequestType conversion helper

Types

type AsnResponse

type AsnResponse struct {
	AsNumber  string   `json:"as-number,omitempty" csv:"as_number"`
	AsName    string   `json:"as-name,omitempty" csv:"as_name"`
	AsCountry string   `json:"as-country,omitempty" csv:"as_country"`
	AsRange   []string `json:"as-range,omitempty" csv:"as_range"`
}

func (*AsnResponse) String

func (o *AsnResponse) String() string

type DNSX

type DNSX struct {
	Options *Options
	// contains filtered or unexported fields
}

DNSX is structure to perform dns lookups

func New

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

New creates a dns resolver

func (*DNSX) AXFR

func (d *DNSX) AXFR(hostname string) (*retryabledns.AXFRData, error)

Trace performs a DNS trace of the specified types and returns raw responses

func (*DNSX) CdnCheck

func (d *DNSX) CdnCheck(domain string) (bool, string, error)

CdnCheck verifies if the given ip is part of Cdn ranges

func (*DNSX) Lookup

func (d *DNSX) Lookup(hostname string) ([]string, error)

Lookup performs a DNS A question and returns corresponding IPs

func (*DNSX) QueryMultiple

func (d *DNSX) QueryMultiple(hostname string) (*retryabledns.DNSData, error)

QueryMultiple performs a DNS question of the specified types and returns raw responses

func (*DNSX) QueryOne

func (d *DNSX) QueryOne(hostname string) (*retryabledns.DNSData, error)

QueryOne performs a DNS question of a specified type and returns raw responses

func (*DNSX) Trace

func (d *DNSX) Trace(hostname string) (*retryabledns.TraceData, error)

Trace performs a DNS trace of the specified types and returns raw responses

type MarshalOption

type MarshalOption func(d *ResponseData)

func WithoutAllRecords

func WithoutAllRecords() MarshalOption

type Options

type Options struct {
	BaseResolvers     []string
	MaxRetries        int
	QuestionTypes     []uint16
	Trace             bool
	TraceMaxRecursion int
	Hostsfile         bool
	OutputCDN         bool
}

Options contains configuration options

type ResponseData

type ResponseData struct {
	*retryabledns.DNSData
	IsCDNIP bool         `json:"cdn,omitempty" csv:"cdn"`
	CDNName string       `json:"cdn-name,omitempty" csv:"cdn-name"`
	ASN     *AsnResponse `json:"asn,omitempty" csv:"asn"`
}

ResponseData to show output result

func (*ResponseData) JSON

func (d *ResponseData) JSON(options ...MarshalOption) (string, error)

Jump to

Keyboard shortcuts

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