resolver

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: GPL-3.0 Imports: 10 Imported by: 25

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultResolver aim to resolve ip
	DefaultResolver Resolver

	// DisableIPv6 means don't resolve ipv6 host
	// default value is true
	DisableIPv6 = true

	// DefaultHosts aim to resolve hosts
	DefaultHosts = trie.New()

	// DefaultDNSTimeout defined the default dns request timeout
	DefaultDNSTimeout = time.Second * 5
)
View Source
var (
	ErrIPNotFound   = errors.New("couldn't find ip")
	ErrIPVersion    = errors.New("ip version error")
	ErrIPv6Disabled = errors.New("ipv6 disabled")
)

Functions

func FakeIPEnabled added in v1.2.0

func FakeIPEnabled() bool

func FindHostByIP added in v1.2.0

func FindHostByIP(ip net.IP) (string, bool)

func IsExistFakeIP added in v1.3.0

func IsExistFakeIP(ip net.IP) bool

func IsFakeIP added in v1.2.0

func IsFakeIP(ip net.IP) bool

func LookupIP added in v1.11.8

func LookupIP(ctx context.Context, host string) ([]net.IP, error)

ResolveIP with a host, return ip

func LookupIPWithResolver added in v1.11.8

func LookupIPWithResolver(ctx context.Context, host string, r Resolver) ([]net.IP, error)

LookupIPWithResolver same as ResolveIP, but with a resolver

func LookupIPv4 added in v1.11.8

func LookupIPv4(ctx context.Context, host string) ([]net.IP, error)

LookupIPv4 with a host, return ipv4 list

func LookupIPv6 added in v1.11.8

func LookupIPv6(ctx context.Context, host string) ([]net.IP, error)

LookupIPv6 with a host, return ipv6 list

func MappingEnabled added in v1.2.0

func MappingEnabled() bool

func ResolveIP

func ResolveIP(host string) (net.IP, error)

ResolveIP with a host, return ip

func ResolveIPv4

func ResolveIPv4(host string) (net.IP, error)

ResolveIPv4 with a host, return ipv4

func ResolveIPv6

func ResolveIPv6(host string) (net.IP, error)

ResolveIPv6 with a host, return ipv6

Types

type Enhancer added in v1.2.0

type Enhancer interface {
	FakeIPEnabled() bool
	MappingEnabled() bool
	IsFakeIP(net.IP) bool
	IsExistFakeIP(net.IP) bool
	FindHostByIP(net.IP) (string, bool)
}
var DefaultHostMapper Enhancer

type Resolver

type Resolver interface {
	LookupIP(ctx context.Context, host string) ([]net.IP, error)
	LookupIPv4(ctx context.Context, host string) ([]net.IP, error)
	LookupIPv6(ctx context.Context, host string) ([]net.IP, error)
	ResolveIP(host string) (ip net.IP, err error)
	ResolveIPv4(host string) (ip net.IP, err error)
	ResolveIPv6(host string) (ip net.IP, err error)
	ExchangeContext(ctx context.Context, m *dns.Msg) (msg *dns.Msg, err error)
}

Jump to

Keyboard shortcuts

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