Fix the examples, except funkensturm

This commit is contained in:
Miek Gieben 2011-03-30 15:23:09 +02:00
parent bc8186ef04
commit af7f3f769f
6 changed files with 19 additions and 26 deletions

View File

@ -12,7 +12,7 @@ func main() {
flag.Parse()
zone := flag.Arg(flag.NArg() - 1)
c := make(chan dns.Xfr)
c := make(chan *dns.Xfr)
d := new(dns.Conn)
m := new(dns.Msg)

View File

@ -28,12 +28,12 @@ func main() {
}
m.Question[0] = dns.Question{"version.bind.", dns.TypeTXT, dns.ClassCHAOS}
in, _ := dns.QuerySimple(d, m)
in, _ := dns.QuerySimple("udp", d, m)
if in != nil && in.Answer != nil {
fmt.Printf("%v\n", in.Answer[0])
}
m.Question[0] = dns.Question{"hostname.bind.", dns.TypeTXT, dns.ClassCHAOS}
in, _ = dns.QuerySimple(d, m)
in, _ = dns.QuerySimple("udp", d, m)
if in != nil && in.Answer != nil {
fmt.Printf("%v\n", in.Answer[0])
}
@ -46,11 +46,8 @@ func addresses(d *dns.Conn, name string) []string {
m.Question = make([]dns.Question, 1)
var ips []string
d.Dial("udp")
defer d.Close()
m.Question[0] = dns.Question{os.Args[1], dns.TypeA, dns.ClassINET}
in, err := dns.QuerySimple(d, m)
in, err := dns.QuerySimple("udp", d, m)
if in == nil {
fmt.Printf("Nothing recevied: %s\n", err.String())
return nil
@ -64,7 +61,7 @@ func addresses(d *dns.Conn, name string) []string {
ips = append(ips, a.(*dns.RR_A).A.String()+":53")
}
m.Question[0] = dns.Question{os.Args[1], dns.TypeAAAA, dns.ClassINET}
in, err = dns.QuerySimple(d, m)
in, err = dns.QuerySimple("udp", d, m)
if in == nil {
fmt.Printf("Nothing recevied: %s\n", err.String())
return ips

View File

@ -21,8 +21,7 @@ func main() {
d := new(dns.Conn)
d.RemoteAddr = c.Servers[0]
d.Dial("udp")
in, err := dns.QuerySimple(d, m)
in, err := dns.QuerySimple("udp", d, m)
if in != nil {
if in.Rcode != dns.RcodeSuccess {
fmt.Printf(" *** invalid answer name %s after DNSKEY query for %s\n", os.Args[1], os.Args[1])
@ -33,8 +32,10 @@ func main() {
// Foreach key would need to provide a DS records, both sha1 and sha256
if key, ok := k.(*dns.RR_DNSKEY); ok {
ds := key.ToDS(dns.HashSHA1)
ds.Hdr.Ttl = 0
fmt.Printf("%v\n", ds)
ds = key.ToDS(dns.HashSHA256)
ds.Hdr.Ttl = 0
fmt.Printf("%v\n", ds)
}
}

View File

@ -30,7 +30,7 @@ func main() {
os.Exit(1)
}
in, err := dns.QuerySimple(d, m)
in, err := dns.QuerySimple("udp", d, m)
if in != nil {
if in.Rcode != dns.RcodeSuccess {
fmt.Printf(" *** invalid answer name %s after MX query for %s\n", os.Args[1], os.Args[1])

View File

@ -84,7 +84,7 @@ Flags:
go func() {
for _, v := range qname {
d, m := newConnMsg(v, nameserver, c.Attempts, qtype, qclass, *aa, *ad, *cd, *rd, *dnssec, *nsid)
dns.QueryRequest <- dns.Query{Query: m, Conn: d}
dns.QueryRequest <- &dns.Query{Query: m, Conn: d}
}
}()
@ -130,7 +130,7 @@ func query(tcp string, e chan os.Error) {
// reply checking 'n stuff
func qhandle(d *dns.Conn, i *dns.Msg) {
o, err := d.ExchangeMsg(i, false)
dns.QueryReply <- dns.Query{Query: i, Reply: o, Conn: d, Err: err}
dns.QueryReply <- &dns.Query{Query: i, Reply: o, Conn: d, Err: err}
d.Close()
return
}

View File

@ -3,7 +3,6 @@ package main
import (
"os"
"dns"
"net"
"fmt"
)
@ -12,14 +11,10 @@ func handleXfr(d *dns.Conn, i *dns.Msg) {
fmt.Printf("Axfr request seen\n")
if i.Question[0].Name == Zone.name {
fmt.Printf("Matching current zone\n")
m := make(chan dns.Xfr)
var x dns.Xfr
m := make(chan *dns.Xfr)
go d.XfrWrite(i, m)
for j := 0; j < Zone.size; j++ {
x.Add = true
x.RR = Zone.rrs[j]
m <- x
m <- &dns.Xfr{Add: true, RR: Zone.rrs[j]}
}
close(m)
}
@ -43,19 +38,20 @@ func doXfrIn(i *dns.Msg) ([]dns.RR, os.Error) {
q := new(dns.Msg)
q.SetAxfr(i.Question[0].Name)
m := make(chan dns.Xfr)
m := make(chan *dns.Xfr)
fmt.Printf("Preparing Xfr for %s\n", i.Question[0].Name)
// Fill and setup the dns.Conn.
d := new(dns.Conn)
c, err := net.Dial("tcp", "", "127.0.0.1:53")
d.RemoteAddr = "127.0.0.1:53"
err := d.Dial("tcp")
if err != nil {
return nil, err
}
defer d.Close()
fmt.Printf("Calling 127.0.0.1 successful\n")
d.TCP = c.(*net.TCPConn)
d.Addr = d.TCP.RemoteAddr()
go d.XfrRead(q, m)
Zone.name = i.Question[0].Name
j := 0
for x := range m {
@ -64,6 +60,5 @@ func doXfrIn(i *dns.Msg) ([]dns.RR, os.Error) {
j++
}
Zone.size = j
d.Close()
return nil, nil
}