From 82c793d78d8f35b7ad1ba0a1f4887da28df4f3fb Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Wed, 4 Oct 2017 13:32:23 +0800 Subject: [PATCH] Set ECS prefix as scope --- doh-client/client.go | 2 +- json-dns/unmarshal.go | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/doh-client/client.go b/doh-client/client.go index 1eb30a7..2f25fa5 100644 --- a/doh-client/client.go +++ b/doh-client/client.go @@ -156,7 +156,7 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) { return } - fullReply := jsonDNS.Unmarshal(reply, &respJson, udpSize, ednsClientNetmask) + fullReply := jsonDNS.Unmarshal(reply, &respJson, udpSize) buf, err := fullReply.Pack() if err != nil { log.Println(err) diff --git a/json-dns/unmarshal.go b/json-dns/unmarshal.go index 7f495ae..73e94cd 100644 --- a/json-dns/unmarshal.go +++ b/json-dns/unmarshal.go @@ -42,7 +42,7 @@ func PrepareReply(req *dns.Msg) *dns.Msg { return reply } -func Unmarshal(msg *dns.Msg, resp *Response, udpSize uint16, ednsClientNetmask uint8) *dns.Msg { +func Unmarshal(msg *dns.Msg, resp *Response, udpSize uint16) *dns.Msg { now := time.Now().UTC() reply := msg.Copy() @@ -110,17 +110,10 @@ func Unmarshal(msg *dns.Msg, resp *Response, udpSize uint16, ednsClientNetmask u } } if ednsClientAddress != nil { - if ednsClientNetmask == 255 { - if ednsClientFamily == 1 { - ednsClientNetmask = 24 - } else { - ednsClientNetmask = 48 - } - } edns0Subnet := new(dns.EDNS0_SUBNET) edns0Subnet.Code = dns.EDNS0SUBNET edns0Subnet.Family = ednsClientFamily - edns0Subnet.SourceNetmask = ednsClientNetmask + edns0Subnet.SourceNetmask = ednsClientScope edns0Subnet.SourceScope = ednsClientScope edns0Subnet.Address = ednsClientAddress opt.Option = append(opt.Option, edns0Subnet)