mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-03-04 10:24:40 +01:00
Respect proxy.mainProto in forward plugin (#1259)
* Respect proxy.mainProto in forward plugin * Make the serverProtocol part of pluginsState instead
This commit is contained in:
parent
f4631b9121
commit
d2602fd142
3 changed files with 11 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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{}),
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue