Make it compile

This commit is contained in:
Miek Gieben 2012-07-05 11:53:09 +02:00
parent c37493cbbf
commit 743e1dd3e8
2 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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