Documentation
¶
Index ¶
- Constants
- Variables
- func MsgToBuffer(msg *d.Msg) (*buf.Buffer, error)
- func NewDnsConnImpl(tag string, rrCache *rrCache, send func(*dns.Msg) error) *dnsConnImpl
- func NewRrCache(setting RrCacheSetting) *rrCache
- func UnFqdn(domain string) string
- type AllFakeDns
- type Condition
- type ConditionDnsServer
- type Dns
- type DnsConn
- type DnsHandler
- func (s *DnsHandler) HandleFlow(ctx context.Context, dst net.Destination, rw buf.ReaderWriter) error
- func (s *DnsHandler) HandlePacketConn(ctx context.Context, dst net.Destination, rw udp.PacketReaderWriter) error
- func (s *DnsHandler) Tag() string
- func (s *DnsHandler) WithDns(dns dnsServer) *DnsHandler
- func (s *DnsHandler) WithTag(tag string) *DnsHandler
- type DnsMsgMeta
- type DnsResolver
- func (d *DnsResolver) LookupIP(ctx context.Context, host string) ([]net.IP, error)
- func (d *DnsResolver) LookupIPPrefer4(ctx context.Context, host string) ([]net.IP, error)
- func (d *DnsResolver) LookupIPSpeed(ctx context.Context, host string) ([]net.IP, error)
- func (d *DnsResolver) LookupIPv4(ctx context.Context, host string) ([]net.IP, error)
- func (d *DnsResolver) LookupIPv6(ctx context.Context, host string) ([]net.IP, error)
- type DnsRule
- type DnsServer
- type DnsServerConcurrent
- func (ns *DnsServerConcurrent) Close() error
- func (ns *DnsServerConcurrent) HandleQuery(ctx context.Context, msg *dns.Msg, tcp bool) (*dns.Msg, error)
- func (ns DnsServerConcurrent) ReadPacket() (*udp.Packet, error)
- func (d *DnsServerConcurrent) RemoveDest(remove net.AddressPort, fallback []net.AddressPort)
- func (d *DnsServerConcurrent) SetDests(dests []net.AddressPort)
- func (ns *DnsServerConcurrent) Start() error
- func (ns DnsServerConcurrent) WritePacket(p *udp.Packet) error
- type DnsServerConcurrentOption
- type DnsServerSerial
- func (d *DnsServerSerial) Close() error
- func (d *DnsServerSerial) HandleQuery(ctx context.Context, msg *dns.Msg, tcp bool) (*dns.Msg, error)
- func (d *DnsServerSerial) RemoveDest(toBeRemoved net.AddressPort, fallback []net.AddressPort)
- func (d *DnsServerSerial) ReplaceDests(dests []net.AddressPort)
- func (d *DnsServerSerial) Start() error
- type DnsServerToResolver
- func (d *DnsServerToResolver) LookupECH(ctx context.Context, domain string) ([]byte, error)
- func (d *DnsServerToResolver) LookupIP(ctx context.Context, host string) ([]net.IP, error)
- func (d *DnsServerToResolver) LookupIPPrefer4(ctx context.Context, host string) ([]net.IP, error)
- func (d *DnsServerToResolver) LookupIPv4(ctx context.Context, host string) ([]net.IP, error)
- func (d *DnsServerToResolver) LookupIPv6(ctx context.Context, host string) ([]net.IP, error)
- type DnsToDnsServer
- type DoHNameServer
- type DoHNameServerOption
- type DomainAndResolver
- type ExcludeDomainCondition
- type FakeDns
- func (*FakeDns) Close() error
- func (f *FakeDns) GetDomainFromFakeDNS(ip net.Address) string
- func (f *FakeDns) GetResolver(domain string, ip net.Address) (string, bool)
- func (f *FakeDns) HandleQuery(ctx context.Context, msg *dns.Msg, _ bool) (*dns.Msg, error)
- func (f *FakeDns) IsIPInIPPool(ip net.Address) bool
- func (*FakeDns) Name() string
- func (*FakeDns) Start() error
- type FakeDnsCondition
- type HasSrcCondition
- type IPOption
- type IPToDomain
- type IncludedTypesCondition
- type InternalDns
- func (d *InternalDns) Close() error
- func (d *InternalDns) LookupIP(ctx context.Context, host string) ([]net.IP, error)
- func (d *InternalDns) LookupIPSpeed(ctx context.Context, host string) ([]net.IP, error)
- func (d *InternalDns) LookupIPv4(ctx context.Context, host string) ([]net.IP, error)
- func (d *InternalDns) LookupIPv6(ctx context.Context, host string) ([]net.IP, error)
- func (d *InternalDns) Start() error
- type IpOptionDnsServer
- type Pool
- type PoolConfig
- type Pools
- type Prefer4IPResolver
- type PreferDomainCondition
- type QUICNameServer
- type QuicNameServerOption
- type ResolverGetter
- type RrCacheSetting
- type StaticDnsServer
Constants ¶
const NextProtoDQ = "doq"
NextProtoDQ - During connection establishment, DNS/QUIC support is indicated by selecting the ALPN token "doq" in the crypto handshake.
Variables ¶
var ErrAllServersFailed = errors.New("all dns servers failed")
var ErrConditionNotMatch = errors.New("condition not match")
var ErrNoQuestion = errors.New("no question in dns query")
var ErrNotFound = errors.New("not found")
Functions ¶
func NewDnsConnImpl ¶
func NewRrCache ¶
func NewRrCache(setting RrCacheSetting) *rrCache
Types ¶
type AllFakeDns ¶
type AllFakeDns struct {
// contains filtered or unexported fields
}
func (*AllFakeDns) AddFakeDns ¶
func (a *AllFakeDns) AddFakeDns(fakeDns *FakeDns)
func (*AllFakeDns) GetDomainFromFakeDNS ¶
func (a *AllFakeDns) GetDomainFromFakeDNS(ip net.Address) string
func (*AllFakeDns) IsIPInIPPool ¶
func (a *AllFakeDns) IsIPInIPPool(ip net.Address) bool
type Condition ¶
type Condition interface {
Match(msg *DnsMsgMeta) bool
}
type ConditionDnsServer ¶
type ConditionDnsServer struct {
DnsServer
// contains filtered or unexported fields
}
func NewConditionDnsServer ¶
func NewConditionDnsServer(dnsServer DnsServer, conditions ...Condition) *ConditionDnsServer
func (*ConditionDnsServer) MatchConditions ¶
func (d *ConditionDnsServer) MatchConditions(msg *DnsMsgMeta) bool
type DnsHandler ¶
type DnsHandler struct {
// contains filtered or unexported fields
}
intercept dns queries and send back dns responses
func NewHandlerV ¶
func NewHandlerV() *DnsHandler
func (*DnsHandler) HandleFlow ¶
func (s *DnsHandler) HandleFlow(ctx context.Context, dst net.Destination, rw buf.ReaderWriter) error
implements i.FlowHandler
func (*DnsHandler) HandlePacketConn ¶
func (s *DnsHandler) HandlePacketConn(ctx context.Context, dst net.Destination, rw udp.PacketReaderWriter) error
func (*DnsHandler) Tag ¶
func (s *DnsHandler) Tag() string
func (*DnsHandler) WithDns ¶
func (s *DnsHandler) WithDns(dns dnsServer) *DnsHandler
func (*DnsHandler) WithTag ¶
func (s *DnsHandler) WithTag(tag string) *DnsHandler
type DnsMsgMeta ¶
type DnsMsgMeta struct {
*dns.Msg
Src *net.Destination
}
func (*DnsMsgMeta) Tcp ¶
func (d *DnsMsgMeta) Tcp() bool
type DnsResolver ¶
func NewGoIpResolver ¶
func NewGoIpResolver() *DnsResolver
func (*DnsResolver) LookupIPPrefer4 ¶
func (*DnsResolver) LookupIPSpeed ¶
func (*DnsResolver) LookupIPv4 ¶
func (*DnsResolver) LookupIPv6 ¶
type DnsServerConcurrent ¶
type DnsServerConcurrent struct {
// contains filtered or unexported fields
}
reuse conn for dns query
func NewDnsServerConcurrent ¶
func NewDnsServerConcurrent(opts DnsServerConcurrentOption) *DnsServerConcurrent
func (*DnsServerConcurrent) Close ¶
func (ns *DnsServerConcurrent) Close() error
func (*DnsServerConcurrent) HandleQuery ¶
func (ns *DnsServerConcurrent) HandleQuery(ctx context.Context, msg *dns.Msg, tcp bool) (*dns.Msg, error)
msg should be standard dns query message: has only one question, opcode is QUERY
func (DnsServerConcurrent) ReadPacket ¶
func (*DnsServerConcurrent) RemoveDest ¶
func (d *DnsServerConcurrent) RemoveDest(remove net.AddressPort, fallback []net.AddressPort)
func (*DnsServerConcurrent) SetDests ¶
func (d *DnsServerConcurrent) SetDests(dests []net.AddressPort)
func (*DnsServerConcurrent) Start ¶
func (ns *DnsServerConcurrent) Start() error
func (DnsServerConcurrent) WritePacket ¶
msg should be standard dns query message: has only one question, opcode is QUERY, no other fancy stuff.
type DnsServerConcurrentOption ¶
type DnsServerConcurrentOption struct {
Name string
NameserverAddrs []net.AddressPort
Handler i.FlowHandler
IPToDomain *IPToDomain
Tls bool
ClientIp net.IP
Dispatcher packetDispatcher
RrCache *rrCache
}
type DnsServerSerial ¶
does not reuse conn for dns query
func NewDnsServerSerial ¶
func NewDnsServerSerial(dests []net.AddressPort, dialer i.Dialer, ipToDomain *IPToDomain) *DnsServerSerial
func (*DnsServerSerial) Close ¶
func (d *DnsServerSerial) Close() error
func (*DnsServerSerial) HandleQuery ¶
func (*DnsServerSerial) RemoveDest ¶
func (d *DnsServerSerial) RemoveDest(toBeRemoved net.AddressPort, fallback []net.AddressPort)
func (*DnsServerSerial) ReplaceDests ¶
func (d *DnsServerSerial) ReplaceDests(dests []net.AddressPort)
func (*DnsServerSerial) Start ¶
func (d *DnsServerSerial) Start() error
type DnsServerToResolver ¶
type DnsServerToResolver struct {
DnsServers []DnsServer
}
func NewDnsServerToResolver ¶
func NewDnsServerToResolver(dnsServers ...DnsServer) *DnsServerToResolver
func (*DnsServerToResolver) LookupIPPrefer4 ¶
func (*DnsServerToResolver) LookupIPv4 ¶
func (*DnsServerToResolver) LookupIPv6 ¶
type DnsToDnsServer ¶
type DnsToDnsServer struct {
*Dns
}
type DoHNameServer ¶
DoHNameServer implemented DNS over HTTPS (RFC8484) Wire Format, which is compatible with traditional dns over udp(RFC1035), thus most of the DOH implementation is copied from udpns.go
func NewDoHNameServer ¶
func NewDoHNameServer(option DoHNameServerOption) (*DoHNameServer, error)
NewDoHNameServer creates DOH server object for remote resolving.
func (*DoHNameServer) Close ¶
func (d *DoHNameServer) Close() error
func (*DoHNameServer) HandleQuery ¶
func (*DoHNameServer) Name ¶
func (d *DoHNameServer) Name() string
func (*DoHNameServer) Start ¶
func (d *DoHNameServer) Start() error
type DoHNameServerOption ¶
type DoHNameServerOption struct {
ClientIP net.IP
Handler i.FlowHandler
Name string
Url string
IpToDomain *IPToDomain
Tls *tls.Config
RrCache *rrCache
}
type DomainAndResolver ¶
type ExcludeDomainCondition ¶
type FakeDns ¶
type FakeDns struct {
// contains filtered or unexported fields
}
func NewFakeDns ¶
func (*FakeDns) GetDomainFromFakeDNS ¶
func (*FakeDns) GetResolver ¶
func (*FakeDns) HandleQuery ¶
type FakeDnsCondition ¶
func (*FakeDnsCondition) Match ¶
func (f *FakeDnsCondition) Match(msg *DnsMsgMeta) bool
type HasSrcCondition ¶
type HasSrcCondition struct{}
func (*HasSrcCondition) Match ¶
func (h *HasSrcCondition) Match(msg *DnsMsgMeta) bool
type IPToDomain ¶
type IPToDomain struct {
// contains filtered or unexported fields
}
func NewIPToDomain ¶
func NewIPToDomain(size int) *IPToDomain
func (*IPToDomain) GetResolvers ¶
type IncludedTypesCondition ¶
type IncludedTypesCondition struct {
Types []uint16
}
func (*IncludedTypesCondition) Match ¶
func (i *IncludedTypesCondition) Match(msg *DnsMsgMeta) bool
type InternalDns ¶
type InternalDns struct {
StaticDns *StaticDnsServer
DnsServers []DnsServer
DnsServerToIPResolver *DnsServerToResolver
}
for dialer to lookup ip when dialing
func NewInternalDns ¶
func NewInternalDns(staticDns *StaticDnsServer, DnsServers ...DnsServer) *InternalDns
func (*InternalDns) Close ¶
func (d *InternalDns) Close() error
func (*InternalDns) LookupIPSpeed ¶
func (*InternalDns) LookupIPv4 ¶
func (*InternalDns) LookupIPv6 ¶
func (*InternalDns) Start ¶
func (d *InternalDns) Start() error
type IpOptionDnsServer ¶
if ip option conflicts, return a response with no answer
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func (*Pool) GetDomainFromFakeIP ¶
GetDomainFromFakeIP checks if an IP is a fake IP and have corresponding domain name
func (*Pool) GetFakeIPForDomain ¶
GetFakeIPForDomain checks if there is already an ip for domain first, if so returns the ip; if not generate a new fake IP for domain
type PoolConfig ¶
type Prefer4IPResolver ¶
type Prefer4IPResolver struct {
i.IPResolver
}
type PreferDomainCondition ¶
type PreferDomainCondition struct {
DomainSet i.DomainSet
// contains filtered or unexported fields
}
func (*PreferDomainCondition) Match ¶
func (p *PreferDomainCondition) Match(msg *DnsMsgMeta) bool
type QUICNameServer ¶
QUICNameServer implemented DNS over QUIC
func NewQUICNameServer ¶
func NewQUICNameServer(option QuicNameServerOption) (*QUICNameServer, error)
NewQUICNameServer creates DNS-over-QUIC client object for local resolving
func (*QUICNameServer) Close ¶
func (s *QUICNameServer) Close() error
func (*QUICNameServer) HandleQuery ¶
QueryIP is called from dns.Server->queryIPTimeout
func (*QUICNameServer) Name ¶
func (s *QUICNameServer) Name() string
func (*QUICNameServer) Start ¶
func (s *QUICNameServer) Start() error
type QuicNameServerOption ¶
type QuicNameServerOption struct {
Name string
Destination net.Destination
ClientIp net.IP
Handler i.PacketHandler
IpToDomain *IPToDomain
IPResolver i.IPResolver
RrCache *rrCache
}
type ResolverGetter ¶
type RrCacheSetting ¶ added in v1.0.2
type RrCacheSetting struct {
Duration uint32
}
type StaticDnsServer ¶
type StaticDnsServer struct {
// contains filtered or unexported fields
}
func NewStaticDnsServer ¶
func NewStaticDnsServer(records []*configs.Record) *StaticDnsServer