Revert "all: safesearch https"

This reverts commit 1c9564b9b4.
This commit is contained in:
Dimitry Kolyshev 2024-04-11 12:09:27 +02:00
parent 1c9564b9b4
commit cd403a2897
2 changed files with 12 additions and 29 deletions

View File

@ -48,7 +48,7 @@ func (s *Server) genDNSFilterMessage(
) (resp *dns.Msg) {
req := dctx.Req
qt := req.Question[0].Qtype
if qt != dns.TypeA && qt != dns.TypeAAAA && qt != dns.TypeHTTPS {
if qt != dns.TypeA && qt != dns.TypeAAAA {
m, _, _ := s.dnsFilter.BlockingMode()
if m == filtering.BlockingModeNullIP {
return s.makeResponse(req)
@ -97,13 +97,6 @@ func (s *Server) getCNAMEWithIPs(req *dns.Msg, ips []netip.Addr, cname string) (
ans = append(ans, s.genAnswerAAAA(req, ip))
}
}
case dns.TypeHTTPS:
ans = append(ans, s.genAnswersWithIPv4s(req, ips)...)
for _, ip := range ips {
if ip.Is6() {
ans = append(ans, s.genAnswerAAAA(req, ip))
}
}
default:
// Go on and return an empty response.
}

View File

@ -226,8 +226,8 @@ func (ss *Default) searchHost(host string, qtype rules.RRType) (res *rules.DNSRe
}
// newResult creates Result object from rewrite rule. qtype must be either
// [dns.TypeA] or [dns.TypeAAAA], or [dns.TypeHTTPS]. If err is nil, res is
// never nil, so that the empty result is converted into a NODATA response.
// [dns.TypeA] or [dns.TypeAAAA]. If err is nil, res is never nil, so that the
// empty result is converted into a NODATA response.
//
// TODO(a.garipov): Use the main rewrite result mechanism used in
// [dnsforward.Server.filterDNSRequest]. Now we resolve IPs for CNAME to save
@ -286,11 +286,11 @@ func (ss *Default) newResult(
return res, nil
}
// qtypeToProto returns "ip4" for [dns.TypeA] or [dns.TypeHTTPS], and "ip6" for
// [dns.TypeAAAA]. It panics for other types.
// qtypeToProto returns "ip4" for [dns.TypeA] and "ip6" for [dns.TypeAAAA].
// It panics for other types.
func qtypeToProto(qtype rules.RRType) (proto string) {
switch qtype {
case dns.TypeA, dns.TypeHTTPS:
case dns.TypeA:
return "ip4"
case dns.TypeAAAA:
return "ip6"
@ -300,31 +300,21 @@ func qtypeToProto(qtype rules.RRType) (proto string) {
}
// fitToProto returns a non-nil IP address if ip is the correct protocol version
// for qtype. qtype is expected to be either [dns.TypeA] or [dns.TypeAAAA], or
// [dns.TypeHTTPS].
// for qtype. qtype is expected to be either [dns.TypeA] or [dns.TypeAAAA].
func fitToProto(ip net.IP, qtype rules.RRType) (res netip.Addr) {
ip4 := ip.To4()
ip6 := ip.To16()
if qtype == dns.TypeA && ip4 != nil {
return netip.AddrFrom4([4]byte(ip4))
} else if ip6 != nil && qtype == dns.TypeAAAA {
return netip.AddrFrom16([16]byte(ip6))
}
if qtype == dns.TypeHTTPS {
if ip4 := ip.To4(); qtype == dns.TypeA {
if ip4 != nil {
return netip.AddrFrom4([4]byte(ip4))
} else if ip6 != nil {
return netip.AddrFrom16([16]byte(ip6))
}
} else if ip = ip.To16(); ip != nil && qtype == dns.TypeAAAA {
return netip.AddrFrom16([16]byte(ip))
}
return netip.Addr{}
}
// setCacheResult stores data in cache for host. qtype is expected to be either
// [dns.TypeA] or [dns.TypeAAAA], or [dns.TypeHTTPS].
// [dns.TypeA] or [dns.TypeAAAA].
func (ss *Default) setCacheResult(host string, qtype rules.RRType, res filtering.Result) {
expire := uint32(time.Now().Add(ss.cacheTTL).Unix())
exp := make([]byte, 4)
@ -345,7 +335,7 @@ func (ss *Default) setCacheResult(host string, qtype rules.RRType, res filtering
}
// getCachedResult returns stored data from cache for host. qtype is expected
// to be either [dns.TypeA] or [dns.TypeAAAA], or [dns.TypeHTTPS].
// to be either [dns.TypeA] or [dns.TypeAAAA].
func (ss *Default) getCachedResult(
host string,
qtype rules.RRType,