resolver

package
v0.0.0-...-900dcfe Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hairpin

func Hairpin(fn packetHandlerFn) *hairpin

func NewInMemoryResolver

func NewInMemoryResolver(d *ResolverStub) *net.Resolver

NewInMemoryResolver receives a ResolverStub object with the override functions and returns a resolver that can be used as custom Resolver implementation

Types

type HairpinDialer

type HairpinDialer struct {
	PacketHandler packetHandlerFn
}

Dialer

func (*HairpinDialer) Dial

func (h *HairpinDialer) Dial(ctx context.Context, network, address string) (net.Conn, error)

Dial creates an in memory connection that is processed by the packet handler

type HairpinListener

type HairpinListener struct {
	PacketHandler packetHandlerFn
	// contains filtered or unexported fields
}

Listener

func (*HairpinListener) Accept

func (h *HairpinListener) Accept() (net.Conn, error)

func (*HairpinListener) Addr

func (h *HairpinListener) Addr() net.Addr

func (*HairpinListener) Close

func (h *HairpinListener) Close() error

func (*HairpinListener) Listen

func (h *HairpinListener) Listen(network, address string) (net.Listener, error)

type ResolverStub

type ResolverStub struct {
	LookupAddr  func(ctx context.Context, addr string) (names []string, err error)
	LookupCNAME func(ctx context.Context, host string) (cname string, err error)
	LookupHost  func(ctx context.Context, host string) (addrs []string, err error)
	LookupIP    func(ctx context.Context, network, host string) ([]net.IP, error)
	LookupMX    func(ctx context.Context, name string) ([]*net.MX, error)
	LookupNS    func(ctx context.Context, name string) ([]*net.NS, error)
	LookupPort  func(ctx context.Context, network, service string) (port int, err error)
	LookupSRV   func(ctx context.Context, service, proto, name string) (cname string, addrs []*net.SRV, err error)
	LookupTXT   func(ctx context.Context, name string) ([]string, error)
}

ResolverStub process dns packets executing the corresponding functions overrides if set

func (*ResolverStub) ProcessDNSRequest

func (r *ResolverStub) ProcessDNSRequest(b []byte) []byte

ProcessDNSRequest is used by the MemoryConn to process the packets Transform a DNS request to the corresponding Golang Lookup function

Jump to

Keyboard shortcuts

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