add TSIG as a type

This commit is contained in:
Miek Gieben 2010-12-31 15:10:42 +01:00
parent 3de30d5834
commit 9155d632f5
4 changed files with 40 additions and 10 deletions

View File

@ -17,20 +17,17 @@ include $(GOROOT)/src/Make.pkg
all: package
gomake -C dnssec package
gomake -C resolver package
# gomake -C xfr package
# gomake -C strconv package
install: $(INSTALLFILES)
gomake -C dnssec install
gomake -C resolver install
# gomake -C xfr package
# gomake -C strconv install
dnstest:
gotest
gomake -C dnssec test
gomake -C resolver test
# gomake -C xfr test
# gomake -C strconv test
_examples:

1
dns.go
View File

@ -10,6 +10,7 @@
// * 1876 - LOC record (incomplete)
// * 1995 - IXFR
// * 2671 - EDNS
// * 2845 - TSIG
// * 2915 - NAPTR record (incomplete)
// * 3225 - DO bit (DNSSEC OK)
// * 4033/4034/4035 - DNSSEC + validation functions

View File

@ -58,13 +58,6 @@ func NewQuerier(res *Resolver) (ch chan DnsMsg) {
return
}
// Start a new xfr as a goroutine, return a channel.
// Channel will be closed when the axfr is finished, until
// that time new messages will appear on the channel
func NewXfer(res *Resolver) (ch chan DnsMsg) {
}
// The query function.
func query(res *Resolver, msg chan DnsMsg) {
// TODO port number, error checking, robustness
@ -135,6 +128,20 @@ func query(res *Resolver, msg chan DnsMsg) {
return
}
// Start a new xfr as a goroutine, return a channel.
// Channel will be closed when the axfr is finished, until
// that time new messages will appear on the channel
func NewXfer(res *Resolver) (ch chan DnsMsg) {
ch = make(chan DnsMsg)
go axfr(res, ch)
return
}
func axfr(res *Resolver, msg chan DnsMsg) {
return
}
// Send a request on the connection and hope for a reply.
// Up to res.Attempts attempts.
func exchange_udp(c net.Conn, m []byte, r *Resolver) (*dns.Msg, os.Error) {

View File

@ -59,6 +59,7 @@ const (
TypeNSEC3 = 50
TypeNSEC3PARAM = 51
TypeTSIG = 250
// valid Question.qtype only
TypeIXFR = 251
TypeAXFR = 252
@ -80,6 +81,10 @@ const (
RcodeNameError = 3
RcodeNotImplemented = 4
RcodeRefused = 5
// Tsig errors
RcodeBadSig = 16
RcodeBadKey = 17
RcodeBadTime = 18
)
// The wire format for the DNS packet header.
@ -479,6 +484,26 @@ func (rr *RR_NSEC3PARAM) String() string {
// Salt with strings.ToUpper()
}
type RR_TSIG struct {
Hdr RR_Header
Algoritim string "domain-name"
TimeSigned [3]uint16 // uint48 *sigh*
Fudge uint16
MACSize uint16
MAC string
Error uint16
OtherLen uint16
OtherData string
}
func (rr *RR_TSIG) Header() *RR_Header {
return &rr.Hdr
}
func (rr *RR_TSIG) String() string {
return rr.Hdr.String() + "TODO"
}
// Translate the RRSIG's incep. and expir. time to the correct date.
// Taking into account serial arithmetic (RFC 1982)
func timeToDate(t uint32) string {