dns/restest.go

39 lines
674 B
Go
Raw Normal View History

2010-08-04 07:57:59 +10:00
package main
import (
"dns"
"time"
"fmt"
2010-08-04 07:57:59 +10:00
)
const (
NLOOP = 5
)
2010-08-04 07:57:59 +10:00
func main() {
res := new(dns.Resolver)
ch := dns.NewQuerier(res)
// configure the resolver
res.Servers = []string{"192.168.1.2"}
res.Timeout = 2
res.Attempts = 1
2010-08-04 07:57:59 +10:00
2010-12-19 07:01:50 +11:00
// Setup done, now for some real work
// Create a new message
m := new(dns.Msg)
m.MsgHdr.Recursion_desired = true //only set this bit
m.Question = make([]dns.Question, 1)
2010-12-19 07:01:50 +11:00
m.Question[0] = dns.Question{"forfunsec.org", dns.TypeRRSIG, dns.ClassINET}
ch <- dns.DnsMsg{m, nil}
// wait for an reply
in := <-ch
fmt.Printf("%v\n", in.Dns)
2010-12-19 09:46:37 +11:00
ch <- dns.DnsMsg{nil, nil}
2010-12-19 07:01:50 +11:00
time.Sleep(2.0e9) // wait for Go routine to do something
2010-08-04 07:57:59 +10:00
}