From a0b011799e5c2bcbc9d537af87e85c1f9597f78c Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 23 Jul 2011 23:32:42 +0200 Subject: [PATCH] documentation --- client.go | 2 +- defaults.go | 3 ++- kparse.rl | 5 +++-- server.go | 6 ++++-- tsig.go | 4 ++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/client.go b/client.go index 198d2c56..2433424b 100644 --- a/client.go +++ b/client.go @@ -125,7 +125,7 @@ type Client struct { // LocalAddr string // Local address to use } -// Create a new client, with some default values filled in. +// Create a new client, with some defaults. func NewClient() *Client { c := new(Client) c.Net = "udp" diff --git a/defaults.go b/defaults.go index f30ec491..bef2a2aa 100644 --- a/defaults.go +++ b/defaults.go @@ -94,7 +94,7 @@ func (dns *Msg) IsIxfr() (ok bool) { return } -// Has a message a TSIG record as the last record? +// Has the message a TSIG record as the last record? func (dns *Msg) IsTsig() (ok bool) { if len(dns.Extra) > 0 { return dns.Extra[0].Header().Rrtype == TypeTSIG @@ -102,6 +102,7 @@ func (dns *Msg) IsTsig() (ok bool) { return } +// SetTsig Calculates and appends a TSIG RR on the message. func (dns *Msg) SetTsig(z, algo string, fudge uint16, timesigned uint64) { t := new(RR_TSIG) t.Hdr = RR_Header{z, TypeTSIG, ClassANY, 0, 0} diff --git a/kparse.rl b/kparse.rl index 29e631b9..796b9604 100644 --- a/kparse.rl +++ b/kparse.rl @@ -13,8 +13,9 @@ import ( }%% // PrivateKey parses a private key file as defined in XXX. -// A map[string]string is returned with the values. All the keys -// are in lowercase. The algorithm is returned as m[algorithm] = "RSASHA1" +// A map[string]string is returned with the values. All the keys are +// converted to lowercase. All values are returned as-is, except +// the algorithm [e.g. 5 (RSASHA1)] is returned as: m[algorithm] = "RSASHA1" func (kp *Parser) PrivateKey() (m map[string]string, err os.Error) { m = make(map[string]string) var ( diff --git a/server.go b/server.go index cc05d6a8..111d3c4e 100644 --- a/server.go +++ b/server.go @@ -66,7 +66,8 @@ func (f HandlerFunc) ServeDNS(w ResponseWriter, r *Msg) { f(w, r) } -// Helper handlers +// Helper handler that returns an answer with +// RCODE = refused for every request. func Refused(w ResponseWriter, r *Msg) { m := new(Msg) m.SetReply(r) @@ -76,9 +77,10 @@ func Refused(w ResponseWriter, r *Msg) { w.Write(buf) } -// RefusedHandler return a REFUSED answer +// RefusedHandler returns HandlerFunc with Refused. func RefusedHandler() Handler { return HandlerFunc(Refused) } +// ... func ListenAndServe(addr string, network string, handler Handler) os.Error { server := &Server{Addr: addr, Net: network, Handler: handler} return server.ListenAndServe() diff --git a/tsig.go b/tsig.go index 2b931cb7..c02525e9 100644 --- a/tsig.go +++ b/tsig.go @@ -88,9 +88,9 @@ func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) (*Msg, os. return m, nil } -// Verify a TSIG on a message. +// Verify the TSIG on a message. // If the signature does not validate err contains the -// error. If the it validates err is nil +// error. If it validates err is nil. func TsigVerify(msg []byte, secret, requestMAC string, timersOnly bool) (bool, os.Error) { rawsecret, err := packBase64([]byte(secret)) if err != nil {