Skip to content

Commit 68f3ab2

Browse files
committed
Unbreak cloaking plugin
In version 2.1.3, when the cloaking pluging was enabled, a blocked response was returned for records that were not A/AAAA/PTR, even with names that were not in the cloaked list.
1 parent 2edfdc4 commit 68f3ab2

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

.ci/ci-test.sh

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ t || dig -p${DNS_PORT} +dnssec www.darpa.mil @127.0.0.1 2>&1 | grep -Fvq 'RRSIG'
6767

6868
section
6969
t || dig -p${DNS_PORT} +short cloaked.com @127.0.0.1 | grep -Eq '1.1.1.1|1.0.0.1' || fail
70+
t || dig -p${DNS_PORT} +short MX cloaked.com @127.0.0.1 | grep -Fq 'locally blocked' || fail
71+
t || dig -p${DNS_PORT} +short MX example.com @127.0.0.1 | grep -Fvq 'locally blocked' || fail
72+
t || dig -p${DNS_PORT} NS cloaked.com @127.0.0.1 | grep -Fiq 'gtld-servers.net' || fail
7073
t || dig -p${DNS_PORT} +short www.cloaked2.com @127.0.0.1 | grep -Eq '1.1.1.1|1.0.0.1' || fail
7174
t || dig -p${DNS_PORT} +short www.dnscrypt-test @127.0.0.1 | grep -Fq '192.168.100.100' || fail
7275
t || dig -p${DNS_PORT} a.www.dnscrypt-test @127.0.0.1 | grep -Fq 'NXDOMAIN' || fail

dnscrypt-proxy/plugin_cloak.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,7 @@ func (plugin *PluginCloak) Reload() error {
136136

137137
func (plugin *PluginCloak) Eval(pluginsState *PluginsState, msg *dns.Msg) error {
138138
question := msg.Question[0]
139-
if question.Qclass != dns.ClassINET ||
140-
(question.Qtype != dns.TypeA && question.Qtype != dns.TypeAAAA && question.Qtype != dns.TypePTR) {
141-
if question.Qclass != dns.ClassINET || (question.Qtype != dns.TypeNS || question.Qtype == dns.TypeSOA) {
142-
pluginsState.action = PluginsActionReject
143-
pluginsState.returnCode = PluginsReturnCodeCloak
144-
}
139+
if question.Qclass != dns.ClassINET || question.Qtype == dns.TypeNS || question.Qtype == dns.TypeSOA {
145140
return nil
146141
}
147142
now := time.Now()
@@ -151,6 +146,12 @@ func (plugin *PluginCloak) Eval(pluginsState *PluginsState, msg *dns.Msg) error
151146
plugin.RUnlock()
152147
return nil
153148
}
149+
if question.Qtype != dns.TypeA && question.Qtype != dns.TypeAAAA && question.Qtype != dns.TypePTR {
150+
plugin.RUnlock()
151+
pluginsState.action = PluginsActionReject
152+
pluginsState.returnCode = PluginsReturnCodeCloak
153+
return nil
154+
}
154155
cloakedName := xcloakedName.(*CloakedName)
155156
ttl, expired := plugin.ttl, false
156157
if cloakedName.lastUpdate != nil {

0 commit comments

Comments
 (0)