diff --git a/doh-server/server.go b/doh-server/server.go index d1c8793..0827c16 100644 --- a/doh-server/server.go +++ b/doh-server/server.go @@ -81,7 +81,6 @@ func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") w.Header().Set("Server", "DNS-over-HTTPS/1.0 (+https://github.com/m13253/dns-over-https)") w.Header().Set("X-Powered-By", "DNS-over-HTTPS/1.0 (+https://github.com/m13253/dns-over-https)") - w.Header().Set("Vary", "X-Edns-Client-Subnet") name := r.FormValue("name") if name == "" { @@ -205,9 +204,6 @@ func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) { w.Header().Set("Cache-Control", "max-age=" + strconv.Itoa(int(respJson.LeastTTL))) w.Header().Set("Expires", respJson.EarliestExpires.Format(time.RFC1123)) } - if respJson.EdnsClientSubnet != "" { - w.Header().Set("X-Edns-Client-Subnet", respJson.EdnsClientSubnet) - } w.Write(respStr) } diff --git a/json-dns/marshal.go b/json-dns/marshal.go index d5403f1..2a0d996 100644 --- a/json-dns/marshal.go +++ b/json-dns/marshal.go @@ -84,8 +84,7 @@ func Marshal(msg *dns.Msg) *Response { } else if ipv4 := clientAddress.To4(); ipv4 != nil { clientAddress = ipv4 } - scopeMask := net.CIDRMask(int(edns0.SourceScope), len(clientAddress) * 8) - resp.EdnsClientSubnet = clientAddress.Mask(scopeMask).String() + "/" + strconv.Itoa(int(edns0.SourceScope)) + resp.EdnsClientSubnet = clientAddress.String() + "/" + strconv.Itoa(int(edns0.SourceScope)) } } continue