dns

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2018 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Example (Client)
package main

import (
	"fmt"

	"github.com/miekg/dns"
	dnstrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/miekg/dns"
)

func main() {
	m := new(dns.Msg)
	m.SetQuestion("miek.nl.", dns.TypeMX)
	// calling dnstrace.Exchange will call dns.Exchange but trace the request
	reply, err := dnstrace.Exchange(m, "127.0.0.1:53")
	fmt.Println(reply, err)
}
Output:

Example (Server)
package main

import (
	"github.com/miekg/dns"
	dnstrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/miekg/dns"
)

func main() {
	mux := dns.NewServeMux()
	mux.HandleFunc(".", func(w dns.ResponseWriter, r *dns.Msg) {
		m := new(dns.Msg)
		m.SetReply(r)
		w.WriteMsg(m)
	})
	// calling dnstrace.ListenAndServe will call dns.ListenAndServe but all
	// requests will be traced
	dnstrace.ListenAndServe(":dns", "udp", mux)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exchange

func Exchange(m *dns.Msg, addr string) (r *dns.Msg, err error)

Exchange calls dns.Exchange and traces the request.

func ExchangeConn

func ExchangeConn(c net.Conn, m *dns.Msg) (r *dns.Msg, err error)

ExchangeConn calls dns.ExchangeConn and traces the request.

func ExchangeContext

func ExchangeContext(ctx context.Context, m *dns.Msg, addr string) (r *dns.Msg, err error)

ExchangeContext calls dns.ExchangeContext and traces the request.

func ListenAndServe

func ListenAndServe(addr string, network string, handler dns.Handler) error

ListenAndServe calls dns.ListenAndServe with a wrapped Handler.

func ListenAndServeTLS

func ListenAndServeTLS(addr, certFile, keyFile string, handler dns.Handler) error

ListenAndServeTLS calls dns.ListenAndServeTLS with a wrapped Handler.

Types

type Client

type Client struct {
	*dns.Client
}

A Client wraps a DNS Client so that requests are traced.

func (*Client) Exchange

func (c *Client) Exchange(m *dns.Msg, addr string) (r *dns.Msg, rtt time.Duration, err error)

Exchange calls the underlying Client.Exchange and traces the request.

func (*Client) ExchangeContext

func (c *Client) ExchangeContext(ctx context.Context, m *dns.Msg, addr string) (r *dns.Msg, rtt time.Duration, err error)

ExchangeContext calls the underlying Client.ExchangeContext and traces the request.

type Handler

type Handler struct {
	dns.Handler
}

A Handler wraps a DNS Handler so that requests are traced.

func WrapHandler

func WrapHandler(handler dns.Handler) *Handler

WrapHandler creates a new, wrapped DNS handler.

func (*Handler) ServeDNS

func (h *Handler) ServeDNS(w dns.ResponseWriter, r *dns.Msg)

ServeDNS dispatches requests to the underlying Handler. All requests will be traced.

Jump to

Keyboard shortcuts

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