Start thinking about server side axfr

This commit is contained in:
Miek Gieben 2011-09-11 17:24:52 +02:00
parent d814a20623
commit 6ef13c3cbd
2 changed files with 19 additions and 17 deletions

1
msg.go
View File

@ -48,6 +48,7 @@ var (
ErrAuth os.Error = &Error{Error: "bad authentication"} ErrAuth os.Error = &Error{Error: "bad authentication"}
ErrXfrSoa os.Error = &Error{Error: "no SOA seen"} ErrXfrSoa os.Error = &Error{Error: "no SOA seen"}
ErrXfrLast os.Error = &Error{Error: "last SOA"} ErrXfrLast os.Error = &Error{Error: "last SOA"}
ErrXfrType os.Error = &Error{Error: "no ixfr, nor axfr"}
ErrHandle os.Error = &Error{Error: "handle is nil"} ErrHandle os.Error = &Error{Error: "handle is nil"}
ErrChan os.Error = &Error{Error: "channel is nil"} ErrChan os.Error = &Error{Error: "channel is nil"}
ErrName os.Error = &Error{Error: "type not found for name"} ErrName os.Error = &Error{Error: "type not found for name"}

35
xfr.go
View File

@ -4,12 +4,10 @@ import (
"os" "os"
) )
// Perform an incoming Ixfr or Axfr. If the message q's question // XfrReceives requests 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 AXFR type an Axfr is performed, if it is IXFR it does
// section contains an IXFR type an Ixfr is performed. // an Ixfr.
// Each message will be send along the Client's reply channel as it // Each message will be send along the Client's reply channel as it is received.
// is received.
//
// The last message send has Exchange.Error set to ErrXfrLast // The last message send has Exchange.Error set to ErrXfrLast
// to signal there is nothing more to come. // to signal there is nothing more to come.
func (c *Client) XfrReceive(q *Msg, a string) os.Error { 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() go w.axfrReceive()
case TypeIXFR: case TypeIXFR:
go w.ixfrReceive() go w.ixfrReceive()
default:
return ErrXfrType
} }
return nil return nil
} }
@ -115,24 +115,25 @@ func (w *reply) ixfrReceive() {
panic("not reached") panic("not reached")
return return
} }
/* // TODO(mg): helper function for settings/making/parsing the
// Perform an outgoing Ixfr or Axfr. If the message q's question // packets gotten from/to the ixfr/axfr functions
// section contains an AXFR type an Axfr is performed. If q's question
// section contains an IXFR type an Ixfr is performed. // XfrSend performs an outgoing Ixfr or Axfr. If the message q's question
// The actual records to send are given on the channel m. And errors // section contains an AXFR type an Axfr is performed. If it is IXFR
// during transport are return on channel e. // it does an Ixfr.
func (d *Conn) XfrWrite(q *Msg, m chan *Xfr, e chan os.Error) { func XfrSend(w ResponseWriter, q *Msg, a string) os.Error {
switch q.Question[0].Qtype { switch q.Question[0].Qtype {
case TypeAXFR: case TypeAXFR:
d.axfrWrite(q, m, e) // go d.axfrWrite(q, m, e)
case TypeIXFR: case TypeIXFR:
// d.ixfrWrite(q, m) // go d.ixfrWrite(q, m)
default: default:
e <- &Error{Error: "Xfr Qtype not recognized"} return ErrXfrType
close(m)
} }
return nil
} }
/*
// Just send the zone // Just send the zone
func (d *Conn) axfrWrite(q *Msg, m chan *Xfr, e chan os.Error) { func (d *Conn) axfrWrite(q *Msg, m chan *Xfr, e chan os.Error) {
out := new(Msg) out := new(Msg)