diff --git a/edns.go b/edns.go index 98f3e9d3..395ea22b 100644 --- a/edns.go +++ b/edns.go @@ -117,7 +117,12 @@ func (rr *RR_OPT) Nsid() string { } // Set the NSID -func (rr *RR_OPT) SetNsid(nsid string) { +func (rr *RR_OPT) SetNsidToHex(hexnsid string) { rr.Option[0].Code = OptionCodeNSID - rr.Option[0].Data = nsid + rr.Option[0].Data = hexnsid +} + +func (rr *RR_OPT) SetNsidToString(nsid string) { + rr.Option[0].Code = OptionCodeNSID + rr.Option[0].Data = hex.EncodeToString([]byte(nsid)) } diff --git a/pack_test.go b/pack_test.go index 69259211..6631a305 100644 --- a/pack_test.go +++ b/pack_test.go @@ -31,8 +31,7 @@ func TestPackUnpack(t *testing.T) { edns.Hdr.Class = ClassINET edns.Hdr.Ttl = 3600 edns.Option = make([]Option, 1) - edns.Option[0].Code = OptionCodeNSID - edns.Option[0].Data = "lalalala" + edns.SetNsidToString("lalalala") _, ok = packRR(edns, msg, 0) if !ok {