dns

package
v1.65.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IfaceTTL    = time.Second * 20
	DHCPTTL     = time.Hour
	DHCPTimeout = time.Minute
)

Variables

This section is empty.

Functions

func NewDomainFilter

func NewDomainFilter(domains []string) *domainFilter

func ReCreateServer

func ReCreateServer(addr string, resolver *Resolver, mapper *ResolverEnhancer)

Types

type Config

type Config struct {
	Main, Fallback []NameServer
	Default        []NameServer
	ProxyServer    []NameServer
	Remote         []NameServer
	IPv6           bool
	EnhancedMode   C.DNSMode
	FallbackFilter FallbackFilter
	Pool           *fakeip.Pool
	Hosts          *trie.DomainTrie[netip.Addr]
	Policy         map[string]NameServer
	SearchDomains  []string
}

type FallbackFilter

type FallbackFilter struct {
	GeoIP     bool
	GeoIPCode string
	IPCIDR    []*netip.Prefix
	Domain    []string
	GeoSite   []*router.DomainMatcher
}

type LocalServer

type LocalServer struct {
	// contains filtered or unexported fields
}

func NewLocalServer

func NewLocalServer(resolver *Resolver, mapper *ResolverEnhancer) *LocalServer

func (*LocalServer) ServeMsg

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

ServeMsg implement resolver.LocalServer ResolveMsg

type LogAnswer

type LogAnswer struct {
	// contains filtered or unexported fields
}

func (LogAnswer) MarshalObject

func (l LogAnswer) MarshalObject(e *log.Entry)

type NameServer

type NameServer struct {
	Net       string
	Addr      string
	Interface string
	Proxy     string
	IsDHCP    bool
}

type Policy

type Policy struct {
	// contains filtered or unexported fields
}

func NewPolicy

func NewPolicy(data []dnsClient) *Policy

func (*Policy) Compare

func (p *Policy) Compare(p2 *Policy) int

func (*Policy) GetData

func (p *Policy) GetData() []dnsClient

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func NewResolver

func NewResolver(config Config) *Resolver

func (*Resolver) Exchange

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

Exchange a batch of dns request, and it uses cache

func (*Resolver) ExchangeContext

func (r *Resolver) ExchangeContext(ctx context.Context, m *D.Msg) (msg *D.Msg, source string, err error)

ExchangeContext a batch of dns request with context.Context, and it uses cache

func (*Resolver) ExchangeContextWithoutCache

func (r *Resolver) ExchangeContextWithoutCache(ctx context.Context, m *D.Msg) (msg *D.Msg, source string, err error)

ExchangeContextWithoutCache a batch of dns request with context.Context

func (*Resolver) LookupIP

func (r *Resolver) LookupIP(ctx context.Context, host string) (ip []netip.Addr, err error)

LookupIP request with TypeA and TypeAAAA, priority return TypeA

func (*Resolver) LookupIPv4

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

LookupIPv4 request with TypeA

func (*Resolver) LookupIPv6

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

LookupIPv6 request with TypeAAAA

func (*Resolver) RemoveCache

func (r *Resolver) RemoveCache(host string)

func (*Resolver) ResolveIP

func (r *Resolver) ResolveIP(host string) (ip netip.Addr, err error)

ResolveIP request with TypeA and TypeAAAA, priority return TypeA

func (*Resolver) ResolveIPv4

func (r *Resolver) ResolveIPv4(host string) (ip netip.Addr, err error)

ResolveIPv4 request with TypeA

func (*Resolver) ResolveIPv6

func (r *Resolver) ResolveIPv6(host string) (ip netip.Addr, err error)

ResolveIPv6 request with TypeAAAA

type ResolverEnhancer

type ResolverEnhancer struct {
	// contains filtered or unexported fields
}

func NewEnhancer

func NewEnhancer(cfg Config) *ResolverEnhancer

func (*ResolverEnhancer) FakeIPEnabled

func (h *ResolverEnhancer) FakeIPEnabled() bool

func (*ResolverEnhancer) FindHostByIP

func (h *ResolverEnhancer) FindHostByIP(ip netip.Addr) (string, bool)

func (*ResolverEnhancer) FlushFakeIP

func (h *ResolverEnhancer) FlushFakeIP() error

func (*ResolverEnhancer) IsExistFakeIP

func (h *ResolverEnhancer) IsExistFakeIP(ip netip.Addr) bool

func (*ResolverEnhancer) IsFakeBroadcastIP

func (h *ResolverEnhancer) IsFakeBroadcastIP(ip netip.Addr) bool

func (*ResolverEnhancer) IsFakeIP

func (h *ResolverEnhancer) IsFakeIP(ip netip.Addr) bool

func (*ResolverEnhancer) MappingEnabled

func (h *ResolverEnhancer) MappingEnabled() bool

func (*ResolverEnhancer) PatchFrom

func (h *ResolverEnhancer) PatchFrom(o *ResolverEnhancer)

func (*ResolverEnhancer) SniffingEnabled

func (h *ResolverEnhancer) SniffingEnabled() bool

func (*ResolverEnhancer) StoreFakePoolState

func (h *ResolverEnhancer) StoreFakePoolState()

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)

ServeDNS implement D.Handler ServeDNS

func (*Server) SetHandler

func (s *Server) SetHandler(handler handler)

Jump to

Keyboard shortcuts

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