dqrs

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: MIT Imports: 10 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

This section is empty.

Variables

This section is empty.

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 {

	// 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

	// 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

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

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

	// 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
}

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() string

Records returns a comma-separated string of all DNS records retrieved by an earlier query. The output is formatted for display in a Tabwriter table.

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.

func (DNSQueryResponse) TTLs

func (dqr DNSQueryResponse) TTLs() string

TTLs returns a comma-separated list of record TTLs from an earlier query

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()

PrintSummary generates a table of all collected DNS query results

Jump to

Keyboard shortcuts

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