/
plugin_firefox.go
53 lines (43 loc) · 1.21 KB
/
plugin_firefox.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Work around Mozilla's evil plan - https://sk.tl/3Ek6tzhq
package main
import (
"strings"
"github.com/jedisct1/dlog"
"github.com/miekg/dns"
)
type PluginFirefox struct{}
func (plugin *PluginFirefox) Name() string {
return "firefox"
}
func (plugin *PluginFirefox) Description() string {
return "Work around Firefox taking over DNS"
}
func (plugin *PluginFirefox) Init(proxy *Proxy) error {
dlog.Noticef("Firefox workaround initialized")
return nil
}
func (plugin *PluginFirefox) Drop() error {
return nil
}
func (plugin *PluginFirefox) Reload() error {
return nil
}
func (plugin *PluginFirefox) Eval(pluginsState *PluginsState, msg *dns.Msg) error {
if pluginsState.clientProto == "local_doh" {
return nil
}
question := msg.Question[0]
if question.Qclass != dns.ClassINET || (question.Qtype != dns.TypeA && question.Qtype != dns.TypeAAAA) {
return nil
}
qName := pluginsState.qName
if qName != "use-application-dns.net" && !strings.HasSuffix(qName, ".use-application-dns.net") {
return nil
}
synth := EmptyResponseFromMessage(msg)
synth.Rcode = dns.RcodeNameError
pluginsState.synthResponse = synth
pluginsState.action = PluginsActionSynth
pluginsState.returnCode = PluginsReturnCodeSynth
return nil
}