move tsig to tsig.go just as RR_OPT
This commit is contained in:
parent
63001dd590
commit
e1873c28bc
8
edns.go
8
edns.go
|
@ -32,14 +32,6 @@ type Option struct {
|
|||
* Rdlength uint16 // length of data after the header
|
||||
*/
|
||||
|
||||
// Adding an EDNS0 record to a message is done as follows:
|
||||
// opt := new(RR_OPT)
|
||||
// opt.Hdr = dns.RR_Header{Name: "", Rrtype: TypeOPT}
|
||||
// opt.SetVersion(0) // set version to zero
|
||||
// opt.SetDo() // set the DO bit
|
||||
// opt.SetUDPSize(4096) // set the message size
|
||||
// m.Extra = make([]RR, 1)
|
||||
// m.Extra[0] = opt // add OPT RR to the message
|
||||
type RR_OPT struct {
|
||||
Hdr RR_Header
|
||||
Option []Option "opt" // tag is used in Pack and Unpack
|
||||
|
|
41
tsig.go
41
tsig.go
|
@ -33,7 +33,6 @@
|
|||
// Basic use pattern validating and replying to a message that has TSIG set.
|
||||
// TODO(mg)
|
||||
//
|
||||
//
|
||||
package dns
|
||||
|
||||
import (
|
||||
|
@ -44,6 +43,7 @@ import (
|
|||
"encoding/hex"
|
||||
"hash"
|
||||
"io"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
@ -55,6 +55,45 @@ const (
|
|||
HmacSHA256 = "hmac-sha256."
|
||||
)
|
||||
|
||||
// RFC 2845.
|
||||
type RR_TSIG struct {
|
||||
Hdr RR_Header
|
||||
Algorithm string "domain-name"
|
||||
TimeSigned uint64
|
||||
Fudge uint16
|
||||
MACSize uint16
|
||||
MAC string "size-hex"
|
||||
OrigId uint16
|
||||
Error uint16
|
||||
OtherLen uint16
|
||||
OtherData string "size-hex"
|
||||
}
|
||||
|
||||
func (rr *RR_TSIG) Header() *RR_Header {
|
||||
return &rr.Hdr
|
||||
}
|
||||
|
||||
// TSIG has no official presentation format, but this will suffice.
|
||||
func (rr *RR_TSIG) String() string {
|
||||
s := "\n;; TSIG PSEUDOSECTION:\n"
|
||||
s += rr.Hdr.String() +
|
||||
" " + rr.Algorithm +
|
||||
" " + tsigTimeToDate(rr.TimeSigned) +
|
||||
" " + strconv.Itoa(int(rr.Fudge)) +
|
||||
" " + strconv.Itoa(int(rr.MACSize)) +
|
||||
" " + strings.ToUpper(rr.MAC) +
|
||||
" " + strconv.Itoa(int(rr.OrigId)) +
|
||||
" " + strconv.Itoa(int(rr.Error)) + // BIND prints NOERROR
|
||||
" " + strconv.Itoa(int(rr.OtherLen)) +
|
||||
" " + rr.OtherData
|
||||
return s
|
||||
}
|
||||
|
||||
func (rr *RR_TSIG) Len() int {
|
||||
return rr.Hdr.Len() + len(rr.Algorithm) + 1 + 6 +
|
||||
4 + len(rr.MAC)/2 + 1 + 6 + len(rr.OtherData)/2 + 1
|
||||
}
|
||||
|
||||
// The following values must be put in wireformat, so that the MAC can be calculated.
|
||||
// RFC 2845, section 3.4.2. TSIG Variables.
|
||||
type tsigWireFmt struct {
|
||||
|
|
39
types.go
39
types.go
|
@ -974,45 +974,6 @@ func (rr *RR_DHCID) Len() int {
|
|||
base64.StdEncoding.DecodedLen(len(rr.Digest))
|
||||
}
|
||||
|
||||
// RFC 2845.
|
||||
type RR_TSIG struct {
|
||||
Hdr RR_Header
|
||||
Algorithm string "domain-name"
|
||||
TimeSigned uint64
|
||||
Fudge uint16
|
||||
MACSize uint16
|
||||
MAC string "size-hex"
|
||||
OrigId uint16
|
||||
Error uint16
|
||||
OtherLen uint16
|
||||
OtherData string "size-hex"
|
||||
}
|
||||
|
||||
func (rr *RR_TSIG) Header() *RR_Header {
|
||||
return &rr.Hdr
|
||||
}
|
||||
|
||||
// TSIG has no official presentation format, but this will suffice.
|
||||
func (rr *RR_TSIG) String() string {
|
||||
s := "\n;; TSIG PSEUDOSECTION:\n"
|
||||
s += rr.Hdr.String() +
|
||||
" " + rr.Algorithm +
|
||||
" " + tsigTimeToDate(rr.TimeSigned) +
|
||||
" " + strconv.Itoa(int(rr.Fudge)) +
|
||||
" " + strconv.Itoa(int(rr.MACSize)) +
|
||||
" " + strings.ToUpper(rr.MAC) +
|
||||
" " + strconv.Itoa(int(rr.OrigId)) +
|
||||
" " + strconv.Itoa(int(rr.Error)) + // BIND prints NOERROR
|
||||
" " + strconv.Itoa(int(rr.OtherLen)) +
|
||||
" " + rr.OtherData
|
||||
return s
|
||||
}
|
||||
|
||||
func (rr *RR_TSIG) Len() int {
|
||||
return rr.Hdr.Len() + len(rr.Algorithm) + 1 + 6 +
|
||||
4 + len(rr.MAC)/2 + 1 + 6 + len(rr.OtherData)/2 + 1
|
||||
}
|
||||
|
||||
type RR_TLSA struct {
|
||||
Hdr RR_Header
|
||||
Usage uint8
|
||||
|
|
Loading…
Reference in New Issue