resolver

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 5 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) LookupTXT

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

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 a struct used to simulate resolver behavior for testing purposes.

func (*MockResolver) LookupAddr

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

LookupAddr simulates reverse DNS lookup for testing.

func (*MockResolver) LookupCNAME

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

LookupCNAME simulates DNS lookup for CNAME records for testing.

func (*MockResolver) LookupIP

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

LookupIP simulates DNS lookup for A or AAAA records for testing.

func (*MockResolver) LookupMX

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

LookupMX simulates DNS lookup for MX records for testing.

func (*MockResolver) LookupNS

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

LookupNS simulates DNS lookup for NS records for testing.

func (*MockResolver) LookupTXT

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

LookupTXT simulates DNS lookup for TXT records for testing.

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

Jump to

Keyboard shortcuts

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