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
|
||||
case *reflect.BoolValue:
|
||||
// Used internally for Edns, not present in the DNS
|
||||
continue;
|
||||
continue
|
||||
case *reflect.SliceValue:
|
||||
switch f.Tag {
|
||||
default:
|
||||
|
@ -334,7 +334,7 @@ func unpackStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int,
|
|||
return len(msg), false, false
|
||||
case *reflect.BoolValue:
|
||||
// Used internally for Edns, not present in the DNS
|
||||
continue;
|
||||
continue
|
||||
case *reflect.SliceValue:
|
||||
switch f.Tag {
|
||||
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)
|
||||
}
|
9
types.go
9
types.go
|
@ -134,10 +134,15 @@ func (h *RR_Header) Header() *RR_Header {
|
|||
|
||||
func (h *RR_Header) String() string {
|
||||
var s string
|
||||
|
||||
if h.Edns {
|
||||
s = ";"
|
||||
}
|
||||
|
||||
if len(h.Name) == 0 {
|
||||
s = ".\t"
|
||||
s += ".\t"
|
||||
} else {
|
||||
s = h.Name + "\t"
|
||||
s += h.Name + "\t"
|
||||
}
|
||||
s = s + strconv.Itoa(int(h.Ttl)) + "\t"
|
||||
s = s + class_str[h.Class] + "\t"
|
||||
|
|
Loading…
Reference in New Issue