At least it gives formerr now
This commit is contained in:
parent
4668b309e2
commit
8302d19b42
4
msg.go
4
msg.go
|
@ -201,7 +201,7 @@ func packStructValue(val *reflect.StructValue, msg []byte, off int, edns bool) (
|
||||||
return len(msg), false
|
return len(msg), false
|
||||||
case *reflect.BoolValue:
|
case *reflect.BoolValue:
|
||||||
// Used internally for Edns, not present in the DNS
|
// Used internally for Edns, not present in the DNS
|
||||||
continue;
|
continue
|
||||||
case *reflect.SliceValue:
|
case *reflect.SliceValue:
|
||||||
switch f.Tag {
|
switch f.Tag {
|
||||||
default:
|
default:
|
||||||
|
@ -334,7 +334,7 @@ func unpackStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int,
|
||||||
return len(msg), false, false
|
return len(msg), false, false
|
||||||
case *reflect.BoolValue:
|
case *reflect.BoolValue:
|
||||||
// Used internally for Edns, not present in the DNS
|
// Used internally for Edns, not present in the DNS
|
||||||
continue;
|
continue
|
||||||
case *reflect.SliceValue:
|
case *reflect.SliceValue:
|
||||||
switch f.Tag {
|
switch f.Tag {
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package dns
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestResolverEdns(t *testing.T) {
|
||||||
|
res := new(Resolver)
|
||||||
|
ch := NewQuerier(res)
|
||||||
|
|
||||||
|
res.Servers = []string{"127.0.0.1"}
|
||||||
|
res.Timeout = 2
|
||||||
|
res.Attempts = 1
|
||||||
|
|
||||||
|
m := new(Msg)
|
||||||
|
m.MsgHdr.Recursion_desired = true //only set this bit
|
||||||
|
m.Question = make([]Question, 1)
|
||||||
|
m.Extra = make([]RR, 1)
|
||||||
|
|
||||||
|
// Add EDNS rr
|
||||||
|
edns := new(RR_OPT)
|
||||||
|
edns.Hdr.Edns = true // must be set for edns
|
||||||
|
edns.Hdr.Name = "." // must . be for edns
|
||||||
|
edns.Hdr.Rrtype = TypeOPT
|
||||||
|
edns.Hdr.Class = ClassINET
|
||||||
|
edns.Hdr.Ttl = 3600
|
||||||
|
// no options
|
||||||
|
// edns.Option = make([]Option, 1)
|
||||||
|
// edns.Option[0].Code = OptionCodeNSID
|
||||||
|
// edns.Option[0].Data = "lalalala"
|
||||||
|
|
||||||
|
// ask something
|
||||||
|
m.Question[0] = Question{"miek.nl", TypeSOA, ClassINET}
|
||||||
|
m.Extra[0] = edns
|
||||||
|
|
||||||
|
fmt.Printf("%v\n", m)
|
||||||
|
|
||||||
|
ch <- DnsMsg{m, nil}
|
||||||
|
in := <-ch
|
||||||
|
|
||||||
|
if in.Dns.Rcode != RcodeSuccess {
|
||||||
|
t.Log("Failed to get an valid answer")
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
fmt.Printf("%v\n", in)
|
||||||
|
|
||||||
|
ch <- DnsMsg{nil, nil}
|
||||||
|
time.Sleep(1.0e9)
|
||||||
|
}
|
17
types.go
17
types.go
|
@ -134,10 +134,15 @@ func (h *RR_Header) Header() *RR_Header {
|
||||||
|
|
||||||
func (h *RR_Header) String() string {
|
func (h *RR_Header) String() string {
|
||||||
var s string
|
var s string
|
||||||
|
|
||||||
|
if h.Edns {
|
||||||
|
s = ";"
|
||||||
|
}
|
||||||
|
|
||||||
if len(h.Name) == 0 {
|
if len(h.Name) == 0 {
|
||||||
s = ".\t"
|
s += ".\t"
|
||||||
} else {
|
} else {
|
||||||
s = h.Name + "\t"
|
s += h.Name + "\t"
|
||||||
}
|
}
|
||||||
s = s + strconv.Itoa(int(h.Ttl)) + "\t"
|
s = s + strconv.Itoa(int(h.Ttl)) + "\t"
|
||||||
s = s + class_str[h.Class] + "\t"
|
s = s + class_str[h.Class] + "\t"
|
||||||
|
@ -376,8 +381,8 @@ func (rr *RR_RRSIG) Header() *RR_Header {
|
||||||
// needs serial stuff
|
// needs serial stuff
|
||||||
// starts when 1970 has been 68 years ago??
|
// starts when 1970 has been 68 years ago??
|
||||||
func intToDate(t uint32) string {
|
func intToDate(t uint32) string {
|
||||||
// als meer dan 68 jaar geleden, dan 68 jaar bij bedrag optellen
|
// als meer dan 68 jaar geleden, dan 68 jaar bij bedrag optellen
|
||||||
// TODO
|
// TODO
|
||||||
ti := time.SecondsToUTC(int64(t))
|
ti := time.SecondsToUTC(int64(t))
|
||||||
return ti.Format("20060102030405")
|
return ti.Format("20060102030405")
|
||||||
}
|
}
|
||||||
|
@ -389,9 +394,9 @@ func (rr *RR_RRSIG) String() string {
|
||||||
" " + strconv.Itoa(int(rr.Algorithm)) +
|
" " + strconv.Itoa(int(rr.Algorithm)) +
|
||||||
" " + strconv.Itoa(int(rr.Labels)) +
|
" " + strconv.Itoa(int(rr.Labels)) +
|
||||||
" " + strconv.Itoa(int(rr.OrigTtl)) +
|
" " + strconv.Itoa(int(rr.OrigTtl)) +
|
||||||
// " " + strconv.Itoa(int(rr.Expiration)) + // date calc! TODO
|
// " " + strconv.Itoa(int(rr.Expiration)) + // date calc! TODO
|
||||||
" " + intToDate(rr.Expiration) +
|
" " + intToDate(rr.Expiration) +
|
||||||
// " " + strconv.Itoa(int(rr.Inception)) + // date calc! TODO
|
// " " + strconv.Itoa(int(rr.Inception)) + // date calc! TODO
|
||||||
" " + intToDate(rr.Inception) +
|
" " + intToDate(rr.Inception) +
|
||||||
" " + strconv.Itoa(int(rr.KeyTag)) +
|
" " + strconv.Itoa(int(rr.KeyTag)) +
|
||||||
" " + rr.SignerName +
|
" " + rr.SignerName +
|
||||||
|
|
Loading…
Reference in New Issue