Append edns zero options

This commit is contained in:
Miek Gieben 2012-01-13 12:29:25 +01:00
parent ee11948fcb
commit 6e3385b868
2 changed files with 5 additions and 9 deletions

View File

@ -32,16 +32,14 @@ import (
const dom = "whoami.miek.nl"
func handleReflect(w dns.ResponseWriter, r *dns.Msg) {
m := new(dns.Msg)
m.SetReply(r)
m.Extra = make([]dns.RR, 1)
m.Answer = make([]dns.RR, 1)
var (
v4 bool
rr dns.RR
str string
a net.IP
)
m := new(dns.Msg)
m.SetReply(r)
if ip, ok := w.RemoteAddr().(*net.UDPAddr); ok {
str = "Port: " + strconv.Itoa(ip.Port) + " (udp)"
a = ip.IP
@ -67,8 +65,8 @@ func handleReflect(w dns.ResponseWriter, r *dns.Msg) {
t.Hdr = dns.RR_Header{Name: dom, Rrtype: dns.TypeTXT, Class: dns.ClassINET, Ttl: 0}
t.Txt = str
m.Extra[0] = t
m.Answer[0] = rr
m.Extra = append(m.Extra, t)
m.Answer = append(m.Answer, rr)
b, ok := m.Pack()
if !ok {
log.Print("Packing failed")

View File

@ -135,7 +135,5 @@ func (rr *RR_OPT) Nsid() string {
// SetNsid sets the NSID from a hex character string.
// Use the empty string when requesting an NSID.
func (rr *RR_OPT) SetNsid(hexnsid string) {
rr.Option = make([]Option, 1) // TODO(mg) check length first?
rr.Option[0].Code = OptionCodeNSID
rr.Option[0].Data = hexnsid
rr.Option = append(rr.Option, Option{OptionCodeNSID, hexnsid})
}