resolver

package
v1.31.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

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

	// RemoteDnsResolve reports whether TCP/UDP handler should be remote resolve DNS
	// default value is true
	RemoteDnsResolve = true

	// DefaultHosts aim to resolve hosts
	DefaultHosts = trie.New[netip.Addr]()

	// 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 CopyCtxValues

func CopyCtxValues(parent context.Context) context.Context

CopyCtxValues returns a new context with parent's values

func FakeIPEnabled

func FakeIPEnabled() bool

func FindHostByIP

func FindHostByIP(ip netip.Addr) (string, bool)

func FlushFakeIP

func FlushFakeIP() error

func GetProxy

func GetProxy(ctx context.Context) (string, bool)

GetProxy reports the proxy name used by the DNS client and whether there is a proxy

func InsertHostByIP

func InsertHostByIP(ip netip.Addr, host string)

func IsExistFakeIP

func IsExistFakeIP(ip netip.Addr) bool

func IsFakeBroadcastIP

func IsFakeBroadcastIP(ip netip.Addr) bool

func IsFakeIP

func IsFakeIP(ip netip.Addr) bool

func IsProxyServer

func IsProxyServer(ctx context.Context) bool

IsProxyServer reports whether the DefaultResolver should be exchanged by proxyServer DNS client

func IsRemote

func IsRemote(ctx context.Context) bool

IsRemote reports whether the DefaultResolver should be exchanged by remote DNS client

func LookupIP

func LookupIP(ctx context.Context, host string) ([]netip.Addr, error)

LookupIP with a host, return ip list

func LookupIPByProxy

func LookupIPByProxy(ctx context.Context, host, proxy string) ([]netip.Addr, error)

LookupIPByProxy with a host and proxy, reports force combined ipv6 list whether the DisableIPv6 value is true

func LookupIPByResolver

func LookupIPByResolver(ctx context.Context, host string, r Resolver) ([]netip.Addr, error)

LookupIPByResolver same as ResolveIP, but with a resolver

func LookupIPv4

func LookupIPv4(ctx context.Context, host string) ([]netip.Addr, error)

LookupIPv4 with a host, return ipv4 list

func LookupIPv4ByProxy

func LookupIPv4ByProxy(ctx context.Context, host, proxy string) ([]netip.Addr, error)

LookupIPv4ByProxy with a host and proxy, reports ipv4 list

func LookupIPv6

func LookupIPv6(ctx context.Context, host string) ([]netip.Addr, error)

LookupIPv6 with a host, return ipv6 list

func LookupIPv6ByProxy

func LookupIPv6ByProxy(ctx context.Context, host, proxy string) ([]netip.Addr, error)

LookupIPv6ByProxy with a host and proxy, reports ipv6 list whether the DisableIPv6 value is true

func MappingEnabled

func MappingEnabled() bool

func RemoveCache

func RemoveCache(host string)

RemoveCache remove cache by host

func ResolveIP

func ResolveIP(host string) (netip.Addr, error)

ResolveIP with a host, return ip

func ResolveIPv4

func ResolveIPv4(host string) (netip.Addr, error)

ResolveIPv4 with a host, return ipv4

func ResolveIPv4ProxyServerHost

func ResolveIPv4ProxyServerHost(host string) (netip.Addr, error)

ResolveIPv4ProxyServerHost proxies server host only

func ResolveIPv6

func ResolveIPv6(host string) (netip.Addr, error)

ResolveIPv6 with a host, return ipv6

func ResolveIPv6ProxyServerHost

func ResolveIPv6ProxyServerHost(host string) (netip.Addr, error)

ResolveIPv6ProxyServerHost proxies server host only

func ResolveProxyServerHost

func ResolveProxyServerHost(host string) (netip.Addr, error)

ResolveProxyServerHost proxies server host only

func ServeMsg

func ServeMsg(msg *D.Msg) (*D.Msg, error)

ServeMsg with a dns.Msg, return resolve dns.Msg

func SetDisableIPv6

func SetDisableIPv6(v bool)

SetDisableIPv6 set DisableIPv6 & needProxyHostIPv6 value

func StoreFakePoolState

func StoreFakePoolState()

func WithProxy

func WithProxy(ctx context.Context, proxy string) context.Context

WithProxy returns a new context with proxy name

Types

type Enhancer

type Enhancer interface {
	FakeIPEnabled() bool
	MappingEnabled() bool
	IsFakeIP(netip.Addr) bool
	IsFakeBroadcastIP(netip.Addr) bool
	IsExistFakeIP(netip.Addr) bool
	FindHostByIP(netip.Addr) (string, bool)
	FlushFakeIP() error
	InsertHostByIP(netip.Addr, string)
	StoreFakePoolState()
}
var DefaultHostMapper Enhancer

type LocalServer

type LocalServer interface {
	ServeMsg(msg *D.Msg) (*D.Msg, error)
}
var DefaultLocalServer LocalServer

type Resolver

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

Jump to

Keyboard shortcuts

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