From bec41535419515138cc0eccefdae7d8ae3902419 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 10 Sep 2011 14:48:22 +0200 Subject: [PATCH] slight updates to the TODO --- TODO.markdown | 1 - client.go | 1 + dns.go | 6 ++++-- xfr.go | 35 +++++++++++++++++------------------ 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/TODO.markdown b/TODO.markdown index a12d7198..da993710 100644 --- a/TODO.markdown +++ b/TODO.markdown @@ -21,7 +21,6 @@ things that need to be fixed. a major memory saver; * Check base64/base32/hex validity when parsing RRs; * Include os.Error in ParseError too? (more info). -* zone.Nxt needs to be differently sorted than the default * Split up the package? An idea might be: dns/zone -- contains all zone parsing dns/server -- server side stuff diff --git a/client.go b/client.go index 748a3ca5..7a84030d 100644 --- a/client.go +++ b/client.go @@ -186,6 +186,7 @@ func ListenAndQuery(c chan *Request, handler QueryHandler) { // Write returns the original question and the answer on the reply channel of the // client. func (w *reply) Write(m *Msg) { + // Check if nil?? w.Client().ChannelReply <- &Exchange{Request: w.req, Reply: m} } diff --git a/dns.go b/dns.go index 54ac5de4..9803b3d8 100644 --- a/dns.go +++ b/dns.go @@ -46,6 +46,7 @@ package dns import ( "net" + "os" "strconv" ) @@ -146,8 +147,9 @@ func (s RRset) Ok() bool { // Exchange is used in communicating with the resolver. type Exchange struct { - Request *Msg // The question sent. - Reply *Msg // The answer to the question that was sent. + Request *Msg // The question sent. + Reply *Msg // The answer to the question that was sent. + Error os.Error // If something when wrong, this contains the error. } // DNS resource records. diff --git a/xfr.go b/xfr.go index 6b3a6d82..54505d1f 100644 --- a/xfr.go +++ b/xfr.go @@ -7,55 +7,54 @@ import ( // Perform an incoming Ixfr or Axfr. If the message q's question // section contains an AXFR type an Axfr is performed. If q's question // section contains an IXFR type an Ixfr is performed. -func (c *Client) XfrReceive(q *Msg, a string) ([]*Msg, os.Error) { +// Each message will be send along the Client's reply channel as it +// is received. +func (c *Client) XfrReceive(q *Msg, a string) os.Error { w := new(reply) w.client = c w.addr = a - w.req = q // is this needed TODO(mg) + w.req = q if err := w.Send(q); err != nil { - return nil, err + return err } // conn should be set now switch q.Question[0].Qtype { case TypeAXFR: - return w.axfrReceive() + go w.axfrReceive() case TypeIXFR: - // return w.ixfrReceive() + // go w.ixfrReceive() } - panic("not reached") - return nil, nil + return nil } -func (w *reply) axfrReceive() ([]*Msg, os.Error) { - axfr := make([]*Msg, 0) // use append ALL the time? +func (w *reply) axfrReceive() { first := true for { in, err := w.Receive() - axfr = append(axfr, in) if err != nil { - return axfr, err + w.Client().ChannelReply <- &Exchange{Request: w.req, Reply: in, Error: err} + return } if first { if !checkXfrSOA(in, true) { - return axfr, ErrXfrSoa + w.Client().ChannelReply <- &Exchange{Request: w.req, Reply: in, Error: ErrXfrSoa} + return } first = !first } if !first { w.tsigTimersOnly = true // Subsequent envelopes use this. - if !checkXfrSOA(in, false) { - // Soa record not the last one - continue - } else { - return axfr, nil + w.Client().ChannelReply <- &Exchange{Request: w.req, Reply: in} + if checkXfrSOA(in, false) { + return } } } panic("not reached") - return nil, nil + return } /*