dns

package
v0.0.0-...-317432a Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: GPL-3.0 Imports: 33 Imported by: 0

README

trie.(*DomainTrie).Search (domain.go:94) github.com/finddiff/RuleBaseProxy/component/trie dns.withHosts.func1.1 (middleware.go:29) github.com/finddiff/RuleBaseProxy/dns dns.handlerWithContext (server.go:47) github.com/finddiff/RuleBaseProxy/dns dns.(*Server).ServeDNS (server.go:28) github.com/finddiff/RuleBaseProxy/dns dns.(*Server).serveDNS (server.go:659) github.com/miekg/dns dns.(*Server).serveUDPPacket (server.go:603) github.com/miekg/dns dns.(*Server).serveUDP.func3 (server.go:533) github.com/miekg/dns runtime.goexit (asm_arm64.s:1172) runtime

  • Async Stack Trace dns.(*Server).serveUDP (server.go:533) github.com/miekg/dns

Documentation

Index

Constants

View Source
const (
	IfaceTTL    = time.Second * 20
	DHCPTTL     = time.Hour
	DHCPTimeout = time.Minute
)
View Source
const MapDomainDnsMsg string = "mapDomain-DnsMsg"
View Source
const MapIPDomain string = "mapIP-Domain"

const MapDomainIPs string = "mapDomain-IPs" const MapDomainIPttl string = "mapDomainIP-ttl"

View Source
const MaxDnsMsgAge = 3 * 24 * 3600

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 Byte2DnsMsg

func Byte2DnsMsg(buf []byte) (dnsMsg D.Msg, err error)

func DnsMapAdd

func DnsMapAdd(dnsMap DnsMap)

func DnsMapOnEvict

func DnsMapOnEvict(key interface{}, value interface{})

func DnsMsg2Byte

func DnsMsg2Byte(p interface{}) (rb []byte, err error)

func DnsMsgAdd

func DnsMsgAdd(dnsMsg DnsMsgMap)

func IPDomainMapOnEvict

func IPDomainMapOnEvict(key interface{}, value interface{})

func NewDomainFilter

func NewDomainFilter(domains []string) *domainFilter

func ReCreateServer

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

Types

type Config

type Config struct {
	Main, Fallback []NameServer
	Default        []NameServer
	IPv6           bool
	EnhancedMode   EnhancedMode
	FallbackFilter FallbackFilter
	Pool           *fakeip.Pool
	Hosts          *trie.DomainTrie
	Policy         map[string]NameServer
}

type DnsMap

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

type DnsMsgMap

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

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() (interface{}, 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
	GeoIPCode string
	IPCIDR    []*net.IPNet
	Domain    []string
}

type NameServer

type NameServer struct {
	Net  string
	Addr string
}

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, err error)

Exchange a batch of dns request, and it use cache

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

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

ResolveIP request with TypeA and TypeAAAA, priority return TypeA

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 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 net.IP) (string, bool)

func (*ResolverEnhancer) IsExistFakeIP

func (h *ResolverEnhancer) IsExistFakeIP(ip net.IP) bool

func (*ResolverEnhancer) IsFakeIP

func (h *ResolverEnhancer) IsFakeIP(ip net.IP) bool

func (*ResolverEnhancer) MappingEnabled

func (h *ResolverEnhancer) MappingEnabled() bool

func (*ResolverEnhancer) PatchFrom

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

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

Jump to

Keyboard shortcuts

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