Fix outgoing axfr and make reflect use it.
This commit is contained in:
parent
f3d8fc6c34
commit
6dc58c11bd
|
@ -111,6 +111,21 @@ func handleReflect(w dns.ResponseWriter, r *dns.Msg) {
|
||||||
case dns.TypeAAAA, dns.TypeA:
|
case dns.TypeAAAA, dns.TypeA:
|
||||||
m.Answer = append(m.Answer, rr)
|
m.Answer = append(m.Answer, rr)
|
||||||
m.Extra = append(m.Extra, t)
|
m.Extra = append(m.Extra, t)
|
||||||
|
|
||||||
|
case dns.TypeAXFR, dns.TypeIXFR:
|
||||||
|
c := make(chan *dns.Envelope)
|
||||||
|
tr := new(dns.Transfer)
|
||||||
|
defer close(c)
|
||||||
|
err := tr.Out(w, r, c)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
soa, _ := dns.NewRR(`whoami.miek.nl. 0 IN SOA linode.atoom.net. miek.miek.nl. 2009032802 21600 7200 604800 3600`)
|
||||||
|
c <- &dns.Envelope{RR: []dns.RR{soa, t, rr, soa}}
|
||||||
|
w.Hijack()
|
||||||
|
// w.Close() // Client closes connection
|
||||||
|
return
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.IsTsig() != nil {
|
if r.IsTsig() != nil {
|
||||||
|
@ -143,7 +158,7 @@ func serve(net, name, secret string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
runtime.GOMAXPROCS(runtime.NumCPU()*4)
|
runtime.GOMAXPROCS(runtime.NumCPU() * 4)
|
||||||
cpuprofile := flag.String("cpuprofile", "", "write cpu profile to file")
|
cpuprofile := flag.String("cpuprofile", "", "write cpu profile to file")
|
||||||
printf = flag.Bool("print", false, "print replies")
|
printf = flag.Bool("print", false, "print replies")
|
||||||
compress = flag.Bool("compress", false, "compress replies")
|
compress = flag.Bool("compress", false, "compress replies")
|
||||||
|
|
7
xfr.go
7
xfr.go
|
@ -149,11 +149,12 @@ func (t *Transfer) inIxfr(id uint16, c chan *Envelope) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transfer) Out(w ResponseWriter, q *Msg, a string) (chan *Envelope, error) {
|
func (t *Transfer) Out(w ResponseWriter, q *Msg, ch chan *Envelope) error {
|
||||||
ch := make(chan *Envelope)
|
|
||||||
r := new(Msg)
|
r := new(Msg)
|
||||||
|
// Compress?
|
||||||
r.SetReply(q)
|
r.SetReply(q)
|
||||||
r.Authoritative = true
|
r.Authoritative = true
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
for x := range ch {
|
for x := range ch {
|
||||||
// assume it fits TODO(miek): fix
|
// assume it fits TODO(miek): fix
|
||||||
|
@ -165,7 +166,7 @@ func (t *Transfer) Out(w ResponseWriter, q *Msg, a string) (chan *Envelope, erro
|
||||||
w.TsigTimersOnly(true)
|
w.TsigTimersOnly(true)
|
||||||
r.Answer = nil
|
r.Answer = nil
|
||||||
}()
|
}()
|
||||||
return ch, nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadMsg reads a message from the transfer connection t.
|
// ReadMsg reads a message from the transfer connection t.
|
||||||
|
|
Loading…
Reference in New Issue