Documentation
¶
Index ¶
- Variables
- func AddHost(host string, ip string)
- func GetDefaultHostsFilePath() string
- func GetHost(host string) (ip string, ok bool)
- func IsExistedHost(host string) bool
- func LoadHostsFromFile(p string) error
- func LookupAll(host string, opt ...DNSOption) []string
- func LookupCallback(host string, h func(dnsType, domain, ip, fromServer string, method string), ...) error
- func LookupFirst(host string, opt ...DNSOption) string
- func NewDialContextFunc(timeout time.Duration, opts ...DNSOption) func(ctx context.Context, network string, addr string) (net.Conn, error)
- func NewDialGMTLSContextFunc(preferGMTLS bool, onlyGMTLS bool, timeout time.Duration, opts ...DNSOption) func(ctx context.Context, network string, addr string) (net.Conn, error)
- func SetDefaultOptions(opt ...DNSOption)
- type DNSOption
- func GetDefaultOptions() []DNSOption
- func WithDNSCallback(cb func(dnsType, domain, ip, fromServer, method string)) DNSOption
- func WithDNSContext(ctx context.Context) DNSOption
- func WithDNSDisableSystemResolver(b bool) DNSOption
- func WithDNSFallbackDoH(b bool) DNSOption
- func WithDNSFallbackSpecificDNS(b bool) DNSOption
- func WithDNSFallbackTCP(b bool) DNSOption
- func WithDNSNoCache(b bool) DNSOption
- func WithDNSPreferDoH(b bool) DNSOption
- func WithDNSPreferTCP(b bool) DNSOption
- func WithDNSRetryTimes(i int) DNSOption
- func WithDNSServers(s ...string) DNSOption
- func WithDNSSpecificDoH(s ...string) DNSOption
- func WithTemporaryHosts(i map[string]string) DNSOption
- func WithTimeout(timeout time.Duration) DNSOption
- type DoHDNSResponse
- type ReliableDNSConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultCustomDNSServers = []string{
"223.5.5.5", "223.6.6.6",
"120.53.53.53", "1.1.1.1",
"8.8.8.8",
}
View Source
var DefaultCustomDoHServers = []string{
"https://223.5.5.5/resolve",
"https://223.6.6.6/resolve",
"https://1.12.12.12/dns-query",
"https://120.53.53.53/dns-query",
"https://1.1.1.1/dns-query",
"https://8.8.8.8/resolve",
"https://8.8.4.4/resolve",
}
Functions ¶
func GetDefaultHostsFilePath ¶
func GetDefaultHostsFilePath() string
func IsExistedHost ¶
func LookupCallback ¶
func LookupFirst ¶
func NewDialContextFunc ¶
func NewDialGMTLSContextFunc ¶
func SetDefaultOptions ¶
func SetDefaultOptions(opt ...DNSOption)
Types ¶
type DNSOption ¶
type DNSOption func(*ReliableDNSConfig)
func GetDefaultOptions ¶
func GetDefaultOptions() []DNSOption
func WithDNSCallback ¶
func WithDNSContext ¶
func WithDNSFallbackDoH ¶
func WithDNSFallbackTCP ¶
func WithDNSNoCache ¶
func WithDNSPreferDoH ¶
func WithDNSPreferTCP ¶
func WithDNSRetryTimes ¶
func WithDNSServers ¶
func WithDNSSpecificDoH ¶
func WithTemporaryHosts ¶
func WithTimeout ¶
type DoHDNSResponse ¶
type DoHDNSResponse struct { Status int `json:"Status"` TC bool `json:"TC"` RD bool `json:"RD"` RA bool `json:"RA"` AD bool `json:"AD"` CD bool `json:"CD"` Question json.RawMessage Answer []struct { Name string `json:"name"` Type int `json:"type"` TTL int `json:"TTL"` Data string `json:"data"` } `json:"Answer"` }
type ReliableDNSConfig ¶
type ReliableDNSConfig struct { Timeout time.Duration Hosts map[string]string PreferTCP bool FallbackTCP bool RetryTimes int // default 3 // DoH config PreferDoH bool FallbackDoH bool // as backup SpecificDoH []string // NoCache NoCache bool // Disable System Resolver DisableSystemResolver bool // SpecificDNSServers 作为备选项 FallbackSpecificDNS bool SpecificDNSServers []string // ctx BaseContext context.Context Callback func(dnsType string, domain string, ip, fromServer, method string) // contains filtered or unexported fields }
func NewBackupInitilizedReliableDNSConfig ¶
func NewBackupInitilizedReliableDNSConfig() *ReliableDNSConfig
func NewDefaultReliableDNSConfig ¶
func NewDefaultReliableDNSConfig() *ReliableDNSConfig
func (*ReliableDNSConfig) GetBaseContext ¶
func (r *ReliableDNSConfig) GetBaseContext() context.Context
Click to show internal directories.
Click to hide internal directories.