resolver

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PerformDNSLookups

func PerformDNSLookups(resolver Resolver, domain string)

func PerformReverseLookup

func PerformReverseLookup(resolver Resolver, ip string)

func TestPerformReverseLookup

func TestPerformReverseLookup(t *testing.T)

Types

type DefaultResolver

type DefaultResolver struct{}

DefaultResolver uses Go's net package for lookups

func (*DefaultResolver) LookupAddr

func (r *DefaultResolver) LookupAddr(ip string) ([]string, error)

func (*DefaultResolver) LookupCNAME

func (r *DefaultResolver) LookupCNAME(host string) (string, error)

func (*DefaultResolver) LookupIP

func (r *DefaultResolver) LookupIP(host string) ([]net.IP, error)

func (*DefaultResolver) LookupMX

func (r *DefaultResolver) LookupMX(host string) ([]*net.MX, error)

func (*DefaultResolver) LookupNS

func (r *DefaultResolver) LookupNS(host string) ([]*net.NS, error)

func (*DefaultResolver) LookupSOA added in v0.0.2

func (r *DefaultResolver) LookupSOA(host string) ([]string, error)

LookupSOA performs SOA record lookup using miekg/dns

func (*DefaultResolver) LookupTXT

func (r *DefaultResolver) LookupTXT(host string) ([]string, error)

func (*DefaultResolver) LookupWHOIS added in v0.0.2

func (r *DefaultResolver) LookupWHOIS(domain string) (string, error)

LookupWHOIS performs a WHOIS lookup using domainr/whois

type MockResolver

type MockResolver struct {
	MockLookupAddr  func(string) ([]string, error)
	MockLookupIP    func(string) ([]net.IP, error)
	MockLookupCNAME func(string) (string, error)
	MockLookupMX    func(string) ([]*net.MX, error)
	MockLookupNS    func(string) ([]*net.NS, error)
	MockLookupTXT   func(string) ([]string, error)
}

MockResolver is struct used to simulate resolver behaviour for testing purposes

func (*MockResolver) LookupAddr

func (m *MockResolver) LookupAddr(ip string) ([]string, error)

simulates reverse DNS lookup for testing

func (*MockResolver) LookupCNAME

func (m *MockResolver) LookupCNAME(host string) (string, error)

simulates DNS lookup for CNAME records for testing

func (*MockResolver) LookupIP

func (m *MockResolver) LookupIP(host string) ([]net.IP, error)

simulates DNS lookup for A or AAAA records for testing

func (*MockResolver) LookupMX

func (m *MockResolver) LookupMX(host string) ([]*net.MX, error)

simulates DNS lookup for MX records for testing

func (*MockResolver) LookupNS

func (m *MockResolver) LookupNS(host string) ([]*net.NS, error)

simulates DNS lookup for NS records for testing

func (*MockResolver) LookupSOA added in v0.0.2

func (r *MockResolver) LookupSOA(host string) ([]string, error)

func (*MockResolver) LookupTXT

func (m *MockResolver) LookupTXT(host string) ([]string, error)

simulates DNS lookup for TXT records for testing

func (*MockResolver) LookupWHOIS added in v0.0.2

func (r *MockResolver) LookupWHOIS(domain string) (string, error)

type Resolver

type Resolver interface {
	LookupAddr(ip string) ([]string, error)
	LookupIP(host string) ([]net.IP, error)
	LookupCNAME(host string) (string, error)
	LookupMX(host string) ([]*net.MX, error)
	LookupNS(host string) ([]*net.NS, error)
	LookupTXT(host string) ([]string, error)
	LookupSOA(host string) ([]string, error)
	LookupWHOIS(host string) (string, error)
}

Jump to

Keyboard shortcuts

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