New does help

This commit is contained in:
Miek Gieben 2011-03-13 14:51:02 +01:00
parent a3865be05e
commit 496ab892d8
4 changed files with 35 additions and 1 deletions

3
TODO
View File

@ -4,6 +4,9 @@ Todo:
* encoding NSEC3/NSEC bitmaps, DEcoding works
* AXFR/IXFR with TSIG validation
* Failed Xfr triggers nil error?
* Use callback in IXFR/AXFR to make tsig happen (and other cool stuff in FunkenSturm)
* A New for all type with some defaults filled in
* Take a good look at hash.Hash take over the digest sizes and names
* HIP RR (needs list of domain names, need slice stuff for that)
Issues:

1
dns.go
View File

@ -23,6 +23,7 @@ const (
Year68 = 2 << (32 - 1) // For RFC1982 (Serial Arithmetic) calculations in 32 bits.
DefaultMsgSize = 4096 // A standard default for larger than 512 packets.
MaxMsgSize = 65536 // Largest possible DNS packet.
DefaultTtl = 3600 // Default Ttl, used in New() for instance.
)
// Error represents a DNS error

28
new.go Normal file
View File

@ -0,0 +1,28 @@
package dns
func New(i int) RR {
var rr RR
mk, known := rr_mk[i]
if !known {
rr = new(RR_RFC3597)
} else {
rr = mk()
}
switch t := rr.(type) {
case *RR_RFC3597:
t.Hdr = RR_Header{Ttl: DefaultTtl, Class: ClassINET, Rrtype: uint16(i)}
case *RR_TSIG:
t.Hdr = RR_Header{Ttl: 0, Class: ClassANY, Rrtype: uint16(i)}
t.Fudge = 300
case *RR_OPT:
t.Hdr = RR_Header{Name: "", Ttl: 0, Class: 0, Rrtype: uint16(i)}
t.SetVersion(0)
t.SetUDPSize(DefaultMsgSize)
case *RR_A:
t.Hdr = RR_Header{Ttl: DefaultTtl, Class: ClassINET, Rrtype: uint16(i)}
case *RR_AAAA:
t.Hdr = RR_Header{Ttl: DefaultTtl, Class: ClassINET, Rrtype: uint16(i)}
}
return rr
}

View File

@ -219,7 +219,9 @@ Server:
// returned over the channel, so the caller will receive
// the zone as-is. Xfr.Add is always true.
// The channel is closed to signal the end of the AXFR.
func (res *Resolver) Axfr(q *Msg, m chan Xfr) {
// f is a callback function called after every message has been
// received.
func (res *Resolver) Axfr(q *Msg, m chan Xfr, f func(*Msg) bool) {
var port string
var in *Msg
if res.Port == "" {