Make it compile
This commit is contained in:
parent
c37493cbbf
commit
743e1dd3e8
8
edns.go
8
edns.go
|
@ -143,8 +143,12 @@ type EDNS0 interface {
|
||||||
// identifier. The identifier is an opaque string encoded has hex.
|
// identifier. The identifier is an opaque string encoded has hex.
|
||||||
// Basic use pattern for creating an nsid option:
|
// 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 := new(dns.EDNS0_NSID)
|
||||||
// e.Code = dns.EDNS0NSID
|
// e.Code = dns.EDNS0NSID
|
||||||
|
// o.Option = append(o.Option, e)
|
||||||
type EDNS0_NSID struct {
|
type EDNS0_NSID struct {
|
||||||
Code uint16 // Always EDNS0NSID
|
Code uint16 // Always EDNS0NSID
|
||||||
Nsid string // This string needs to be hex encoded
|
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.
|
// answer depending on the location or network topology.
|
||||||
// Basic use pattern for creating an subnet option:
|
// 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 := new(dns.EDNS0_SUBNET)
|
||||||
// e.Code = dns.EDNS0SUBNET
|
// e.Code = dns.EDNS0SUBNET
|
||||||
// e.Family = 1 // 1 for IPv4 source address, 2 for IPv6
|
// 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.SourceScope = 0
|
||||||
// e.Address = net.ParseIP("127.0.0.1").To4() // for IPv4
|
// e.Address = net.ParseIP("127.0.0.1").To4() // for IPv4
|
||||||
// // e.Address = net.ParseIP("2001:7b8:32a::2") // for IPV6
|
// // e.Address = net.ParseIP("2001:7b8:32a::2") // for IPV6
|
||||||
|
// o.Option = append(o.Option, e)
|
||||||
type EDNS0_SUBNET struct {
|
type EDNS0_SUBNET struct {
|
||||||
Code uint16 // Always EDNS0SUBNET
|
Code uint16 // Always EDNS0SUBNET
|
||||||
Family uint16 // 1 for IP, 2 for IP6
|
Family uint16 // 1 for IP, 2 for IP6
|
||||||
|
|
|
@ -239,7 +239,7 @@ func toFingerprint(m *dns.Msg) *fingerprint {
|
||||||
f.UDPSize = int(r.(*dns.RR_OPT).UDPSize())
|
f.UDPSize = int(r.(*dns.RR_OPT).UDPSize())
|
||||||
if len(r.(*dns.RR_OPT).Option) == 1 {
|
if len(r.(*dns.RR_OPT).Option) == 1 {
|
||||||
// Only support NSID atm
|
// 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.
|
// We have added an OPT RR, set the size.
|
||||||
m.Extra[0].(*dns.RR_OPT).SetUDPSize(uint16(f.UDPSize))
|
m.Extra[0].(*dns.RR_OPT).SetUDPSize(uint16(f.UDPSize))
|
||||||
if f.Nsid {
|
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
|
return m
|
||||||
|
|
Loading…
Reference in New Issue