dns

package
v0.0.0-...-72cc9c9 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// EnhancedModeMapping is a mapping for EnhancedMode enum
	EnhancedModeMapping = map[string]EnhancedMode{
		NORMAL.String():  NORMAL,
		FAKEIP.String():  FAKEIP,
		MAPPING.String(): MAPPING,
	}
)

Functions

func ReCreateServer

func ReCreateServer(addr string, resolver *Resolver) error

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 Config

type Config struct {
	Main, Fallback []NameServer
	IPv6           bool
	EnhancedMode   EnhancedMode
	FallbackFilter FallbackFilter
	Pool           *fakeip.Pool
}

type EnhancedMode

type EnhancedMode int
const (
	NORMAL EnhancedMode = iota
	FAKEIP
	MAPPING
)

func (EnhancedMode) MarshalJSON

func (e EnhancedMode) MarshalJSON() ([]byte, error)

MarshalJSON serialize EnhancedMode with json

func (EnhancedMode) MarshalYAML

func (e EnhancedMode) MarshalYAML() ([]byte, error)

MarshalYAML serialize EnhancedMode with yaml

func (EnhancedMode) String

func (e EnhancedMode) String() string

func (*EnhancedMode) UnmarshalJSON

func (e *EnhancedMode) UnmarshalJSON(data []byte) error

UnmarshalJSON unserialize EnhancedMode with json

func (*EnhancedMode) UnmarshalYAML

func (e *EnhancedMode) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unserialize EnhancedMode with yaml

type FallbackFilter

type FallbackFilter struct {
	GeoIP  bool
	IPCIDR []*net.IPNet
}

type NameServer

type NameServer struct {
	Net  string
	Addr string
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}
var (
	// DefaultResolver aim to resolve ip
	DefaultResolver *Resolver

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

func New

func New(config Config) *Resolver

func (*Resolver) Exchange

func (r *Resolver) Exchange(m *D.Msg) (msg *D.Msg, err error)

Exchange a batch of dns request, and it use cache

func (*Resolver) IPToHost

func (r *Resolver) IPToHost(ip net.IP) (string, bool)

IPToHost return fake-ip or redir-host mapping host

func (*Resolver) IsFakeIP

func (r *Resolver) IsFakeIP() bool

func (*Resolver) IsMapping

func (r *Resolver) IsMapping() bool

func (*Resolver) ResolveIP

func (r *Resolver) ResolveIP(host string) (ip net.IP, err error)

ResolveIP request with TypeA and TypeAAAA, priority return TypeAAAA

func (*Resolver) ResolveIPv4

func (r *Resolver) ResolveIPv4(host string) (ip net.IP, err error)

ResolveIPv4 request with TypeA

func (*Resolver) ResolveIPv6

func (r *Resolver) ResolveIPv6(host string) (ip net.IP, err error)

ResolveIPv6 request with TypeAAAA

type Server

type Server struct {
	*D.Server
	// contains filtered or unexported fields
}

func (*Server) ServeDNS

func (s *Server) ServeDNS(w D.ResponseWriter, r *D.Msg)

Jump to

Keyboard shortcuts

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