Clean ups
This commit is contained in:
parent
4b0bee3c94
commit
879e6dcda8
|
@ -22,6 +22,7 @@ func main() {
|
|||
d.RemoteAddr = c.Servers[0]
|
||||
d.Dial("udp")
|
||||
for _, a := range addresses(d, os.Args[0]) {
|
||||
// d.Close() -- interesting
|
||||
d.RemoteAddr = a
|
||||
d.Dial("udp") // Redial TODO(mg)
|
||||
m.Question[0] = dns.Question{"version.bind.", dns.TypeTXT, dns.ClassCHAOS}
|
||||
|
|
5
dns.go
5
dns.go
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
// Extended and bugfixes by Miek Gieben
|
||||
// Extended and bugfixes by Miek Gieben.
|
||||
|
||||
// Package dns implements a full featured interface to the DNS.
|
||||
// The package allows complete control over what is send out to the DNS.
|
||||
|
@ -16,7 +16,7 @@
|
|||
// The package dns supports (async) querying/replying, incoming/outgoing Axfr/Ixfr,
|
||||
// TSIG, EDNS0, dynamic updates, notifies and DNSSEC validation/signing.
|
||||
//
|
||||
// A lot of functions take a dns message. Use pattern for creating one:
|
||||
// In the DNS messages are exchanged. Use pattern for creating one:
|
||||
//
|
||||
// message := new(Msg)
|
||||
// // Create message with the desired options.
|
||||
|
@ -31,6 +31,7 @@
|
|||
// dnsconn.RemoteAddr = "127.0.0.1:53"
|
||||
// dnsconn.Dial("udp") // "tcp" for tcp connection.
|
||||
// inmessage, err := SimpleQuery(dnsconn, message)
|
||||
// dnsconn.Close()
|
||||
//
|
||||
// (Asynchronize) querying the DNS is also supported. The Query structure
|
||||
// is used for communicating with the Query* functions.
|
||||
|
|
|
@ -8,7 +8,6 @@ package dns
|
|||
|
||||
import (
|
||||
"os"
|
||||
"net"
|
||||
)
|
||||
|
||||
// Query is used to communicate with the Query* functions.
|
||||
|
@ -44,15 +43,10 @@ func query(n string, in, out chan Query, f func(*Conn, *Msg, chan Query)) {
|
|||
for {
|
||||
select {
|
||||
case q := <-in:
|
||||
c, err := net.Dial(n, q.Conn.LocalAddr, q.Conn.RemoteAddr)
|
||||
err := q.Conn.Dial(n)
|
||||
if err != nil {
|
||||
out <- Query{Err: err}
|
||||
}
|
||||
if n == "tcp" {
|
||||
q.Conn.SetTCPConn(c.(*net.TCPConn), nil)
|
||||
} else {
|
||||
q.Conn.SetUDPConn(c.(*net.UDPConn), nil)
|
||||
}
|
||||
if f == nil {
|
||||
go QueryDefault(q.Conn, q.Msg, out)
|
||||
} else {
|
||||
|
@ -65,6 +59,7 @@ func query(n string, in, out chan Query, f func(*Conn, *Msg, chan Query)) {
|
|||
|
||||
// Default Handler when none is given.
|
||||
func QueryDefault(d *Conn, m *Msg, q chan Query) {
|
||||
defer d.Close()
|
||||
buf, ok := m.Pack()
|
||||
if !ok {
|
||||
q <- Query{nil, d, ErrPack}
|
||||
|
|
Loading…
Reference in New Issue