documentation

This commit is contained in:
Miek Gieben 2011-07-23 23:32:42 +02:00
parent 9b1e7b4b3d
commit a0b011799e
5 changed files with 12 additions and 8 deletions

View File

@ -125,7 +125,7 @@ type Client struct {
// LocalAddr string // Local address to use // 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 { func NewClient() *Client {
c := new(Client) c := new(Client)
c.Net = "udp" c.Net = "udp"

View File

@ -94,7 +94,7 @@ func (dns *Msg) IsIxfr() (ok bool) {
return 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) { func (dns *Msg) IsTsig() (ok bool) {
if len(dns.Extra) > 0 { if len(dns.Extra) > 0 {
return dns.Extra[0].Header().Rrtype == TypeTSIG return dns.Extra[0].Header().Rrtype == TypeTSIG
@ -102,6 +102,7 @@ func (dns *Msg) IsTsig() (ok bool) {
return return
} }
// SetTsig Calculates and appends a TSIG RR on the message.
func (dns *Msg) SetTsig(z, algo string, fudge uint16, timesigned uint64) { func (dns *Msg) SetTsig(z, algo string, fudge uint16, timesigned uint64) {
t := new(RR_TSIG) t := new(RR_TSIG)
t.Hdr = RR_Header{z, TypeTSIG, ClassANY, 0, 0} t.Hdr = RR_Header{z, TypeTSIG, ClassANY, 0, 0}

View File

@ -13,8 +13,9 @@ import (
}%% }%%
// PrivateKey parses a private key file as defined in XXX. // PrivateKey parses a private key file as defined in XXX.
// A map[string]string is returned with the values. All the keys // A map[string]string is returned with the values. All the keys are
// are in lowercase. The algorithm is returned as m[algorithm] = "RSASHA1" // 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) { func (kp *Parser) PrivateKey() (m map[string]string, err os.Error) {
m = make(map[string]string) m = make(map[string]string)
var ( var (

View File

@ -66,7 +66,8 @@ func (f HandlerFunc) ServeDNS(w ResponseWriter, r *Msg) {
f(w, r) f(w, r)
} }
// Helper handlers // Helper handler that returns an answer with
// RCODE = refused for every request.
func Refused(w ResponseWriter, r *Msg) { func Refused(w ResponseWriter, r *Msg) {
m := new(Msg) m := new(Msg)
m.SetReply(r) m.SetReply(r)
@ -76,9 +77,10 @@ func Refused(w ResponseWriter, r *Msg) {
w.Write(buf) w.Write(buf)
} }
// RefusedHandler return a REFUSED answer // RefusedHandler returns HandlerFunc with Refused.
func RefusedHandler() Handler { return HandlerFunc(Refused) } func RefusedHandler() Handler { return HandlerFunc(Refused) }
// ...
func ListenAndServe(addr string, network string, handler Handler) os.Error { func ListenAndServe(addr string, network string, handler Handler) os.Error {
server := &Server{Addr: addr, Net: network, Handler: handler} server := &Server{Addr: addr, Net: network, Handler: handler}
return server.ListenAndServe() return server.ListenAndServe()

View File

@ -88,9 +88,9 @@ func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) (*Msg, os.
return m, nil return m, nil
} }
// Verify a TSIG on a message. // Verify the TSIG on a message.
// If the signature does not validate err contains the // 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) { func TsigVerify(msg []byte, secret, requestMAC string, timersOnly bool) (bool, os.Error) {
rawsecret, err := packBase64([]byte(secret)) rawsecret, err := packBase64([]byte(secret))
if err != nil { if err != nil {