mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-04-06 06:37:36 +03:00
We now enforce the fact that a query always include a question. It holds true for all practical use cases of dnscrypt-proxy. This avoids quite a lot of redundant code in plugins, and is faster.
47 lines
1 KiB
Go
47 lines
1 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/miekg/dns"
|
|
)
|
|
|
|
type PluginBlockUnqualified struct {
|
|
}
|
|
|
|
func (plugin *PluginBlockUnqualified) Name() string {
|
|
return "block_unqualified"
|
|
}
|
|
|
|
func (plugin *PluginBlockUnqualified) Description() string {
|
|
return "Block unqualified DNS names"
|
|
}
|
|
|
|
func (plugin *PluginBlockUnqualified) Init(proxy *Proxy) error {
|
|
return nil
|
|
}
|
|
|
|
func (plugin *PluginBlockUnqualified) Drop() error {
|
|
return nil
|
|
}
|
|
|
|
func (plugin *PluginBlockUnqualified) Reload() error {
|
|
return nil
|
|
}
|
|
|
|
func (plugin *PluginBlockUnqualified) Eval(pluginsState *PluginsState, msg *dns.Msg) error {
|
|
question := msg.Question[0]
|
|
if question.Qclass != dns.ClassINET || (question.Qtype != dns.TypeA && question.Qtype != dns.TypeAAAA) {
|
|
return nil
|
|
}
|
|
if strings.IndexByte(pluginsState.qName, '.') >= 0 {
|
|
return nil
|
|
}
|
|
synth := EmptyResponseFromMessage(msg)
|
|
synth.Rcode = dns.RcodeNameError
|
|
pluginsState.synthResponse = synth
|
|
pluginsState.action = PluginsActionSynth
|
|
pluginsState.returnCode = PluginsReturnCodeSynth
|
|
|
|
return nil
|
|
}
|