Add documentation and fix the tests for TSIG

Everything is working, I get a complete TSIG verified AXFR from
miek.nl.
This commit is contained in:
Miek Gieben 2011-09-11 01:37:06 +02:00
parent 3be73fcea9
commit f252e2f3f0
4 changed files with 34 additions and 10 deletions

View File

@ -78,12 +78,12 @@ func TestClientEDNS0(t *testing.T) {
func TestClientTsigAXFR(t *testing.T) {
m := new(Msg)
m.SetAxfr("miek.nl")
m.SetAxfr("miek.nl.")
m.SetTsig("axfr", HmacMD5, 300, uint64(time.Seconds()))
m.SetTsig("axfr.", HmacMD5, 300, uint64(time.Seconds()))
TsigGenerate(m, "so6ZGir4GPAqINNh9U5c3A==", "", false)
secrets := make(map[string]string)
secrets["axfr"] = "so6ZGir4GPAqINNh9U5c3A=="
secrets["axfr."] = "so6ZGir4GPAqINNh9U5c3A=="
println(m.String())
c := NewClient()

View File

@ -3,6 +3,9 @@ package dns
// Everything is assumed in the ClassINET class. If
// you need other classes you are on your own.
// Add SetEDNS0
// IsEDNS0 function
// Create a reply packet from a request message.
func (dns *Msg) SetReply(request *Msg) {
dns.MsgHdr.Id = request.MsgHdr.Id

33
tsig.go
View File

@ -1,5 +1,32 @@
// TSIG or transaction signature add a HMAC TSIG record to each message sent.
// Basic use pattern when querying with TSIG:
//
// m := new(Msg)
// m.SetAxfr("miek.nl.")
// // Add a skeleton TSIG record.
// m.SetTsig("axfr.", HmacMD5, 300, uint64(time.Seconds()))
// // Generate the contents of the complete TSIG record.
// TsigGenerate(m, "so6ZGir4GPAqINNh9U5c3A==", "", false)
// // A map holds all the secrets
// secrets := make(map[string]string)
// secrets["axfr."] = "so6ZGir4GPAqINNh9U5c3A==" // don't forget the . here
//
// The message requesting an AXFR for miek.nl with the TSIG record is now ready to use.
// We now need a new client with access to the secrets:
//
// c := NewClient()
// c.TsigSecret = secrets
// err := c.XfrReceive(m, "85.223.71.124:53")
//
// You can now read the records from the AXFR as the come in.
//
// Basic use pattern replying to a message which has TSIG set.
// TODO(mg)
//
package dns
// Fill in the TSIG errors. 0 = NOERROR, etc. like BIND
import (
"io"
"os"
@ -9,12 +36,6 @@ import (
"encoding/hex"
)
// The structure Tsig is used in Read/Write functions to
// add or remove a TSIG on a dns message. See RFC 2845
// and RFC 4635.
// Basic use pattern of Tsig:
//
// HMAC hashing codes. These are transmitted as domain names.
const (
HmacMD5 = "hmac-md5.sig-alg.reg.int."

View File

@ -792,7 +792,7 @@ func (rr *RR_TSIG) String() string {
" " + strconv.Itoa(int(rr.MACSize)) +
" " + strings.ToUpper(rr.MAC) +
" " + strconv.Itoa(int(rr.OrigId)) +
" " + strconv.Itoa(int(rr.Error)) +
" " + strconv.Itoa(int(rr.Error)) + // BIND prints NOERROR
" " + strconv.Itoa(int(rr.OtherLen)) +
" " + rr.OtherData
}