dns

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractRecords

func ExtractRecords[T uint16 | string](records *DNSRecords, qtype T) ([]string, error)

ExtractRecords extracts records from the DNS query results based on the query type

func GetQueryTypeFromString

func GetQueryTypeFromString(testType string) (uint16, error)

GetQueryTypeFromString maps the string test type to the corresponding DNS query type

func QueryAndExtract

func QueryAndExtract(client IDNSClient, testType, dnsServer, domain string) ([]string, error)

QueryAndExtract handles the DNS query and extracts the relevant records

func QueryDNSRecord

func QueryDNSRecord(client IDNSClient, domain string, server string, qtype uint16, setter func(dns.RR)) error

QueryDNSRecord queries a specific DNS record type and processes the results using a setter function

Types

type DNSRecords

type DNSRecords struct {
	ARecords     []string
	AAAARecords  []string
	CNAMERecords []string
	MXRecords    []MXRecord
	TXTRecords   []string
	NSRecords    []string
}

func QueryDNS

func QueryDNS(domain string, dnsServer string, client IDNSClient) (*DNSRecords, error)

QueryDNS fetches DNS records of various types for a given domain

type IDNSClient

type IDNSClient interface {
	Exchange(msg *dns.Msg, server string) (*dns.Msg, time.Duration, error)
}

IDNSClient is a small 'github.com/miekg/dns.client' implementation for easy testing

type MXRecord

type MXRecord struct {
	Host string
	Pref uint16
}

type MockIDNSClient

type MockIDNSClient struct {
	MockExchange func(*dns.Msg, string) (*dns.Msg, time.Duration, error)
}

func (*MockIDNSClient) Exchange

func (m *MockIDNSClient) Exchange(msg *dns.Msg, server string) (*dns.Msg, time.Duration, error)

Jump to

Keyboard shortcuts

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