dqrs

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package dqrs provides types and functions used by this application to collect and process DNS queries and responses.

Index

Constants

View Source
const (
	RequestTypeA       string = "A"
	RequestTypeAAAA    string = "AAAA"
	RequestTypeCNAME   string = "CNAME"
	RequestTypeMX      string = "MX"
	RequestTypeNS      string = "NS"
	RequestTypePTR     string = "PTR"
	RequestTypeSRV     string = "SRV"
	RequestTypeUnknown string = "UNKNOWN"
)

Supported Request types TODO: Duplicated in config package

View Source
const (
	ResultsOutputSingleLine string = "single-line"
	ResultsOutputMultiLine  string = "multi-line"
)

Results summary output display options TODO: Duplicated in config package

Variables

View Source
var ErrNoRecordsFound = errors.New("no records found for query")

ErrNoRecordsFound indicates that a nameserver found no records for the specified query.

Functions

func RRStringToType

func RRStringToType(rrString string) (uint16, error)

RRStringToType converts a known Resource Record string value to the appropriate internal Resource Record type. An error is returned if the string value is not a valid key in the dns.StringToType map.

func RRTypeToString

func RRTypeToString(rrType uint16) (string, error)

RRTypeToString converts a known Resource Record type to the appropriate internal Resource Record string value. An error is returned if the Resource Record type is not a valid key in the dns.TypeToString map.

Types

type DNSQueryResponse

type DNSQueryResponse struct {

	// Server is the DNS server used for this query and response.
	Server string

	// Query is the FQDN that we requested a record for.
	Query string

	// Error records whether an error occurred during any part of performing a
	// query
	QueryError error

	// Answer may potentially be composed of multiple Resource Record types
	// such as CNAME and A records. We later separate out the types when
	// needed.
	Answer []dns.RR

	// ResponseTime, also known as the Round-trip Time, can be best summed up
	// by this Cloudflare definition: "Round-trip time (RTT) is the duration
	// in milliseconds (ms) it takes for a network request to go from a
	// starting point to a destination and back again to the starting point."
	ResponseTime time.Duration

	// RequestedRecordType represents the type of record requested as part of
	// the query
	RequestedRecordType uint16
}

DNSQueryResponse represents a query and response from a DNS server. Multiple records may be returned for a single query (e.g., CNAME and A records).

func PerformQuery

func PerformQuery(query string, server string, qType uint16, timeout time.Duration) DNSQueryResponse

PerformQuery wraps the bulk of the query/record logic performed by this application

func (DNSQueryResponse) Error

func (dqr DNSQueryResponse) Error() string

Error satisfies the Error interface TODO: This doesn't look right

func (*DNSQueryResponse) Less

func (dqr *DNSQueryResponse) Less(i, j int) bool

Less compares records and indicates whether the first argument is less than the second argument. Preference is given to CNAME records.

func (DNSQueryResponse) Records

func (dqr DNSQueryResponse) Records() []DNSRecord

Records returns all DNS records associated with a query response.

func (*DNSQueryResponse) SortRecordsAsc

func (dqr *DNSQueryResponse) SortRecordsAsc()

SortRecordsAsc sorts DNS query responses by the response value in ascending order with CNAME records listed first.

func (*DNSQueryResponse) SortRecordsDesc

func (dqr *DNSQueryResponse) SortRecordsDesc()

SortRecordsDesc sorts DNS query responses by the response value in descending order with CNAME records listed last.

type DNSQueryResponses

type DNSQueryResponses []DNSQueryResponse

DNSQueryResponses is a collection of DNS query responses. Intended for aggregation before bulk processing of some kind.

func (DNSQueryResponses) PrintSummary

func (dqrs DNSQueryResponses) PrintSummary(outputFormat string, omitTimestamp bool)

PrintSummary generates a summary of all collected DNS query results in the specified format. If specified, the date/time that the results are generated is omitted from the results output.

func (DNSQueryResponses) RecordsFound added in v0.5.4

func (dqrs DNSQueryResponses) RecordsFound() bool

RecordsFound indicates whether any query responses indicate records were found.

type DNSRecord added in v0.5.0

type DNSRecord struct {

	// Value represents the record value such as smtp1.example.com.
	Value string

	// Type is the record type, such as A, MX or CNAME.
	Type string

	// TTL is the lifetime of the record, such as 300.
	TTL uint32
}

DNSRecord represents a record returned as part of a query response.

Jump to

Keyboard shortcuts

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