dns

package
v0.0.0-...-4d950b6 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: GPL-3.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IfaceTTL    = time.Second * 20
	DHCPTTL     = time.Hour
	DHCPTimeout = time.Minute
)
View Source
const (
	// QUICCodeNoError is used when the connection or stream needs to be closed,
	// but there is no error to signal.
	QUICCodeNoError = quic.ApplicationErrorCode(0)
	// QUICCodeInternalError signals that the DoQ implementation encountered
	// an internal error and is incapable of pursuing the transaction or the
	// connection.
	QUICCodeInternalError = quic.ApplicationErrorCode(1)
	// QUICKeepAlivePeriod is the value that we pass to *quic.Config and that
	// controls the period with with keep-alive frames are being sent to the
	// connection. We set it to 20s as it would be in the quic-go@v0.27.1 with
	// KeepAlive field set to true This value is specified in
	// https://pkg.go.dev/github.com/metacubex/quic-go/internal/protocol#MaxKeepAliveInterval.
	//
	// TODO(ameshkov):  Consider making it configurable.
	QUICKeepAlivePeriod = time.Second * 20
	DefaultTimeout      = time.Second * 5
)
View Source
const (
	SystemDnsFlushTime   = 5 * time.Minute
	SystemDnsDeleteTimes = 12 // 12*5 = 60min
)
View Source
const (
	MaxMsgSize = 65535
)
View Source
const NextProtoDQ = "doq"

Variables

View Source
var DefaultHTTPVersions = []C.HTTPVersion{C.HTTPVersion11, C.HTTPVersion2}
View Source
var ParseNameServer func(servers []string) ([]NameServer, error) // define in config/config.go

Functions

func AddPrefix

func AddPrefix(b []byte) (m []byte)

AddPrefix adds a 2-byte prefix with the DNS message length.

func NewDomainFilter

func NewDomainFilter(domains []string) *domainFilter

func NewGeoSite

func NewGeoSite(group string) (fallbackDomainFilter, error)

func NewHandler

func NewHandler(resolver *Resolver, mapper *ResolverEnhancer) handler

func ReCreateServer

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

func UpdateIsolateHandler

func UpdateIsolateHandler(resolver *Resolver, mapper *ResolverEnhancer)

Types

type Config

type Config struct {
	Main, Fallback []NameServer
	Default        []NameServer
	ProxyServer    []NameServer
	IPv6           bool
	IPv6Timeout    uint
	EnhancedMode   C.DNSMode
	FallbackFilter FallbackFilter
	Pool           *fakeip.Pool
	Hosts          *trie.DomainTrie[resolver.HostValue]
	Policy         *orderedmap.OrderedMap[string, []NameServer]
	RuleProviders  map[string]provider.RuleProvider
	CacheAlgorithm 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(ctx context.Context, msg *D.Msg) (*D.Msg, error)

ServeMsg implement resolver.LocalServer ResolveMsg

type NameServer

type NameServer struct {
	Net          string
	Addr         string
	Interface    string
	ProxyAdapter C.ProxyAdapter
	ProxyName    string
	Params       map[string]string
	PreferH3     bool
}

func (NameServer) Equal

func (ns NameServer) Equal(ns2 NameServer) bool

type Resolver

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

func NewProxyServerHostResolver

func NewProxyServerHostResolver(old *Resolver) *Resolver

func NewResolver

func NewResolver(config Config) *Resolver

func (*Resolver) ExchangeContext

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

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

func (*Resolver) Invalid

func (r *Resolver) Invalid() bool

Invalid return this resolver can or can't be used

func (*Resolver) LookupIP

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

func (*Resolver) LookupIPPrimaryIPv4

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

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

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) InsertHostByIP

func (h *ResolverEnhancer) InsertHostByIP(ip netip.Addr, host string)

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) 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