Documentation ¶
Index ¶
- Constants
- Variables
- func CSVtoIPs(csv string) (ips []net.IP, err error)
- func CalculatePaddingLength(preAllocatedLen int, least int, gain int) int
- func GenerateUrlSafeString(n int) string
- func GetMinTTLFromDnsMsg(msg *dns.Msg) (minTTL uint32)
- func InsertIntoSlice(to []interface{}, from interface{}, inex int) []interface{}
- func IsLocalListen(addr string) bool
- func NewLogger() *logrus.Logger
- func ObtainEDN0Subnet(msg *dns.Msg) (edns0Subnet dns.EDNS0_SUBNET)
- func ReplaceEDNS0Padding(msg *dns.Msg, padding *dns.EDNS0_PADDING)
- func ReplaceEDNS0Subnet(msg *dns.Msg, subnet *dns.EDNS0_SUBNET)
- func ResolveHostToIPClosure(name string, resolver string) (closure func() (ip4s []string, ip6s []string))
- type Cache
- type DMProvider
- type DMProviderOptions
- type DNSQuestion
- type DNSQuestions
- type DNSRR
- type DNSRRs
- type Handler
- type HandlerOptions
- type HostsFileProvider
- type HostsFileResolver
- type JSONDNSResponse
- type KeyValue
- type Provider
- type RedBlackTreeExtended
- func (tree *RedBlackTreeExtended) GetMax() (value interface{}, found bool)
- func (tree *RedBlackTreeExtended) GetMin() (value interface{}, found bool)
- func (tree *RedBlackTreeExtended) RemoveMax() (value interface{}, deleted bool)
- func (tree *RedBlackTreeExtended) RemoveMin() (value interface{}, deleted bool)
- type Stub
Constants ¶
const ( // MaxBytesOfDNSName is the maximum number of bytes a DNS name may contain MaxBytesOfDNSName = 253 // EDNSSentinelValue is the value that when sent to Google as the // EDNS value, means "do not use EDNS". EDNSSentinelValue = "0.0.0.0/0" PaddingParameter = "random_padding" ContentType = "application/dns-message" MaxBytesOfDNSMessage = 512 )
Variables ¶
var (
Log = NewLogger()
)
Functions ¶
func CalculatePaddingLength ¶
func GenerateUrlSafeString ¶
func GetMinTTLFromDnsMsg ¶
func InsertIntoSlice ¶
func InsertIntoSlice(to []interface{}, from interface{}, inex int) []interface{}
func IsLocalListen ¶
func ObtainEDN0Subnet ¶
func ObtainEDN0Subnet(msg *dns.Msg) (edns0Subnet dns.EDNS0_SUBNET)
func ReplaceEDNS0Padding ¶
func ReplaceEDNS0Padding(msg *dns.Msg, padding *dns.EDNS0_PADDING)
func ReplaceEDNS0Subnet ¶
func ReplaceEDNS0Subnet(msg *dns.Msg, subnet *dns.EDNS0_SUBNET)
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Use map to store cache, red-black tree to index cache. red-black tree also used to implement the cache expire mechanism.
type DMProvider ¶
type DMProvider struct {
// contains filtered or unexported fields
}
DMProvider is the Google DNS-over-HTTPS provider; it implements the Provider interface, the abbreviation "DM" stands for dns-message.
func NewDMProvider ¶
func NewDMProvider(endpoint string, opts *DMProviderOptions) (*DMProvider, error)
NewDMProvider creates a DMProvider
func (*DMProvider) GetIPsClosure ¶
func (provider *DMProvider) GetIPsClosure(name string) (closure func() (ip4s []string, ip16s []string))
resolve domain name to ips (ipv4 and ipv6) using Dns over HTTPS.
func (*DMProvider) ObtainCurrentExternalIP ¶
func (provider *DMProvider) ObtainCurrentExternalIP(dnsResolver string) (string, error)
obtain external ip through some public apis.
type DMProviderOptions ¶
type DMProviderOptions struct { EndpointIPs []net.IP EDNSSubnet string // Additional headers to be sent with requests to the DNS provider Headers http.Header // Additional query parameters to be sent with requests to the DNS provider QueryParameters map[string][]string // if using http2 for query HTTP2 bool // using specific CA cert file for TLS establishment CACertFilePath string // Reply All AAAA Questions with a Empty Answer NoAAAA bool // use https://dns.google/resolve like endpoint Alternative bool JSONAPI bool // dns resolver for retrieve ip of DoH enpoint host DnsResolver string DnsMsgEncoder base64.Encoding }
DMProviderOptions is a configuration object for optional DMProvider configuration
type DNSQuestion ¶ added in v5.1.1
DNSQuestion represents a DNS question to be resolved by a DNS server
type DNSQuestions ¶ added in v5.1.1
type DNSQuestions []DNSQuestion
type DNSRR ¶ added in v5.1.1
type DNSRR struct { Name string `json:"name,omitempty"` Type uint16 `json:"type,omitempty"` TTL uint32 `json:"TTL,omitempty"` Data string `json:"data,omitempty"` }
DNSRR represents a DNS record, part of a response to a DNSQuestion
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler represents a DNS handler
func NewHandler ¶
func NewHandler(provider Provider, options *HandlerOptions) *Handler
NewHandler creates a new Handler
func (*Handler) AnswerByDoH ¶
func (h *Handler) AnswerByDoH(writer *dns.ResponseWriter, ctx *writerCtx)
func (*Handler) AnswerByHostsFile ¶
func (h *Handler) AnswerByHostsFile(writer *dns.ResponseWriter, ctx *writerCtx)
func (*Handler) Handle ¶
func (h *Handler) Handle(writer dns.ResponseWriter, msg *dns.Msg)
Handle handles a DNS request
func (*Handler) TryWriteAnswer ¶
func (h *Handler) TryWriteAnswer(writer *dns.ResponseWriter, ctx *writerCtx)
type HandlerOptions ¶
HandlerOptions specifies options to be used when instantiating a handler
type HostsFileProvider ¶
type HostsFileProvider struct {
// contains filtered or unexported fields
}
func NewHostsFileProvider ¶
func NewHostsFileProvider() *HostsFileProvider
type HostsFileResolver ¶
hosts contains known host entries.
func (*HostsFileResolver) LookupStaticAddr ¶
func (hosts *HostsFileResolver) LookupStaticAddr(addr string) []string
LookupStaticAddr looks up the hosts for the given address from /etc/hosts.
func (*HostsFileResolver) LookupStaticHost ¶
func (hosts *HostsFileResolver) LookupStaticHost(host string) []string
LookupStaticHost looks up the addresses for the given host from /etc/hosts.
type JSONDNSResponse ¶ added in v5.1.1
type JSONDNSResponse struct { Status int32 `json:"Status"` TC bool `json:"TC"` RD bool `json:"RD"` RA bool `json:"RA"` AD bool `json:"AD"` CD bool `json:"CD"` Question DNSQuestions `json:"Question,omitempty"` Answer DNSRRs `json:"Answer,omitempty"` Authority DNSRRs `json:"Authority,omitempty"` Additional DNSRRs `json:"Additional,omitempty"` EDNSClientSubnet string `json:"edns_client_subnet,omitempty"` Comment string `json:"Comment,omitempty"` }
JSONDNSResponse represents a response from the Google DNS-over-HTTPS servers
type RedBlackTreeExtended ¶
RedBlackTreeExtended to demonstrate how to extend a RedBlackTree to include new functions
func (*RedBlackTreeExtended) GetMax ¶
func (tree *RedBlackTreeExtended) GetMax() (value interface{}, found bool)
GetMax gets the max value and flag if found
func (*RedBlackTreeExtended) GetMin ¶
func (tree *RedBlackTreeExtended) GetMin() (value interface{}, found bool)
GetMin gets the min value and flag if found
func (*RedBlackTreeExtended) RemoveMax ¶
func (tree *RedBlackTreeExtended) RemoveMax() (value interface{}, deleted bool)
RemoveMax removes the max value and flag if found
func (*RedBlackTreeExtended) RemoveMin ¶
func (tree *RedBlackTreeExtended) RemoveMin() (value interface{}, deleted bool)
RemoveMin removes the min value and flag if found