Documentation updates
This commit is contained in:
parent
4dd48338af
commit
17c7921aa2
18
client.go
18
client.go
|
@ -19,8 +19,8 @@ const tcpIdleTimeout time.Duration = 8 * time.Second
|
|||
// A Conn represents a connection to a DNS server.
|
||||
type Conn struct {
|
||||
net.Conn // a net.Conn holding the connection
|
||||
UDPSize uint16 // Minimum receive buffer for UDP messages
|
||||
TsigSecret map[string]string // Secret(s) for Tsig map[<zonename>]<base64 secret>, zonename must be fully qualified
|
||||
UDPSize uint16 // minimum receive buffer for UDP messages
|
||||
TsigSecret map[string]string // secret(s) for Tsig map[<zonename>]<base64 secret>, zonename must be fully qualified
|
||||
rtt time.Duration
|
||||
t time.Time
|
||||
tsigRequestMAC string
|
||||
|
@ -29,7 +29,7 @@ type Conn struct {
|
|||
// A Client defines parameters for a DNS client.
|
||||
type Client struct {
|
||||
Net string // if "tcp" a TCP query will be initiated, otherwise an UDP one (default is "" for UDP)
|
||||
UDPSize uint16 // Minimum receive buffer for UDP messages
|
||||
UDPSize uint16 // minimum receive buffer for UDP messages
|
||||
DialTimeout time.Duration // net.DialTimeout (ns), defaults to 2 * 1e9
|
||||
ReadTimeout time.Duration // net.Conn.SetReadTimeout value for connections (ns), defaults to 2 * 1e9
|
||||
WriteTimeout time.Duration // net.Conn.SetWriteTimeout value for connections (ns), defaults to 2 * 1e9
|
||||
|
@ -41,6 +41,14 @@ type Client struct {
|
|||
// Exchange performs a synchronous UDP query. It sends the message m to the address
|
||||
// contained in a and waits for an reply. Exchange does not retry a failed query, nor
|
||||
// will it fall back to TCP in case of truncation.
|
||||
// If you need to send a DNS message on an already existing connection, you can use the
|
||||
// following:
|
||||
//
|
||||
// co := &dns.Conn{Conn: c} // c is your net.Conn
|
||||
// co.WriteMsg(m)
|
||||
// in, err := co.ReadMsg()
|
||||
// co.Close()
|
||||
//
|
||||
func Exchange(m *Msg, a string) (r *Msg, err error) {
|
||||
var co *Conn
|
||||
co, err = DialTimeout("udp", a, dnsTimeout)
|
||||
|
@ -137,11 +145,11 @@ func (c *Client) exchange(m *Msg, a string) (r *Msg, rtt time.Duration, err erro
|
|||
co.SetWriteDeadline(time.Now().Add(timeout))
|
||||
defer co.Close()
|
||||
opt := m.IsEdns0()
|
||||
// If EDNS0 is used use that for size
|
||||
// If EDNS0 is used use that for size.
|
||||
if opt != nil && opt.UDPSize() >= MinMsgSize {
|
||||
co.UDPSize = opt.UDPSize()
|
||||
}
|
||||
// Otherwise use the client's configured UDP size
|
||||
// Otherwise use the client's configured UDP size.
|
||||
if opt == nil && c.UDPSize >= MinMsgSize {
|
||||
co.UDPSize = c.UDPSize
|
||||
}
|
||||
|
|
16
defaults.go
16
defaults.go
|
@ -14,7 +14,7 @@ const hexDigit = "0123456789abcdef"
|
|||
|
||||
// Everything is assumed in ClassINET.
|
||||
|
||||
// SetReply creates a reply packet from a request message.
|
||||
// SetReply creates a reply message from a request message.
|
||||
func (dns *Msg) SetReply(request *Msg) *Msg {
|
||||
dns.Id = request.Id
|
||||
dns.RecursionDesired = request.RecursionDesired // Copy rd bit
|
||||
|
@ -28,7 +28,7 @@ func (dns *Msg) SetReply(request *Msg) *Msg {
|
|||
return dns
|
||||
}
|
||||
|
||||
// SetQuestion creates a question packet.
|
||||
// SetQuestion creates a question message.
|
||||
func (dns *Msg) SetQuestion(z string, t uint16) *Msg {
|
||||
dns.Id = Id()
|
||||
dns.RecursionDesired = true
|
||||
|
@ -37,7 +37,7 @@ func (dns *Msg) SetQuestion(z string, t uint16) *Msg {
|
|||
return dns
|
||||
}
|
||||
|
||||
// SetNotify creates a notify packet.
|
||||
// SetNotify creates a notify message.
|
||||
func (dns *Msg) SetNotify(z string) *Msg {
|
||||
dns.Opcode = OpcodeNotify
|
||||
dns.Authoritative = true
|
||||
|
@ -47,14 +47,14 @@ func (dns *Msg) SetNotify(z string) *Msg {
|
|||
return dns
|
||||
}
|
||||
|
||||
// SetRcode creates an error packet suitable for the request.
|
||||
// SetRcode creates an error message suitable for the request.
|
||||
func (dns *Msg) SetRcode(request *Msg, rcode int) *Msg {
|
||||
dns.SetReply(request)
|
||||
dns.Rcode = rcode
|
||||
return dns
|
||||
}
|
||||
|
||||
// SetRcodeFormatError creates a packet with FormError set.
|
||||
// SetRcodeFormatError creates a message with FormError set.
|
||||
func (dns *Msg) SetRcodeFormatError(request *Msg) *Msg {
|
||||
dns.Rcode = RcodeFormatError
|
||||
dns.Opcode = OpcodeQuery
|
||||
|
@ -64,7 +64,7 @@ func (dns *Msg) SetRcodeFormatError(request *Msg) *Msg {
|
|||
return dns
|
||||
}
|
||||
|
||||
// SetUpdate makes the message a dynamic update packet. It
|
||||
// SetUpdate makes the message a dynamic update message. It
|
||||
// sets the ZONE section to: z, TypeSOA, ClassINET.
|
||||
func (dns *Msg) SetUpdate(z string) *Msg {
|
||||
dns.Id = Id()
|
||||
|
@ -76,7 +76,7 @@ func (dns *Msg) SetUpdate(z string) *Msg {
|
|||
return dns
|
||||
}
|
||||
|
||||
// SetIxfr creates dns.Msg for requesting an IXFR.
|
||||
// SetIxfr creates message for requesting an IXFR.
|
||||
func (dns *Msg) SetIxfr(z string, serial uint32) *Msg {
|
||||
dns.Id = Id()
|
||||
dns.Question = make([]Question, 1)
|
||||
|
@ -89,7 +89,7 @@ func (dns *Msg) SetIxfr(z string, serial uint32) *Msg {
|
|||
return dns
|
||||
}
|
||||
|
||||
// SetAxfr creates dns.Msg for requesting an AXFR.
|
||||
// SetAxfr creates message for requesting an AXFR.
|
||||
func (dns *Msg) SetAxfr(z string) *Msg {
|
||||
dns.Id = Id()
|
||||
dns.Question = make([]Question, 1)
|
||||
|
|
2
zscan.go
2
zscan.go
|
@ -102,7 +102,7 @@ type lex struct {
|
|||
type Token struct {
|
||||
RR // the scanned resource record when error is not nil
|
||||
Error *ParseError // when an error occured, this has the error specifics
|
||||
Comment string // A potential comment positioned after the RR and on the same line
|
||||
Comment string // a potential comment positioned after the RR and on the same line
|
||||
}
|
||||
|
||||
// NewRR reads the RR contained in the string s. Only the first RR is returned.
|
||||
|
|
Loading…
Reference in New Issue