From 743e1dd3e80100106a9e2000856cef2d615e3c1e Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Thu, 5 Jul 2012 11:53:09 +0200 Subject: [PATCH] Make it compile --- edns.go | 8 ++++++++ ex/fp/fp.go | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/edns.go b/edns.go index c168cd0e..9f16ae92 100644 --- a/edns.go +++ b/edns.go @@ -143,8 +143,12 @@ type EDNS0 interface { // identifier. The identifier is an opaque string encoded has hex. // Basic use pattern for creating an nsid option: // +// o := new(dns.RR_OPT) +// o.Hdr.Name = "." +// o.Hdr.Rrtype = dns.TypeOPT // e := new(dns.EDNS0_NSID) // e.Code = dns.EDNS0NSID +// o.Option = append(o.Option, e) type EDNS0_NSID struct { Code uint16 // Always EDNS0NSID Nsid string // This string needs to be hex encoded @@ -175,6 +179,9 @@ func (e *EDNS0_NSID) String() string { // answer depending on the location or network topology. // Basic use pattern for creating an subnet option: // +// o := new(dns.RR_OPT) +// o.Hdr.Name = "." +// o.Hdr.Rrtype = dns.TypeOPT // e := new(dns.EDNS0_SUBNET) // e.Code = dns.EDNS0SUBNET // e.Family = 1 // 1 for IPv4 source address, 2 for IPv6 @@ -182,6 +189,7 @@ func (e *EDNS0_NSID) String() string { // e.SourceScope = 0 // e.Address = net.ParseIP("127.0.0.1").To4() // for IPv4 // // e.Address = net.ParseIP("2001:7b8:32a::2") // for IPV6 +// o.Option = append(o.Option, e) type EDNS0_SUBNET struct { Code uint16 // Always EDNS0SUBNET Family uint16 // 1 for IP, 2 for IP6 diff --git a/ex/fp/fp.go b/ex/fp/fp.go index 51e206e7..5bc95b8a 100644 --- a/ex/fp/fp.go +++ b/ex/fp/fp.go @@ -239,7 +239,7 @@ func toFingerprint(m *dns.Msg) *fingerprint { f.UDPSize = int(r.(*dns.RR_OPT).UDPSize()) if len(r.(*dns.RR_OPT).Option) == 1 { // Only support NSID atm - f.Nsid = r.(*dns.RR_OPT).Option[0].Code == dns.OptionCodeNSID + f.Nsid = r.(*dns.RR_OPT).Option[0].Option() == dns.EDNS0NSID } } } @@ -270,7 +270,9 @@ func (f *fingerprint) msg() *dns.Msg { // We have added an OPT RR, set the size. m.Extra[0].(*dns.RR_OPT).SetUDPSize(uint16(f.UDPSize)) if f.Nsid { - m.Extra[0].(*dns.RR_OPT).SetNsid("") + e := new(dns.EDNS0_NSID) + e.Code = dns.EDNS0NSID + m.Extra[0].(*dns.RR_OPT).Option = append(m.Extra[0].(*dns.RR_OPT).Option, e) } } return m