From b722229700fb04ca77adff284ea3a4b179e9fbb8 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Fri, 18 Mar 2011 14:13:42 +0100 Subject: [PATCH] start of server side (sending) AXFR --- TODO | 11 +++++++++++ server.go | 1 + xfr.go | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/TODO b/TODO index 6ff81661..2d8f6505 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,20 @@ +Guidelines for the API: + +o symmetrical, client side stuff should be mirrored in the server stuff +o clean, small API +o fast data structures (rb-tree, when they come available) +o api-use should lead to self documenting code +o compression (only ownernames?) + + + Todo: * Parsing from strings, going with goyacc and .cz lexer? * encoding NSEC3/NSEC bitmaps, DEcoding works * HIP RR (needs list of domain names, need slice stuff for that) * Resolver can see if you want ixfr or axfr from the msg no need for seperate functions +* Is subdomain, is glue helper functions Issues: * Check the network order, it works now, but this is on Intel?? diff --git a/server.go b/server.go index 62241139..57ab678e 100644 --- a/server.go +++ b/server.go @@ -11,6 +11,7 @@ import ( "net" ) +// Do I want this type Server struct { ServeUDP func(*net.UDPConn, net.Addr, *Msg) os.Error ServeTCP func(*net.TCPConn, net.Addr, *Msg) os.Error diff --git a/xfr.go b/xfr.go index 530accbd..ca2071de 100644 --- a/xfr.go +++ b/xfr.go @@ -1,3 +1,37 @@ package dns +import ( + "net" + ) + // Outgoing AXFR and IXFR implementations + +// Read from m until it is closed. Group the RRs until +// no space is left and send the messages. +// How do I know the message still fits in 64 K??? +func AxfrTCP(c *net.TCPConn, a net.Addr, m chan Xfr) { + msg := new(Msg) + msg.Answer = make([]RR, 1000) + i := 0 + var soa *RR_SOA + for r := range m { + msg.Answer[i] = r.RR + if soa == nil { + if r.RR.Header().Rrtype != TypeSOA { + // helegaar geen SOA + } else { + soa = r.RR.(*RR_SOA) + } + } + i++ + if i > 1000 { + // send it + msg.Answer = msg.Answer[:0] + i = 0 + } + } + // Last one, what if was 1000 send lonely soa?? No matter + // what, add the SOA and send the msg + msg.Answer[i] = soa + // send it +}