Documentation
¶
Overview ¶
Package dnsclient provides a minimal DNS client library. It provides native support for - Dns Over UDP - DNS Over TCP - DNS Over HTTPS (DoH) - DNS Over TLS (DoT) - DNS Over QUIC (DoQ)
Index ¶
- func GetDialer(socksURL string) (proxy.Dialer, error)
- type ClassicDNS
- type Client
- func New(uri string, skipVerify bool, proxy string) (Client, error)
- func NewClassicDNS(server net.Addr, UseTCP bool, UseTLS bool, SkipVerify bool, proxy string) (Client, error)
- func NewDoHClient(server url.URL, SkipVerify bool, proxy string) (Client, error)
- func NewDoQClient(server string, SkipVerify bool) (Client, error)
- type DoHClient
- type DoQClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClassicDNS ¶
type ClassicDNS struct {
// contains filtered or unexported fields
}
ClassicDNS provides functionality to create DNS over UDP, DNS over TCP and DNS over TLS
func (*ClassicDNS) Query ¶
func (c *ClassicDNS) Query(ctx context.Context, q *dns.Msg) (responses []dns.RR, rtt time.Duration, err error)
Query takes a dns message and returns a list of resources
func (*ClassicDNS) Reconnect ¶ added in v0.2.0
func (c *ClassicDNS) Reconnect() error
Reconnect reads the configuration from the running instance, and tries to replace the client with a fresh connection on-the-fly
type Client ¶
type Client interface { Query(context.Context, *dns.Msg) ([]dns.RR, time.Duration, error) Close() error Reconnect() error }
Client Provides a unified interface for DNS queries
func main() { msg := dns.Msg{} msg.RecursionDesired = true msg.Question = []dns.Question{{ Name: "example.com.", Qtype: dns.StringToType["A"], Qclass: dns.ClassINET, }} addr := &net.UDPAddr{ IP: net.IPv4(1, 1, 1, 1), Port: 53, } c, _ := dnsclient.NewClassicDNS(addr, false, false, false) response, ttr, err := c.Query(context.Background(), &msg) fmt.Printf("Query: %v, Response: %v, Time to Respond: %s, Error: %v", msg, response, ttr, err) }
func New ¶
New creates a DNS Client by parsing a URI and returning the appropriate client for it URI string could look like below:
- udp://1.1.1.1:53
- udp6://[2606:4700:4700::1111]:53
- tcp://9.9.9.9:5353
- https://dns.adguard.com
- quic://dns.adguard.com:8853
- tls://dns.adguard.com:853
func NewClassicDNS ¶
func NewClassicDNS(server net.Addr, UseTCP bool, UseTLS bool, SkipVerify bool, proxy string) (Client, error)
NewClassicDNS provides a client interface which you can query on
func NewDoHClient ¶
NewDoHClient creates a new DoH client
type DoHClient ¶
DoHClient encapsulates all functions and attributes for a DoH client
type DoQClient ¶
type DoQClient struct {
// contains filtered or unexported fields
}
DoQClient encapsulates all functions and attributes for a DoH client