diff --git a/dnscrypt-proxy/plugin_forward.go b/dnscrypt-proxy/plugin_forward.go index 6487aa95..d957f67c 100644 --- a/dnscrypt-proxy/plugin_forward.go +++ b/dnscrypt-proxy/plugin_forward.go @@ -41,7 +41,10 @@ func (plugin *PluginForward) Init(proxy *Proxy) error { } domain, serversStr, ok := StringTwoFields(line) if !ok { - return fmt.Errorf("Syntax error for a forwarding rule at line %d. Expected syntax: example.com: 9.9.9.9,8.8.8.8", 1+lineNo) + return fmt.Errorf( + "syntax error for a forwarding rule at line %d. Expected syntax: example.com 9.9.9.9,8.8.8.8", + 1+lineNo, + ) } domain = strings.ToLower(domain) var servers []string @@ -56,7 +59,8 @@ func (plugin *PluginForward) Init(proxy *Proxy) error { continue } plugin.forwardMap = append(plugin.forwardMap, PluginForwardEntry{ - domain: domain, servers: servers, + domain: domain, + servers: servers, }) } return nil @@ -89,7 +93,7 @@ func (plugin *PluginForward) Eval(pluginsState *PluginsState, msg *dns.Msg) erro } server := servers[rand.Intn(len(servers))] pluginsState.serverName = server - client := dns.Client{Net: "udp"} + client := dns.Client{Net: pluginsState.serverProto} respMsg, _, err := client.Exchange(msg, server) if err != nil { return err diff --git a/dnscrypt-proxy/plugins.go b/dnscrypt-proxy/plugins.go index f511b9e3..60a65dd8 100644 --- a/dnscrypt-proxy/plugins.go +++ b/dnscrypt-proxy/plugins.go @@ -86,6 +86,7 @@ type PluginsState struct { cacheHit bool returnCode PluginsReturnCode serverName string + serverProto string } func (proxy *Proxy) InitPluginsGlobals() error { @@ -222,7 +223,7 @@ type Plugin interface { Eval(pluginsState *PluginsState, msg *dns.Msg) error } -func NewPluginsState(proxy *Proxy, clientProto string, clientAddr *net.Addr, start time.Time) PluginsState { +func NewPluginsState(proxy *Proxy, clientProto string, clientAddr *net.Addr, serverProto string, start time.Time) PluginsState { return PluginsState{ action: PluginsActionContinue, returnCode: PluginsReturnCodePass, @@ -238,6 +239,7 @@ func NewPluginsState(proxy *Proxy, clientProto string, clientAddr *net.Addr, sta questionMsg: nil, qName: "", serverName: "-", + serverProto: serverProto, requestStart: start, maxUnencryptedUDPSafePayloadSize: MaxDNSUDPSafePacketSize, sessionData: make(map[string]interface{}), diff --git a/dnscrypt-proxy/proxy.go b/dnscrypt-proxy/proxy.go index d81b3e53..d4106607 100644 --- a/dnscrypt-proxy/proxy.go +++ b/dnscrypt-proxy/proxy.go @@ -443,7 +443,7 @@ func (proxy *Proxy) processIncomingQuery(clientProto string, serverProto string, if len(query) < MinDNSPacketSize { return } - pluginsState := NewPluginsState(proxy, clientProto, clientAddr, start) + pluginsState := NewPluginsState(proxy, clientProto, clientAddr, serverProto, start) serverName := "-" needsEDNS0Padding := false serverInfo := proxy.serversInfo.getOne()