Fix xfr some more
This commit is contained in:
parent
f9fa2d2c0c
commit
05e5e586b5
46
xfr.go
46
xfr.go
|
@ -23,22 +23,8 @@ type Transfer struct {
|
||||||
tsigTimersOnly bool
|
tsigTimersOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// In performs a [AI]XFR request (depends on the message's Qtype). It returns
|
// In performs an incoming transfer with the server in a.
|
||||||
// a channel of *Envelope on which the replies from the server are sent.
|
func (t *Transfer) In(q *Msg, a string) (env chan *Envelope, err error) {
|
||||||
// At the end of the transfer the channel is closed.
|
|
||||||
// The messages are TSIG checked if needed, no other post-processing is performed.
|
|
||||||
// The caller must dissect the returned messages.
|
|
||||||
//
|
|
||||||
// Basic use pattern for receiving an AXFR:
|
|
||||||
//
|
|
||||||
// // m contains the AXFR request
|
|
||||||
// t := new(dns.Transfer)
|
|
||||||
// c, e := t.In(m, "127.0.0.1:53")
|
|
||||||
// for env := range c
|
|
||||||
// // ... deal with env.RR or env.Error
|
|
||||||
// }
|
|
||||||
|
|
||||||
func (t *Transfer) In(q *Msg, a string, env chan *Envelope) (err error) {
|
|
||||||
co := new(Conn)
|
co := new(Conn)
|
||||||
timeout := dnsTimeout
|
timeout := dnsTimeout
|
||||||
if t.DialTimeout != 0 {
|
if t.DialTimeout != 0 {
|
||||||
|
@ -46,17 +32,20 @@ func (t *Transfer) In(q *Msg, a string, env chan *Envelope) (err error) {
|
||||||
}
|
}
|
||||||
co.Conn, err = net.DialTimeout("tcp", a, timeout)
|
co.Conn, err = net.DialTimeout("tcp", a, timeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
if q.Question[0].Qtype == TypeAXFR {
|
env = make(chan *Envelope)
|
||||||
go t.inAxfr(q.Id, env)
|
go func() {
|
||||||
return nil
|
if q.Question[0].Qtype == TypeAXFR {
|
||||||
}
|
go t.inAxfr(q.Id, env)
|
||||||
if q.Question[0].Qtype == TypeIXFR {
|
return
|
||||||
go t.inIxfr(q.Id, env)
|
}
|
||||||
return nil
|
if q.Question[0].Qtype == TypeIXFR {
|
||||||
}
|
go t.inIxfr(q.Id, env)
|
||||||
return nil // TODO(miek): some error
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
return env, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Transfer) inAxfr(id uint16, c chan *Envelope) {
|
func (t *Transfer) inAxfr(id uint16, c chan *Envelope) {
|
||||||
|
@ -114,7 +103,6 @@ func (t *Transfer) inIxfr(id uint16, c chan *Envelope) {
|
||||||
timeout = t.ReadTimeout
|
timeout = t.ReadTimeout
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
// re-read 'n stuff must be pushed down
|
|
||||||
t.SetReadDeadline(time.Now().Add(timeout))
|
t.SetReadDeadline(time.Now().Add(timeout))
|
||||||
in, err := t.ReadMsg()
|
in, err := t.ReadMsg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -171,8 +159,8 @@ func (t *Transfer) Out(w ResponseWriter, q *Msg, a string) (chan *Envelope, erro
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// w.TsigTimersOnly(true)
|
w.TsigTimersOnly(true)
|
||||||
// rep.Answer = nil
|
r.Answer = nil
|
||||||
}()
|
}()
|
||||||
return ch, nil
|
return ch, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue