From dd627b2407b20564344eb8b34fe95afbbd560e90 Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Wed, 4 Oct 2017 12:54:05 +0800 Subject: [PATCH] Workaround bug https://github.com/miekg/dns/pull/530 --- json-dns/marshal.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/json-dns/marshal.go b/json-dns/marshal.go index 01209a3..9e45c2a 100644 --- a/json-dns/marshal.go +++ b/json-dns/marshal.go @@ -78,8 +78,12 @@ func Marshal(msg *dns.Msg) *Response { for _, option := range opt.Option { if option.Option() == dns.EDNS0SUBNET { edns0 := option.(*dns.EDNS0_SUBNET) + clientAddress := edns0.Address + if clientAddress == nil { + clientAddress = net.IPv4(0, 0, 0, 0) + } scopeMask := net.CIDRMask(int(edns0.SourceScope), len(edns0.Address)) - resp.EdnsClientSubnet = edns0.Address.Mask(scopeMask).String() + "/" + strconv.Itoa(int(edns0.SourceScope)) + resp.EdnsClientSubnet = clientAddress.Mask(scopeMask).String() + "/" + strconv.Itoa(int(edns0.SourceScope)) } } continue