From 6ef13c3cbd5d84761863e1cbbc164b1a4058419d Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sun, 11 Sep 2011 17:24:52 +0200 Subject: [PATCH] Start thinking about server side axfr --- msg.go | 1 + xfr.go | 35 ++++++++++++++++++----------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/msg.go b/msg.go index d7881057..f837a1fd 100644 --- a/msg.go +++ b/msg.go @@ -48,6 +48,7 @@ var ( ErrAuth os.Error = &Error{Error: "bad authentication"} ErrXfrSoa os.Error = &Error{Error: "no SOA seen"} ErrXfrLast os.Error = &Error{Error: "last SOA"} + ErrXfrType os.Error = &Error{Error: "no ixfr, nor axfr"} ErrHandle os.Error = &Error{Error: "handle is nil"} ErrChan os.Error = &Error{Error: "channel is nil"} ErrName os.Error = &Error{Error: "type not found for name"} diff --git a/xfr.go b/xfr.go index 6ecf5e7d..b3fcc5cc 100644 --- a/xfr.go +++ b/xfr.go @@ -4,12 +4,10 @@ import ( "os" ) -// 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. -// Each message will be send along the Client's reply channel as it -// is received. -// +// XfrReceives requests an incoming Ixfr or Axfr. If the message q's question +// section contains an AXFR type an Axfr is performed, if it is IXFR it does +// an Ixfr. +// Each message will be send along the Client's reply channel as it is received. // The last message send has Exchange.Error set to ErrXfrLast // to signal there is nothing more to come. func (c *Client) XfrReceive(q *Msg, a string) os.Error { @@ -28,6 +26,8 @@ func (c *Client) XfrReceive(q *Msg, a string) os.Error { go w.axfrReceive() case TypeIXFR: go w.ixfrReceive() + default: + return ErrXfrType } return nil } @@ -115,24 +115,25 @@ func (w *reply) ixfrReceive() { panic("not reached") return } -/* -// Perform an outgoing 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. -// The actual records to send are given on the channel m. And errors -// during transport are return on channel e. -func (d *Conn) XfrWrite(q *Msg, m chan *Xfr, e chan os.Error) { +// TODO(mg): helper function for settings/making/parsing the +// packets gotten from/to the ixfr/axfr functions + +// XfrSend performs an outgoing Ixfr or Axfr. If the message q's question +// section contains an AXFR type an Axfr is performed. If it is IXFR +// it does an Ixfr. +func XfrSend(w ResponseWriter, q *Msg, a string) os.Error { switch q.Question[0].Qtype { case TypeAXFR: - d.axfrWrite(q, m, e) + // go d.axfrWrite(q, m, e) case TypeIXFR: - // d.ixfrWrite(q, m) + // go d.ixfrWrite(q, m) default: - e <- &Error{Error: "Xfr Qtype not recognized"} - close(m) + return ErrXfrType } + return nil } +/* // Just send the zone func (d *Conn) axfrWrite(q *Msg, m chan *Xfr, e chan os.Error) { out := new(Msg)